Monday, January 14, 2019

Design Patterns in C#




Structural patterns

Design Patterns
 1 , 2
Design Patterns Examples
Liskov Substitution Principle is a way of ensuring that inheritance is used correctly. derived class does not affect the behavior of the parent class, in other words that a derived class must be substitutable for its base class.

Factory Pattern real world example

Abstract Factory vs Factory ***
With the Factory pattern, you produce instances of implementations (AppleBananaCherry, etc.) of a particular interface -- say, IFruit.
With the Abstract Factory pattern, you provide a way for anyone to provide their own factory. This allows your warehouse to be either an IFruitFactory or an IJuiceFactory, without requiring your warehouse to know anything about fruits or juices.


Agile & Scrum
https://www.simplilearn.com/agile-scrum-master-interview-questions-article
Unit Of Work
Generic repository pattern with Unit of Work
https://www.codeproject.com/Articles/581487/Unit-of-Work-Design-Pattern
Abstract Factory vs Factory Pattern
Structural Design pattern: structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.
Is it good practice to implement Repository Pattern / Unit of Work Pattern over top Entity Core?
Many developers write code to implement the repository and unit of work patterns as a wrapper around code that works with the Entity Framework. These patterns are intended to create an abstraction layer between the data access layer and the business logic layer of an application. Implementing these patterns can help insulate your application from changes in the data store and can facilitate automated unit testing or test-driven development (TDD). However, writing additional code to implement these patterns is not always the best choice for applications that use EF, for several reasons: The EF context class itself insulates your code from data-store-specific code. The EF context class can act as a unit-of-work class for database updates that you do using EF. EF includes features for implementing TDD without writing repository code.


The Abstract Factory Pattern

  • Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  • The Abstract Factory pattern is very similar to the Factory Method pattern. One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation.
  • Actually, the delegated object frequently uses factory methods to perform the instantiation!

Factory pattern

  • Factory patterns are examples of creational patterns
  • Creational patterns abstract the object instantiation process. They hide how objects are created and help make the overall system independent of how its objects are created and composed.
  • Class creational patterns focus on the use of inheritance to decide the object to be instantiated Factory Method
  • Object creational patterns focus on the delegation of the instantiation to another object Abstract Factory

No comments:

Post a Comment