What’s the difference between design patterns and architectural patterns

Architecturedesign-patterns

When we read about design patterns on the internet we note that there are 3 categories:

  • Creational
  • Structural
  • Behavioral

But when we create the architecture of a software, then we think about MVP, MVC or MVVM.

For example, among creational patterns I found the singleton pattern, but I have also used singleton in my MPV.

So my question is: Is a design pattern a over all structure of a product?

  • If yes, then how singleton can be a design pattern? Because I can use it anywhere in my application. Basically, it is restricted only to create one instance at a time in memory, but doesn't this concept define how software is designed?

  • If not, then where are MVP, MVC and MVVM in the three categories of patterns? And what is the difference between design and architecture of software?

Best Answer

It requires a detailed explanation but I will try to sketch the differences to best of my knowledge.

Patterns are distilled commonality that you find in programs. It allows us to deconstruct a large complex structure and build using simple parts. It provides a general solution for a class of problems.

A large complex software goes through a series of deconstruction at different levels. At large level, architectural patterns are the tools. At smaller level, design patterns are the tools and at implementation level, programming paradigms are the tools.

A pattern can occur at very different levels. See Fractals. Quick sort, Merge sort are all algorithmic patterns for organizing a group of elements in a order.

For a most simplistic view:

  • Programming paradigms - specific to programming language
  • Design patterns - solves reoccurring problems in software construction
  • Architectural patterns - fundamental structural organization for software systems

Idioms are paradigm-specific and language-specific programming techniques that fill in low-level details.

Design patterns are usually associated with code level commonalities. It provides various schemes for refining and building smaller subsystems. It is usually influenced by programming language. Some patterns pale into insignificance due to language paradigms. Design patterns are medium-scale tactics that flesh out some of the structure and behavior of entities and their relationships.

While architectural patterns are seen as commonality at higher level than design patterns. Architectural patterns are high-level strategies that concerns large-scale components, the global properties and mechanisms of a system.

How are patterns obtained? Through:

  1. re-use,
  2. classification
  3. and finally abstraction to distill the commonality.

If you have followed the thoughts laid above. You will see that Singleton is a "design pattern" while MVC is one of the "architectural" pattern to deal with separation of concerns.

Try reading on:

  1. http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)
  2. http://en.wikipedia.org/wiki/Design_pattern
  3. http://en.wikipedia.org/wiki/Anti-pattern