Coder Social home page Coder Social logo

18021009 / design-pattern-tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gpcodervn/design-pattern-tutorial

0.0 0.0 0.0 128 KB

This project includes all examples about 23 design patterns of GoF with some other patterns in software development

Home Page: https://gpcoder.com/category/design-pattern/

Java 100.00%

design-pattern-tutorial's Introduction

Design-Pattern-Tutorial

This project includes all examples about 23 design patterns of GoF with some other patterns in software development

Design Patterns là gì?

Design Pattern là một kỹ thuật trong lập trình hướng đối tượng, nó khá quan trọng và mọi lập trình viên muốn giỏi đều phải biết. Được sử dụng thường xuyên trong các ngôn ngữ OOP. Nó sẽ cung cấp cho bạn các "mẫu thiết kế", giải pháp để giải quyết các vấn đề chung, thường gặp trong lập trình. Các vấn đề mà bạn gặp phải có thể bạn sẽ tự nghĩ ra cách giải quyết nhưng có thể nó chưa phải là tối ưu. Design Pattern giúp bạn giải quyết vấn đề một cách tối ưu nhất, cung cấp cho bạn các giải pháp trong lập trình OOP.

Design Patterns không phải là ngôn ngữ cụ thể nào cả. Nó có thể thực hiện được ở phần lớn các ngôn ngữ lập trình, chẳng hạn như Java, C#, thậm chí là Javascript hay bất kỳ ngôn ngữ lập trình nào khác.

Mỗi pattern mô tả một vấn đề xảy ra lặp đi lặp lại, và trình bày trọng tâm của giải pháp cho vấn đề đó, theo cách mà bạn có thể dùng đi dùng lại hàng triệu lần mà không cần phải suy nghĩ.

— Christopher Alexander —

Phân loại Design Patterns

Năm 1994, bốn tác giả Erich Gamma, Richard Helm, Ralph Johnson và John Vlissides đã cho xuất bản một cuốn sách với tiêu đề Design Patterns – Elements of Reusable Object-Oriented Software, đây là khởi nguồn của khái niệm design pattern trong lập trình phần mềm.

Bốn tác giả trên được biết đến rộng rãi dưới tên Gang of Four (bộ tứ).

Theo quan điểm của bốn người, design pattern chủ yếu được dựa theo những quy tắc sau đây về thiết kế hướng đối tượng.

Lập trình cho interface chứ không phải để implement interface đó.

Ưu tiên object composition hơn là thừa kế.

Hệ thống các mẫu Design pattern hiện có 23 mẫu được định nghĩa trong cuốn “Design patterns Elements of Reusable Object Oriented Software” và được chia thành 3 nhóm:

Creational Pattern (nhóm khởi tạo – 5 mẫu) gồm: Factory Method, Abstract Factory, Builder, Prototype, Singleton. Những Design pattern loại này cung cấp một giải pháp để tạo ra các object và che giấu được logic của việc tạo ra nó, thay vì tạo ra object một cách trực tiếp bằng cách sử dụng method new. Điều này giúp cho chương trình trở nên mềm dẻo hơn trong việc quyết định object nào cần được tạo ra trong những tình huống được đưa ra.

Structural Pattern (nhóm cấu trúc – 7 mẫu) gồm: Adapter, Bridge, Composite, Decorator, Facade, Flyweight và Proxy. Những Design pattern loại này liên quan tới class và các thành phần của object. Nó dùng để thiết lập, định nghĩa quan hệ giữa các đối tượng.

Behavioral Pattern (nhóm tương tác/ hành vi – 11 mẫu) gồm: Interpreter, Template Method, Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy và Visitor. Nhóm này dùng trong thực hiện các hành vi của đối tượng, sự giao tiếp giữa các object với nhau.

Nhóm Creational (nhóm khởi tạo)

  • Hướng dẫn Java Design Pattern – Singleton
  • Hướng dẫn Java Design Pattern – Factory Method
  • Hướng dẫn Java Design Pattern – Abstract Factory
  • Hướng dẫn Java Design Pattern – Builder
  • Hướng dẫn Java Design Pattern – Prototype
  • Hướng dẫn Java Design Pattern – Object Pool

Nhóm Structural (nhóm cấu trúc)

  • Hướng dẫn Java Design Pattern – Adapter
  • Hướng dẫn Java Design Pattern – Bridge
  • Hướng dẫn Java Design Pattern – Composite
  • Hướng dẫn Java Design Pattern – Decorator
  • Hướng dẫn Java Design Pattern – Facade
  • Hướng dẫn Java Design Pattern – Flyweight
  • Hướng dẫn Java Design Pattern – Proxy

Nhóm Behavioral (nhóm hành vi/ tương tác)

  • Hướng dẫn Java Design Pattern – Chain of Responsibility
  • Hướng dẫn Java Design Pattern – Command
  • Hướng dẫn Java Design Pattern – Interpreter
  • Hướng dẫn Java Design Pattern – Iterator
  • Hướng dẫn Java Design Pattern – Mediator
  • Hướng dẫn Java Design Pattern – Memento
  • Hướng dẫn Java Design Pattern – Observer
  • Hướng dẫn Java Design Pattern – State
  • Hướng dẫn Java Design Pattern – Strategy
  • Hướng dẫn Java Design Pattern – Template Method
  • Hướng dẫn Java Design Pattern – Visitor

Refer: https://gpcoder.com/4164-gioi-thieu-design-patterns/

design-pattern-tutorial's People

Contributors

ptgiang56it 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.