Design patterns vs Frameworks

后端 未结 12 1640
清歌不尽
清歌不尽 2021-01-31 10:52

Can someone illustrate what really is the difference between the two?

相关标签:
12条回答
  • 2021-01-31 10:55

    answer is very easy: framework: how elements of a system such as (component, layers, class ,...) must or should interact with each other

    design pattern: a solution for a high frequence problem. it may be an transformation of MSSQL source code to oracle, ........ and have 3 type: analyse, design and implement patterns.

    0 讨论(0)
  • 2021-01-31 10:56

    A design pattern is a standard solution to a well known (design) problem. For example the Factory pattern, and the Abstract Factory pattern offer a blueprint for implementing designs to overcome common problems with instantiating objects.

    A framework on the other hand contains infrastructure which you can use and extend to develop your own solution. For example a model 2 "web application framework" will contain the infrastructure for building web based applications. It will contain the controller, some gui elements and base classes which we can extend to create our model and business logic. Typically it contains plumbing code and interactions which we inherit when we extend from their base classes. Some examples of frameworks are Struts, JSF, Swing Application Framework, JUnit testing framework, etc...

    Going a step ahead there are also libraries, which we use directly from our code. Usually without extending their classes. Log4J would be an example of a library.

    0 讨论(0)
  • 2021-01-31 10:59

    A design pattern is a well-established design for tackling a problem. A framework is an actual package of code you use to make building applications easier. Note that a framework can and probably will, make use of design patterns.

    0 讨论(0)
  • 2021-01-31 11:04

    Here is GOF's answer:

    Because patterns and frameworks have some similarities, people often wonder how or even if they differ. They are different in three major ways:

    • Design patterns are more abstract than frameworks. Frameworks can be embodied in code, but only examples of patterns can be embodied in code. A strength of frameworks is that they can be written down in programming languages and not only studied but executed and reused directly. In contrast, the design patterns in this book have to be implemented each time they're used. Design patterns also explain the intent, trade-offs, and consequences of a design.

    • Design patterns are smaller architectural elements than frameworks. A typical framework contains several design patterns, but the reverse is never true.

    • Design patterns are less specialized than frameworks. Frameworks always have a particular application domain. A graphical editor framework might be used in a factory simulation, but it won't be mistaken for a simulation framework. In contrast, the design patterns in this catalog can be used in nearly any kind of application. While more specialized design patterns than ours are certainly possible (say, design patterns for distributed systems or concurrent programming), even these wouldn't dictate an application architecture like a framework would.

    0 讨论(0)
  • 2021-01-31 11:04

    This question has been answered a few different ways, though I think a concrete example is missing.

    Design Pattern: A set of rules put together to solve a reoccurring problem. The rules define the pattern. There is no code you can copy paste to implement this. The developer is supposed to understand the rules then implement them.

    Example:

    • Name: Test Driven Development (TDD)
    • Problem: It ensures that the unit tests written cover enough case scenarios that gives you confidence in your production code.
    • Rules: It states that you should write your tests first, then write your code after to pass those tests. This then ensures you're not writing tests to pass your code, but instead writing code to pass your tests.

    Design Patterns are split into 3 categories:

    • Creational Design Patterns:
    • Structural
    • Behavioral

    I've found this link to be helpful in explaining them.


    Framework: A framework, not to be confused with libraries, is the basic structure underlying a system that allows developers to build and deploy software applications in a standardized way.

    Example: The .Net Core framework is a tool that contains a set of libraries that enables developers using the Microsoft stack to write software applications that can be deployed in multiple different environments (Windows, Mac OS, Linux)


    Library: A reusable set of methods/classes put together in one package to provide functionality.

    Example: The System.Collections.dll library enables .Net developers to use things such as a Hashtable.


    It's worth it to also look at other answers, as sometimes it's just a buzzword and it differs from one environment to another. Look here.

    I hope this helps.

    0 讨论(0)
  • 2021-01-31 11:05

    Frameworks are more specific to a problem definition. In order to write one design patterns can be devised or used where ever applicable.

    0 讨论(0)
提交回复
热议问题