Inherit from Abstract class: base.Do() vs field.Do
If im using the command Pattern, is there some rule, that says, that i should use base.Do instead of creating a field?
Example:
or:
Why is the better approach better?
8 Replies
composition allows you to combine multiple things, inheritance only allows a single one
generally prefer composition, even though it's usually more boilerplate
google composition vs inheritance
well in this task im supposed to inherit. Its a study task
otherwise I wouldn't use inheritance at all
and you don't need to override anything on the second thing
in practice, you avoid inheritance if you can
I know. I still have to create examples for some oop design patterns i would almost never use in my personal projects
patterns can be useful at a conceptual level
If i don't override i get compliler issues, that tell me that im supposed to implement them. I guess u would suggest to imblement them in the base?
oh it's a base class
then sure
i mean those are abstract
yes they are... But i guess i can make Redo just execute Execute in abstract base, and there shouldn't be any rule preventing that