Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design Patterns [duplicate]

Possible Duplicate:
How do you know when to use design patterns?

How can I understand/take decision about "When to use what Design Pattern"?

What are the factors to observe while taking decisions about using an appropriate design pattern in an appropriate place?

like image 343
user366312 Avatar asked Jun 14 '09 01:06

user366312


People also ask

How do you avoid code duplication?

To avoid the problem of duplicated bugs, never reuse code by copying and pasting existing code fragments. Instead, put it in a method if it is not already in one, so that you can call it the second time that you need it.

Why is code duplication considered a design anti pattern?

because it goes against Composition over inheritance principle, will force any GameObject who needs to jump to inherit from Character class. This will make the design less flexible.

How do you avoid code duplication in C++?

The conventional approach to reduce this kind of code duplication is to move the common code to a member function, which can be called from all the constructors. Usually, that member function is called init.


1 Answers

Generally, if you're doing it right, there's a pattern for it. You just might now know you're using it.

If you're doing it wrong, there's an anti-pattern for it. But you definitely don't know you're using it.

like image 196
Joel Coehoorn Avatar answered Sep 28 '22 18:09

Joel Coehoorn