Application of more than one Pattern design

Asked

Viewed 195 times

6

I’ve been studying about Patterns design and I thought it was really cool, but there was one thing I couldn’t understand. Regarding Patterns design, can I apply more than one of them to the same project? Whatever it is (e.g., Singleton, Observer, Builder, etc.), I can use one more in a solution that I come to develop?

I intend to make a solution in php and wanted to start it after resolving this doubt. I wanted to put the MVC, but I don’t know if it is considered a Pattern design also.

  • 3

    Yes you can use as many as you want, you should use them when you have that specific problem use by using it does not help at all, except in the case of a job where you are asked to use 3 or more Patterns design.

  • And as for the mvc, it’s considered a Pattern design as well?

  • For the course I did, yes. And each of them can implement a different pattern!

  • 6

    What difference does it make whether or not it’s a pattern? (I think it’s an architectural pattern, but I’m not sure, nor am I interested in knowing) If it applies to your case, use it! The problem is only when two or more different patterns try to solve the same problem in different ways, and are incompatible with each other (type MVC vs MVVM vs MVP vs MVA). But in a project as a whole, if part of it fits more into one pattern, part into the other, part into the two, part into none, you use the pattern you need when you need it.

  • 5

    P.S. I had made a relevant comment on another question, but I think it was removed because I don’t find it, so I’ll repeat here: the problem with studying patterns when you’re a beginner is that they end up being seen as a "cookbook" where you choose one, apply the way it is there and ready, but without really understanding the purpose behind it, without winning experience in solving the problem. For the natural is, when solving N problems and perceiving something common in all of them, to abstract this common feature into a reusable concept - the standard.

  • A good reason for the MVC not to be considered a Pattern design (in the sense of Gof’s 23 Patterns design) is that it is cited in Gof’s book and still not on their Patterns list. Wikipedia in English treats it as an architectural pattern, which makes a lot of sense. I tried to correct the Wiki in Portuguese a few times, but there was always some stubborn and undone the correction, then I gave up.

Show 1 more comment

1 answer

10


You probably haven’t studied enough about it and are still clinging to the rules you artificially created about it. You already use design standards all the time, even without realizing it. Forget this as rules, as recipes, as "good practices", as something to be followed.

And of course you can use several, otherwise it would not be possible to create anything useful. Coding is to join a series of patterns together to achieve a result. Even if these patterns aren’t documented in some book, they’re not famous, or even if they’re so used, so obvious and already implemented in the language that you don’t even realize it’s a pattern.

When you start thinking of patterns as being those listed by the Gang of Four, or on And things like that, you make two mistakes: 1) you don’t see the whole; 2) you keep trying to apply complex patterns where it’s simple. That is, you are looking for problem to apply the tool, when the correct is to do the opposite.

It doesn’t matter if MVC is a design standard or not, whether you need it or not. It will matter if you’re writing a monograph or something that has to define MVC, but in development work, whether it’s this or whether it’s an architecture model, or has another definition, is irrelevant. The doubt occurs precisely for not having understood yet the purpose of such a Pattern design.

  • vlw bigown, I will study more on the subject to deepen myself.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.