When domain modelling with SysML, Generalization, inheritance, and even multiple inheritance are not "evil" and can be used relatively freely. We are not doing code-oriented Decorator patterns - an implementation choice - we are doing domain modelling!

Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
UML keywords
Keywords
"Nobody uses inheritance anymore! Inheritance is "evil"! SysML shouldn't have Block inheritance! And they made the same mistake with SysMLv2! Don't they know anything?

Dr Darren says, "now, please repeat after me":

The Decorator Pattern is a good option (only) for run-time encapsulation of variations of behaviour in certain code implementations, not a replacement for inheritance in domain modelling. Domain modelling!

Ever had someone ask you about inheritance in a job interview and offer up the Decorator Pattern as the complete replacement (because they only understood half of the story)? Be lucky you failed their "test" and aren't working under them. Then go and work for someone who knows about domain modelling in Systems Modeling Language v1 (SysML®) instead!


BTW: Inheritance in OO coding is NOT intrinsically, per se, "evil"

Dr Darren says:
If you have half-read (only) the GoF Design Patterns or you've heard just a little (only) about the Decorator Pattern and then presume to lecture other programmers on the "evil" of inheritance, I recommend you do read (all of) 'Head First Design Patterns', and especially the bit where the "Patterns Guru" Grasshopper explains that the Decorator Pattern is a useful alternative to inheritance in OO coding languages especially FOR BEHAVIOUR and when you need run-time flexibility FOR BEHAVIOUR.

Not always. And not for everything.

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)
External links