Application of more than one design pattern

6

I've been studying design patterns and thought it was cool, but there was one thing I did not understand. Regarding design patterns , can I apply more than one of them in the same project? Regardless of which one (eg, Singleton, Observer, Builder, etc.), can I use one more in a solution that I will develop?

I intend to make a solution in php and wanted to start it after healing this doubt. I wanted to put MVC, but I do not know if it is considered a design pattern as well.

    
asked by anonymous 20.11.2015 / 14:10

1 answer

10

You probably have not studied enough about it and are still attached to rules that artificially created about it. You already use design patterns all the time without even realizing it. Forget this as rules, as recipes, as "good practices," as something to be followed.

Of course you can use several, otherwise you would not be able to create anything useful. Code is to join a series of patterns together to achieve a result. Even if these standards are not documented in some book, they are not famous, or even that they are so used, so obvious and already implemented in the language, that you do not even realize that it is a pattern.

When you start thinking of patterns as being those listed by the Gang of Four, or in and things like that, you make two mistakes: 1) you do not see the whole; 2) is trying to apply complex pattern where the thing is simple. That is, he is looking for a problem to apply the tool, when the correct one is to do the opposite.

It does not matter if the MVC is a design pattern or not, it matters whether you need it or not. It will matter if you are writing a monograph or something so you have to define the MVC, but in development work, whether it is this, or whether it is an architecture model, or has another definition, is irrelevant. The doubt occurs precisely because it has not yet understood the purpose of the design pattern .

    
20.11.2015 / 14:28