Scenarios based Java OO concepts & GoF design patterns
Scenarios based Java OO concepts & GoF design patterns
The following post improves on the design flaws listed in the previous post entitled 02: Scenarios based Java OO design & GoF design patterns – naive Template Method pattern. Scenario: A company named XYZ Retail is in the business of selling Books, … Read more ›...
Q1. Why use design patterns? A1. 1) Capture design experience from the past: E.g. Facade and value object patterns evolved from performance problems experienced due to multiple remote calls. 2) Promote reuse without having to reinvent the wheel: E.g. … Read more ›...
When you are asked in job interviews to explain a design pattern that you had used, many pick “singleton” as it is easy to explain. But, “singleton” design pattern does have lots of nuances that can lead to further drill down questions mentioned in this post. This post also explains...
Next time you are asked to explain a design pattern in an interview, you could pick this as opposed to the very common factory and singleton design patterns. Q1. How will you go about using a builder design pattern instead of constructors to create thread-safe immutable objects? … Read more...
Q1. Why do Proxy, Decorator, Adapter, Bridge, and Facade design patterns look very similar? A1. Some design patterns do have subtle differences, and it is important to understand the intent of a pattern. Decorator and chain of responsibility may look similar but the intent is different. … Read more ›...
Flyweight pattern is about sharing a collection of objects. The flyweight design pattern is a structural pattern used to improve memory usage and performance (i.e. due to shorter and less frequent garbage collections) by creating fewer objects. Instead of creating a large number of objects, we reuse the objects that...
Java executor framework for running multi-threaded applications concurrently, sequentially, and with a strategy design pattern to switch between sequential and concurrent execution. 1. Running concurrently The output will be You can see more than 1 thread process 5 tasks concurrently. … Read more ›...
Design pattern: If you are asked to describe or talk about a design pattern, you could mention this dynamic proxy class as a proxy design pattern. Many pick either singleton or factory design pattern. It would be nicer to pick something other than these two common patterns. … Read more...
There are often patterns that look very similar, but differ in their intent. Most patterns use polymorphism with interface inheritance. Strategy and state design patterns are very similar as well. Proxy, Decorator, Adapter, and Bridge are all variations on “wrapping”
…