Why avoid Conversion Operators

No doubt that the Conversation Operators makes developers life easier by bring in a kind of¬†substitutability, but it comes with a price. If not properly designed/used, it could result in subtle errors that can be easily ignored. Consider the following code. We have a class called Car, which exposes a single property - MakerName. We … Continue reading Why avoid Conversion Operators

Design Patterns : Template Method

The purpose of a Template Method Pattern is to define the skelton of an algorithm, while deferring the exact steps to sub classes. There is plenty of literature on the internet detailing the pattern, so we will skip it and head right to the code. As always, lets begin by defining the contract interface, in … Continue reading Design Patterns : Template Method

Design Patterns : Chain of Responsibility

The intend of Chain of Responibility Pattern is to avoid coupling the sender of a request to its reciever by giving more than one object change to handle the request. Let's try to mimic the execution of classical Waterfall Model with CoR. Let's begin by declaring the contract interface. And our sub classes. The final … Continue reading Design Patterns : Chain of Responsibility

Design Patterns : Fascade Pattern

Fascade, name being an analogy to an architectural fascade, intends set the tone for the entire functionality by providing a simplified yet effective interface wrapping away the complex, pooly designed collection of APIs. Wrong Code Consider following set of Classes. ¬† The Client Code could be As you can see, the Client class is invoking … Continue reading Design Patterns : Fascade Pattern

Patterns,Principles and Programming.

Have been thinking about putting together a collection of Jump Start Tutorials on some core concepts on Programming, finally getting everything together Design Patterns GOF: Adapter Pattern GOF: Strategy Pattern GOF: Singleton Pattern (Lazy) GOF: Fascade Pattern GOF: Chain Of Responsibility Pattern (CoR) GOF: Template Method GOF: Null Object Pattern GOF: State Pattern GOF: Decorator … Continue reading Patterns,Principles and Programming.

Design Patterns : Strategy Pattern

Strategy Pattern lets you create a family of strategies (algorithm) encapsulated into separate interchangeable classes. In our example, we will consider a Client class which needs to invoke different sorting algorithm. ¬† Let's first create the contract interface for different Sorting algorithm. Now that we have our interface ready, let's go ahead and implement different … Continue reading Design Patterns : Strategy Pattern

Design Patterns : Adapter Pattern

There is already a large amount of literature on the Internet which discusses Adapter Pattern. However, the purpose of article is to showcase the implementations of the Adapter Pattern, rather than discussing the application of the pattern. In this post, adapter class is implemented using 1. Inheritance 2. Dependency Injection 3. Generics Consider your old … Continue reading Design Patterns : Adapter Pattern