In Asp.Net MVC, Layouts are like as Master Pages in Asp.Net Web Forms. These helps us to maintain consistent look and feel across all the views within your Asp.Net MVC application. Like Master Pages, Layout may contains common CSS, jQuery files across the multiple Views and one or more placeholders for which Views provide content.
Singleton pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance and provides a global point of access to it.
Prototype pattern is used to create a duplicate object or clone of the current object to enhance performance. This pattern is used when creation of object is costly or complex.
Builder pattern builds a complex object by using simple objects and a step by step approach. Builder class builds the final object step by step. This builder is independent of other objects. The builder pattern describes a way to separate an object from its construction. The same construction method can create different representation of the object.
Abstract Factory method pattern falls under Creational Pattern of Gang of Four (GOF) Design Patterns in .Net. It is used to create a set of related objects, or dependent objects. Internally, Abstract Factory use Factory design pattern for creating objects. It may also use Builder design pattern and prototype design pattern for creating objects.
In Factory pattern, we create object without exposing the creation logic. In this pattern, an interface is used for creating an object, but let subclass decide which class to instantiate. The creation of object is done when it is required. The Factory method allows a class later instantiation to subclasses.
In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book (Design Patterns: Elements of Reusable Object-Oriented Software) for explaining the concept of Design Pattern in Software development. These four authors are collectively known as Gang of Four (GOF).
Design patterns provide solutions to common problems which occur in software design. Design patterns are about reusable designs and interactions of objects.
Software design principles are a set of guidelines that helps developers to make a good system design. The most important principle is SOLID principle. The key software design principles are as:
In previous articles, I have explained the IoC, DI pattern and DI containers. I hope, you understand well the IoC, DI pattern and and DI containers. Now you will learn how to apply it in ASP.NET MVC 4. In this article, I am going to use e>Unit DI Container in MVC4.
The terms Dependency Injection (DI) & Inversion of Control (IoC) are generally used interchangeably to describe the same design pattern. Hence some people says IoC Container and some people says DI container but both terms indicate to the same thing. So don't be confused from the terminology.
ASP.NET Web API is one of the most powerful recent addition to ASP.NET framework. Sometimes, you have to post a form data using jQuery JSON to Web API or MVC method, which have multiple input fields.Passing each and every input field data as a separate parameter is not good practice, even when you have a strongly typed-view. The best practice is, pass a complex type object.
Dependency Injection (DI) is a software design pattern that allow us to develop loosely coupled code. DI is a great way to reduce tight coupling between software components. DI also enables us to better manage future changes and other complexity in our software. The purpose of DI is to make code maintainable.
So many developers are confused about the the term Dependency Injection (DI). The confusion is about terminology, purpose, and mechanics. Should it be called Dependency Injection, Inversion of Control, or Service Locator? Over the Internet, there are a lot of articles, presentations and discussion but, unfortunately, many of them use conflicting terminology.