177

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?

nbro
  • 15,395
  • 32
  • 113
  • 196
Jeevan Bhatt
  • 5,881
  • 18
  • 54
  • 82
  • Already discussed : https://stackoverflow.com/a/46419722/3649347 – Tell Me How Sep 26 '17 at 07:11
  • 4
    Check out this list of design pattern and architectural pattern resources https://github.com/DovAmir/awesome-design-patterns – dov.amir Jun 09 '18 at 14:45
  • Does this answer your question? [Software architecture design patterns](https://stackoverflow.com/questions/4192887/software-architecture-design-patterns) – duffymo Dec 16 '22 at 17:33

8 Answers8

253

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
ivanjermakov
  • 1,131
  • 13
  • 24
pyfunc
  • 65,343
  • 15
  • 148
  • 136
  • 24
    Very well done and elaborated. Now I only wished everybody would use the terms as differentiated as you put them here. May I pin a print of your answer at the wall above the coffee dispenser of our marketing dept.? Maybe they'll understand one day. ;-) – ofi Nov 22 '10 at 08:12
  • @ofi: Thank! Use of language construct can both mislead us and guide us. This is something I find quite powerful. – pyfunc Nov 22 '10 at 08:31
  • +3 for Saving us from the Interview Questions :) – RAJESH KUMAR ARUMUGAM May 26 '17 at 05:12
  • Good answer, thanks !! as @ofi said, i will print it and pin in the design team wall. – Rolly Feb 27 '18 at 14:50
  • Very well explained, thanks – Pravin Sep 01 '22 at 17:20
21

Design Patterns are well known patterns for solving technical problems in a way that has proven itself many times. Design patterns are common design structures and practices that make for creating reusable Object-Oriented software. Design pattern examples are Factory Pattern, Singleton, Facade, State, etc. Design patterns can be used to solve smaller problems throughout the application, and are much easier to inject, change, add than the overall architecture

architecture patterns are well known patterns for solving software application architecture problems. Software application architecture is the process of defining a structured solution that meets all of the technical and operational requirements. Application's architecture is the overall 'organization' of the code. Examples of different Architectures might be MVC, MVVM, MVP, n-layer (i.e. UI-BLL-DAL), etc. The architecture typically needs to be decided up front and often is difficult to change once the application is built.

RBT
  • 24,161
  • 21
  • 159
  • 240
2

Architectural elements tend towards collections of classes or modules, generally represented as boxes. Diagrams about architecture represent the loftiest level looking down, whereas class diagrams are at the most atomic level. The purpose of architecture patterns is to understand how the major parts of the system fit together, how messages and data flow through the system, and other structural concerns. Architecture patterns utilize a variety of component types, each typically composed of successively smaller modules. Each component has a responsibility within the architecture Design patterns are low level or class level design patterns for smaller particles of applications.

For more information: https://www.oreilly.com/ideas/contrasting-architecture-patterns-with-design-patterns

Vishnu Chandel
  • 113
  • 2
  • 10
1

Well, for the main part it's a matter of the language. According to my experience the borderline between design and architecture, as far as software is concerned, is a broad river with it's width resulting from the water level which in turn is mainly influenced by the seasons of marketing. Generally the term "design" is used with a strong aspect of the software product's behavior as recognized by end users, whereas "architecture" stands for the technical structure of a software, i. e. the components, libraries, protocols and whatever it needs to fulfill the design. "Design patterns" take two roles: 1st they are regarded as best practices for solving a category of (more or less) standard problems, not prodiucts; 2nd they help the developers to communicate. Staying with your example of a Singleton, it allows us to know what the mechanics are about by just using the word, instead of explaining every time, that we created a single instance by using a designated dataspace (variable or whatever) which is set in a controlled manner and is guaranteed to be the only one, because we protected the constructor of the class etc. So IMHO the short answer to your question is: It depends on who is talking. Does that make some sense?

ofi
  • 364
  • 1
  • 4
1

Design Patterns differ from Architectural Patterns in their scope, they are more localized, they have less impact on the code base, they impact a specific section of the code base, for example:

How to instantiate an object when we only know what type needs to be instantiated at run time (maybe a Factory Class?)
How to make an object behave differently according to its state (maybe a state machine, or a Strategy Pattern?)

Architectural Patterns have an extensive impact on the code base, most often impacting the whole application either horizontally (ie. how to structure the code inside a layer) or vertically (ie. how a request is processed from the outer layers into the inner layers and back). Examples of Architectural Patterns: Model-View-Controller, Model-View-ViewModel

1

If i put this very simply

Architecture governs data flow in app i.e. how the data flows between various components in app

Design Pattern deals with any destruct you apply to break a large unit into manageable chunks

sashi_bhushan
  • 394
  • 3
  • 16
1

The original Gang of Four book captured design patterns as common solutions to problems in object-oriented programming. Example implementations were given in C++ and Smalltalk. Java hadn't been invented yet.

Functional programmers would say that the Gang of Four book listed flaws to problems in object-oriented programming.

Design is such a fuzzy word here. It applies at the level of methods, components, and systems.

I think of design patterns as common solutions at the method or component level.

Architecture patterns are broader in scope and apply to systems of components.

The idea of a pattern as a suggeste solution to a common problem holds across the spectrum.

duffymo
  • 305,152
  • 44
  • 369
  • 561
-1

The architectural pattern is like a blueprint and the design pattern is the actual implementation.

More on it:

Raheem Amer
  • 1
  • 1
  • 2
  • Not so. Read the GoF book and you'll see. – duffymo Dec 16 '22 at 17:34
  • @duffymo elaborate more on why this is wrong without the need to read a whole book to understand the reason you are disagreeing with me :)) – Raheem Amer Dec 17 '22 at 23:41
  • You said design pattern is the actual implementation. The book contains 23 patterns, each one is independent of implementation. Your concept of design pattern is wrong. The word "design" itself implies a conception prior to implementing. Design patterns are implemented in every language, even ones that weren't invented when the book was written. – duffymo Dec 18 '22 at 16:15
  • @duffymo There is no outrage, just simply having a mature discussion with someone who disagrees with me. It's that simple. Thanks for clarifying your point :) – Raheem Amer Dec 18 '22 at 22:21