Design patterns vs Frameworks

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

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

12条回答
  •  执念已碎
    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.

提交回复
热议问题