Interpreter design pattern

You can see a sample implementation of the interpreter design pattern.it’s possible smilliar to each other definitions for interpreter in internet literature.

  •  interpreter pattern is a design pattern that specifies how to evaluate sentences in a language
  • Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
  • Map a domain to a language, the language to a grammar, and the grammar to a hierarchical object-oriented design

Sample scenarios for this pattern

  • read barcode
  • roman numbers converting numbers   –   (X == 10)
  • Total ASCII values ​​of the characters  – (A == 65)
  • reading result operations with mathematical and logical operators (10*5-3==47)
  • analysis of the encrypted text

Now let’s take a look our sample codes and diagram

ClassDiagram1

Main classes

example of use:

see you blog post

also get clone using VisualStudio 2012 with git source control in the bitbucket repository.You can see repository address and git address in the below

Repository : https://bitbucket.org/yemrekeskin/interpreter.designpattern

Git : https://yemrekeskin@bitbucket.org/yemrekeskin/interpreter.designpattern.git to get clone repository

Visio Drawing : Service Designing

Everything is diagram.You see enterprise system with a wide perspective and know better.you can also easily manage these enterprise projects. I came across a interesting article in association with diagrams.You can available this article via 100 Diagrams That Changed the World

Now Let’s take a look my visio drawings about services :D

Diagram : 0

Each web or windows service application (service provider application) can consist of multiple service.

untitled(4)

Diagram : 1

untitled(5)

Diagram : 2.1

Enterprise Applications have multiple application server an this is mostly three.Each application server come true  also spesific tasks of application services an tools. For instance; Web Services in a app server,Windows services in other app server, pdf builder directory in other app server or Report Services in another app server and so on.

untitled

Diagram : 2.2

App Servers’ specific task is significant and whole system may be affected from these tasks’ errors

untitled(2)

Diagram : 2.3

Therefore you should install all tool and services related enterprise application for each app server.You just switch on/off mode.

untitled(3)

have a good codeday :D

Chain of Responsibility design pattern

Let’s explain the pattern step by step ;

  • The chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects.This design pattern is situated insi behavioral patterns.
  • Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
  • Launch-and-leave requests with a single processing pipeline that contains many possible handlers.
  • An object-oriented linked list with recursive traversal.

Minimal Example 

UML Diagram :

chain

Code Snippet:

Loan Example with generic

Class diagram

Capture_ChainOfResponsibility

Code Snippet:

have a good codeday :D

Observer Design Pattern in C#

The observer pattern is a Gang of Four design pattern and one of the most interesting patterns in design pattern. this pattern listed under Behavioral Patterns.

Definition

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.This pattern suitable push-based notifications.

you can watch youtube video related observer design pattern’s logic.I recommend this.

and you can find a great technical post via codeproject.In this post you’ll see example blog subscriber with observer pattern.I made three example for this.

1- Classic sample via gist (ObserverDesignPattern.cs)

2 – Sample with event and delegete via gist (ObserverPatternWithEventAndDelegate.cs)

3 – Sample with generic via gist (ObserverPatternWithNetFramework.cs)

you can examine implementation observer pattern with generic structure

have a good codeday :D

Strategy Design Pattern (example for payment types)

Hi everyone,

We continue to studies about design patterns.I want to illustrate strategy design patern in this post.I implemented a sample scenario related accounting and tranfer operations of payment types for this and coded.Also ı coded  classcic sample scenario(SalaryCalc for different Staffs,PermitDayCalc for different Staff and department) of strategy pattern.you can see this sample via my gist

Our scenario’s class diagram

Capture_StrategyDesignPattern

You can see th following code snippet

implementation to strategy design pattern

using pattern

Capture_patternStartegy

have a good day

EF Codefirst with Design Patterns

I frequently use codefirst approach of  Entity Framework in my asp.net mvc projects. Thefore I want to do much more flexible,independency using design patterns and that project is output.

Briefly;

Factory Pattern : ContextFactory

Singleton Pattern : ContextFactory and UnitOfWork

UnitOfWork Pattern 

Repository Pattern :  Generic Repository

Decorator Pattern : RepositoryDecoratorBase – CachableRepositoryLoggableRepositoryAuditableRepository

Dependency Injection : Ninject Container as IoC

Used Structure : Object Caching,Logging with Log4net, Advanced Object Orinted Principles

you can download via my github repo

Review Of Structural Design Pattern

Structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.

Adapter Design Pattern : Match interfaces of different classes – via here

Bridge Design Pattern :  Separates an object’s interface from its implementation – via here

Composition Design Pattern : A tree structure of simple and composite objects – via here

Decorator Design Pattern : Add responsibilities to objects dynamicall – via here turkish post

Facade Design Pattern : A single class that represents an entire subsystem – via here – also via here turskish post

Flyweight Design Pattern : A fine-grained instance used for efficient sharing – via here turkish post

Proxy Design Pattern : An object representing another object – via here

Source : http://sourcemaking.com/structural_patterns

 

Command Design pattern

Hi everyone,

in one of previous my posts, I illustrated the using of command design pattern (command query reponsibility separation with command processor) via here.in this post I will exemine this pattern as simpler.

Intent

- encapsulate a request in an object
– allows the parameterization of clients with different requests
– allows saving the requests in a queue

Composition design pattern’s uml diagram

CommandUML

implementation to command design pattern

Class Diagram

Capture_Command_Design_Pattern

see you next post

Composition Design Pattern

Definition

The intent of this pattern is to compose objects into tree structures to represent part-whole hierarchies.Composite lets clients treat individual objects and compositions of objects uniformly.

Composition design pattern’s uml diagram

composite

our hierarchies

Capture_Composition_samples

implementation to composition design pattern

Class Diagram

Capture_Composition_Class_Diagram

See you next post