Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 101495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:46:56+00:00 2026-05-11T00:46:56+00:00

I am aware of the responses at Prefer composition over inheritance and am aware

  • 0

I am aware of the responses at Prefer composition over inheritance and am aware of the merits of composition over inheritance.

But there are cases where inheritance does have a good role to play. It’s the incorrect use of inheritance hierarchy that causes all the issues related to reuse.

Take the example of the following controls…

Button/Textbox/Combobox/ListBox/Grid etc. 

Typically they are implemented as

public class Control {     ... }   public abstract class TextBoxBase : control {     .... }  public class TextBox : TextBoxBase {     .... }  public abstract class ButtonBase: control {     .... }  public class Button: ButtonBase {     .... }   public class TextBox : TextBoxBase {     .... }   public class NumericTextBox: TextBox {     .... } 

NOTE: Both the UI and the functionlity is reusable.

I may be wrong or partially correct. Your thoughts would only help me improve my understanding of this subject.

How would you go about designing the control model/hierarchy without using inheritance, and which one do you think is better?

Please take into account the ease of use, use of IDE for this control as well.

P.S: This question is also inspired by this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:46:57+00:00Added an answer on May 11, 2026 at 12:46 am

    Preferring composition isn’t the same as mandating it in every situation. To add to your UI example, I’d say that both Java and .NET benefit from using an inheritance hierarchy for streams.

    I suggest you have a look at the inheritance tree for Windows Presentation Foundation though – that’s a relatively modern UI toolkit designed for composition. That enables weird and wonderful things – like buttons which contain further buttons etc. Sometimes (as in that example) it will be useless – but the general design is powerful.

    I’m not saying I’m ideal – nor would I claim to know very much about WPF – but it’s an interesting starting point.

    I should point out that even within WPF inheritance is used extensively – but not in quite the same way as in (say) WinForms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I wouldn't hassle with the NameScopes etc. and would rather… May 11, 2026 at 11:17 am
  • added an answer wget can create an HTML mirror of a website. Look… May 11, 2026 at 11:17 am
  • added an answer I'm not a Java expert, but it seems like you're… May 11, 2026 at 11:17 am

Related Questions

I am aware of the responses at Prefer composition over inheritance and am aware
I want to convert a std::string to lowercase. I am aware of the function
I am aware of how to setup autocompletion of python objects in the python
Of course I am aware of Ajax, but the problem with Ajax is that
I am aware of CocoaMySQL but I have not seen a Mac GUI for
I am aware of this command: cvs log -N -w<userid> -d1 day ago Unfortunately
I am aware of using jconsole to attach to a java process to get
As far as tools go, I am aware of Haxe , MTASC , and
How do you debug PHP scripts? I am aware of basic debugging such as
Can anybody please explain how this could possibly happen? I am completely aware of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.