Giter Site home page Giter Site logo

design-pattern-go-code's Introduction

why builder ?
1. Khởi tạo các đối tượng của 1 struct nhưng struct đó có quá nhiều các thuộc tính.
 khi khởi tạo bình thường cần nắm kieur dữ liệu,thứ tự :
 vi du : account bank 
2 .Có thể tạo ra nhiều biến thể khác nhau cho cùng một đối tượng
House : normal House or iglooHouse 
3. Khi co 1 struct khoi tao doi tuong  day du cac thuoc tinh ...
-------
product =>house
builder interface
concrete builder 1
concrete builder 2
director

why factory 
1.1 nhu caau thi co 1 hoac nhieu cach khoi 1 hoac nhieu doi tuong san pham =>struct

abstract product interface 1 shoe 
abstract product interface 2 short 
concrete product 1 
concrete product 2
abstract factory interface 1 adidas
abstract factory interface 2 nike
concrete factory 1 
concrete factory 2

why prototype 
tạo ra các bản sao của 1 đối tượng mà struct của nó ở bên trong chứa 1 struct khác.
còn trong trường hợp các thuộc tính ở bên trong các struct chỉ là các primitive type 
tức là  1 kiểu nguyên thủy ví dụ string,int . có thể sử dụng toán tử =

--
-prototype interface 
    +clone 
-concrete prototype 1 -File
-concrete prototype 2 -Folder

why Chain of responsibility
khi chúng ta có 1 đối tượng và các đối tượng đó của chúng ta cần được xử lí
 bởi một chuỗi các hành vi xử lí tuần tự 
 vi du :Chúng ta có đối tượng , Đối tượng đó phải xử lí hành vi A sau khi kết thúc hành vi A,
 chúng ta tiếp tục xử lí hành vi B sau khi kết thúc B, ... 1 chuỗi xử lí các hành vi

--
client ->patient
handler interface ->department
    +Execute
    +SetNext
concrete handler 1 ->reception
concrete handler 2 ->doctor
concrete handler 3 ->medicine
concrete handler 4 ->cashier


wwhy observer
1 doi tuong phat di thong bao ->cho tat ca cac doi tuong da dang ki nhan tin voi observer

--
subject interface->phat thong bao, nhan dang ki 
concrete subject ->item 
observer interface
concrete observer ->customer 

why factory method 
Tạo một đối tượng mà không cần thiết chỉ ra một cách chính xác lớp nào sẽ được tạo bằng cách nhóm các đối tượng
 liên quan đến nhau và sử dụng 1 đối tượng trung gian để khởi tạo đối tượng cần tạo
ví dụ: chúng ta sẽ tạo các phương thức thanh toán cho 1 shop bằng factory method, hình thức thanh toán
 có thể bằng tiền mặt hoặc bằng thẻ debit

design-pattern-go-code's People

Contributors

dothiphuc81299 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.