Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would you design the the control tree/hierarchy without inheritance?
    text
    copied!<p>I am aware of the responses at <a href="https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance">Prefer composition over inheritance</a> and am aware of the merits of composition over inheritance.</p> <p>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.</p> <p>Take the example of the following controls...</p> <pre><code>Button/Textbox/Combobox/ListBox/Grid etc. </code></pre> <p>Typically they are implemented as</p> <pre><code>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 { .... } </code></pre> <p>NOTE: Both the UI and the functionlity is reusable.</p> <p>I may be wrong or partially correct. Your thoughts would only help me improve my understanding of this subject.</p> <p>How would you go about designing the control model/hierarchy without using inheritance, and which one do you think is better?</p> <p>Please take into account the ease of use, use of IDE for this control as well.</p> <p><strong>P.S: This question is also inspired by <a href="https://stackoverflow.com/questions/361371/should-inheritance-of-non-interface-types-be-removed-from-programming-languages">this question</a>.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload