Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

structural vs behavioural design patterns [closed]

I just started reading design patterns and I have some basic doubt and was not clear even after going through many articles. Can someone please explain me following? I have seen many similar posts here but they are not very clear.

  1. How did they segregate in to structural and behavioural patterns?

  2. Is there any good book to follow?Now I am following Head first design patterns.

  3. What is the easy way to remember all these patterns and apply? I thought of remembering UML diagram and concept for each pattern. Do you suggest any other way?

like image 426
Java P Avatar asked Jul 13 '15 17:07

Java P


1 Answers

  1. How did they segregate in to structural and behavioural patterns?

From Gof book

"Structural patterns are concerned with how classes and objects are composed to form larger structures. "

some structural patterns:

  • Adapter
  • Decorator
  • Facade
  • Proxy
  • Flyweight

etc

"Behavior patterns are concerted with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just the patterns of objects or classes but also the patterns of communication between them."

Some behavior patterns:

  • Chain of Responsibility
  • Command
  • Iterator
  • Mediator
  • Observer
  • Visitor

etc

  1. Is there any good book to follow?Now I am following Head first design patterns.

This question is out of scope of SO since we aren't really supposed to recommend books.

  1. What is the easy way to remember all these patterns and apply? I thought of remembering UML diagram and concept for each pattern. Do you suggest any other way?

UML diagrams of design patterns are confusing because several patterns have identical or similar enough diagrams that you can't tell them apart. Unfortunately, the easiest way is to just use them enough to just know how to use them. And keep a Design Pattern book handy to find motivations for the lesser used patterns you don't remember off the top of your head.

like image 152
dkatzel Avatar answered Oct 13 '22 00:10

dkatzel