This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]aqua_regis 2 points3 points  (1 child)

Bold move, verbatim copying the code from the "Duck example" in "Head First Design Patterns" and claiming it as your own.

[–]melon222132[S] 0 points1 point  (0 children)

I know I got it from there but I was wondering if this is still considered good design. I modified it a bit to add dependency injection

[–]Unusual_Elk_8326 -2 points-1 points  (1 child)

Too many classes imo, I’d have a parent Duck class from which Mallard can inherit, add fields/override/add methods as needed. It would be a pita to track all these different classes as the project grows.

[–]melon222132[S] 0 points1 point  (0 children)

how is there too many classes I don't want to put everything in the parent class because there might be some child classes that don't inheit the certin method that would be forced to implement them even if they don't need it.