简体   繁体   中英

Which design patterns improve performance?

Always the first thing i hear when we talk about design pattern is like a documented solution to common architectural issues.

I am curious to know which design patterns are good solutions to improve performance of an application in general.

Flyweight reduces memory consumption.

The Proxy pattern can be used for speed optimization.

The Bridge pattern can change the implementation of an abstraction on the fly - always picking the most efficient one.

On a more serious note, design patterns will probably reduce performance. From my experience, the usage of design patterns gives cleaner, more maintainable code. Should you need to optimize anything, you would probably need to de-design pattern the code.

Often performance of code is dependent on a relatively small piece (a data structure, a function, or even a single loop), so it doesn't go into the scope of design patterns any way. Changing a straight forward function in C to a super optimized version in assembly probably won't change the way the entire class behaves.

Probably the "don't-do-stupid-tings" pattern. If followed to the tee, you'll find it beats:

  • Factory
  • Singleton
  • MVC
  • Aspect Oriented Programming
  • Extreme Programming and Extreme Programmers (mercilessly)
  • DotNetNuke (twice)
  • Drupal (once)

Hands down

Object Pool Pattern

The object pool pattern is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand.

Object pools are primarily used for performance: in some circumstances, object pools significantly improve performance.

There is nothing like that.Design patterns are used to make your development and maintance easier.

mostly design patterns are used for

design pattern is a general reusable solution to a commonly occurring problem in software design

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM