LoginSignup
0
0

More than 3 years have passed since last update.

Design Patterns in Python: Introduction

Last updated at Posted at 2020-04-07

What is a design pattern?

Design patterns are widely accepted solutions to recurring problems.

Why do we need them?

Reusing these patterns saves our time to reinvent the wheel and encourage us to adopt the best practices.

Facts about design patterns

  • language-neutral
  • dynamic
  • intentionally incomplete for possible customization

Three major design patterns

  • Creational : Polymorphism
  • Structural : Inheritance
  • Behavioral : Methods and their signatures

Polymorphism:
1. relies on inheritance
2. Allows child classes to be instantiated and treated as the same type as its parent
3. Enables a parent class to be manifested into any of its child classes

A Pattern Context

  • Participants: classes
  • Quality attributes: Usability, modifiability, reliability, etc
  • Forces: various factors or trade-offs to consider
  • Consequences: side effects

Pattern Language

  • Name: should be meaningful and memorable
  • Context
  • Problem
  • Solution: Structure: relationships among elements; Behavior: interactions
  • Related patterns

Links

Creational Patterns

Structural Patterns

Behavioral Patterns


To be continued...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0