Skip to main content

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
  1. Abstract Factory Pattern: Create instances of classes belonging to different families
  2. Builder Pattern: Separate representation and object construction
  3. Factory Method Pattern: Create instances of derived classes
  4. Prototype Pattern: Clone or copy initialized instances
  5. Singleton Pattern: Class with only one single possible instance
Structural Pattern
  1. Adapter Pattern: Match interfaces of classes with different interfaces
  2. Bridge Pattern:: Separate implementation and object interfaces
  3. Composite: Simple and composite objects tree
  4. Decorator: Dynamically add responsibilities to objects
  5. Facade: Class that represents sub classes and subsystems
  6. Flyweight: Minimize memory usage by sharing as much data as possible with similar objects
  7. Proxy: Object that represents another object
Behavioural Pattern
  1. Chain of Responsibility: Pass requests between command and processing objects within a chain of objects
  2. Command: Encapsulate a method call as an object containing all necessary information
  3. Interpreter: Include language elements and evaluate sentences in a given language
  4. Iterator: Give sequential access to elements in a collection
  5. Mediator: Encapsulates and simplifies communication between objects
  6. Memento: Undo modifications and restore an object to its initial state
  7. Observer: Notify dependent objects of state changes
  8. State: Change object behavior depending on its state
  9. Strategy: Encapsulate algorithms within a class and make them interchangeable
  10. Template Method: Define an algorithm skeleton and delegate algorithm steps to sub classes so that they may be overridden
  11. Visitor: Add new operations to classes without modifying them
There are several other patterns such as Parallel Patterns, SOA Patterns, Enterprise Architecture Patterns, etc… So if we work in the respective area don’t hesitate to look up patterns that may help you to be more efficient and build better applications.

Comments

Popular posts from this blog

Difference between NPM and NPX

NPM Vs NPX npm  - Javascript package manager npx  - Execute npm package binaries https://docs.npmjs.com/files/folders#executables If you use  npm 5.1 or earlier , you can't use npx. Instead, install create-react-app globally: npm install -g create-react-app Now you can run: create-react-app my-app NPM: One might install a package locally on a certain project: npm install some - package Now let's say you want NodeJS to execute that package from the command line: $ some - package The above will  fail . Only  globally installed  packages can be executed by typing their name  only . To fix this, and have it run, you must type the local path: $ ./ node_modules /. bin / some - package You can technically run a locally installed package by editing your  packages.json  file and adding that package in the  scripts  section: { "name" : "whatever" , "version" : "1.0.0" , "scripts" : { ...

Books To Refer

1. C#   in Depth ,  Third   Edition : Foreword   by Eric   Lippert        By:  Jon Skeet    Publication Date:  16-SEP-2013 2. Learning jQuery - Fourth Edition     B y:  Jonathan Chaffer; Karl Swedberg     Pub. Date:  June 25, 2013      3.Beginning JSON                    By:  Ben Smith     Publication Date:  04-MAR-2014 4. Responsive Web Design with jQuery     By:  Gilberto Crespo      Pub. Date:  November 25, 2013 5. Developing Responsive Web Applications with AJAX and jQuery       By:  Sandeep Kumar Patel  P ub. Date:  July 25, 2014 6. Dependency Injection in .NET     by  Mark Seemann

Create ASP.NET Core React-Redux Without Template

Node JS Visual Studio Code NET Core SDK (I’m using SDK version 2.2) Omni Sharp C# extension mkdir DotnetReactRedux cd DotnetReactRedux dotnet new mvc Code . npm init If you didn’t already install Webpack globally run below: npm install webpack -g npm install webpack-cli -g Then run below to add Webpack to your project npm i webpack –-save-dev npm i webpack-cli --save-dev open package.json file and add below { "name": "myapp", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "webpack", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "webpack": "^4.20.2", "webpack-cli": ...