Skip to main content

Posts

Showing posts from July, 2016

Design Patterns

Design Pattern - Design pattern to build high quality robust applications.             Developer have to take care to select the right pattern for the right problem. Improper usage lead to  unmaintainable, complex and inefficient code .              We shall take a look at how to use the well known Gang of Four (GoF) Design Patterns in C# 4.0 code. Those patterns will work well in any project that uses C# but especially in WPF, WCF, WinForms, ASP.NET projects.  The GoF Design Patterns are divided into 3 categories : Creational Patterns, Structural Patterns and Behavioral Patterns . I am going to explain each GoF Design Pattern in detail and will show you examples of how to write good C# 4.0 code that implement those patterns. Creational Pattern Abstract Factory Pattern:  Create instances of classes belonging to different families Builder Pattern:  Separate representation and object construct...

Dependency Injection (DI) vs. Inversion of Control (IOC)

The main goal of Inversion of control and Dependency Injection is to remove dependencies of an application. This makes the system more decoupled and maintainable. First let’s try to understand IOC (Inversion of control). If you go back to old computer programming days, program flow used to run in its own control. For instance let’s consider a simple chat application flow as shown in the below flow diagram. End user sends chat message. Application waits for the message from the other end. If no message is found it goes to Step 2 or else moves to Step 4. Displays the message. User continues with his work ahead. Now if you analyze the program flow closely, it’s sequential. The program is in control of himself. Inversion of control means the program delegates control to someone else who will drive the flow. For instance if we make the chat application event based then the flow of the program will go something as below:- End user sends chat message. User continues with his...