Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 575
Siva Avatar asked Feb 16 '11 06:02

Siva


2 Answers

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.

like image 74
Karl Avatar answered Sep 23 '22 02:09

Karl


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.

like image 31
Eli Iser Avatar answered Sep 27 '22 02:09

Eli Iser