Tags » Design Pattern

Composite pattern explained with C++ samples

Composite pattern is a commonly used design pattern ; it can be used if we need to treat group of objects in the same way as a single object.In a composite patter we can maintain a tree like structure. 73 more words

C++

Một design pattern trong C++ giúp bảo trì code ngon ngọt

Hellu! Lại là tôi đây. Trong bài trước chúng ta đã học về 1 design biến hoá việc kế thừa thành việc bao hàm. Nghĩa là mặc dù kế thừa là hay nhưng trong trường hợp đó nó lại đâm ra dở. 702 more words

C

Proxy Pattern Application

“In computer programming, the proxy pattern is a software design pattern. A proxy, in its most general form, is a class functioning as an interface to something else.” – Wikipedia… 962 more words

A good tutorial on Builder design pattern

Original article: https://jlordiales.me/2012/12/13/the-builder-pattern-in-practice/

public class User {
  private final String firstName; // required
  private final String lastName; // required
  private final int age; // optional
  private final String phone; // optional
  private final String address; // optional

  private User(UserBuilder builder) {
    this.firstName = builder.firstName;
    this.lastName = builder.lastName;
    this.age = builder.age;
    this.phone = builder.phone;
    this.address = builder.address;
  }

  public String getFirstName() {
    return firstName;
  }

  public String getLastName() {
    return lastName;
  }

  public int getAge() {
    return age;
  }

  public String getPhone() {
    return phone;
  }

  public String getAddress() {
    return address;
  }

  public static class UserBuilder {
    private final String firstName;
    private final String lastName;
    private int age;
    private String phone;
    private String address;

    public UserBuilder(String firstName, String lastName) {
      this.firstName = firstName;
      this.lastName = lastName;
    }

    public UserBuilder age(int age) {
      this.age = age;
      return this;
    }

    public UserBuilder phone(String phone) {
      this.phone = phone;
      return this;
    }

    public UserBuilder address(String address) {
      this.address = address;
      return this;
    }

    public User build() {
      return new User(this);
    }
  }
}
General

MVC

MVC stands for Model-View-Controller and is a recognized design patterns for developing software applications. ASP.NET MVC based applications are made up of:

  • Models – These are classes that model the data of the application.
  • 74 more words
Blog

Decorator Pattern Explained with C++ sample

Decorator pattern means decorating an existing class by giving additional responsibility to it dynamically.


let’s take an example of an ice cream;we can decorate an ice cream with different adding like(fruits , nuts and wafers etc). 205 more words

C++

Repository Pattern with Dapper SQL and MongoDB

The gol is to show how to use Repository Pattern to access multiple databases. Our business class does not need to know where is the database or wich one is. 61 more words

C#