GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ELC/python-design-patterns

BranchesTags
Open more actions menu

Latest commit

 

History

33 Commits
33 Commits

Folders and files

NameName
Last commit message
Last commit date
patterns
patterns
 
 
.gitignore
.gitignore
 
 
Pipfile
Pipfile
 
 
Pipfile.lock
Pipfile.lock
 
 
README.md
README.md
 
 

Repository files navigation

Python Design Patterns

This repo is a collection of non-trivial examples of several design patterns implemented in different ways. Its aim is to contrast traditional (i.e. GoF) design patterns with more Pythonic equivalents, metrics about each implementation are also provided.

The notion of being Pythonic is indeed subjective and it is used in the sense of leveraging built-in Python features such as Protocols, Callable classes, closures, partial evaluation, generators, decorators, first-class functions and so on.

Each pattern has an independent README linked below with a guide to highlight differences between implementation details.

Why This repo?

The python-patterns repo already provides a succint and clear way to implement idiomatic patterns in Python.

This repo focuses on showing different ways to implement the same pattern, including the traditional Java/C/C# like implementation to provide the reader with a comparison. Moreover metrics are added to each implementation to better contrast solutions.

Patterns

Behavioural

  • Strategy
  • Observer
  • Iterator
  • Command

Creational

Structural

  • Bridge

Metrics

The metrics to be used are:

  • Cyclomatic Complexity: is equal to the number of linearly independent paths through the code.
  • Maintainability Index: is calculated as a factored formula consisting of SLOC, Cyclomatic Complexity and Halstead volume.
  • LOC: The total number of lines of code. It does not necessarily correspond to the number of lines in the file.
  • LLOC: The number of logical lines of code. Every logical line of code contains exactly one statement.
  • SLOC: The number of source lines of code - not necessarily corresponding to the LLOC.

To generate the metrics, use the following commands from the radon library:

python -m radon raw . -s -O stats.md
python -m radon mi . -s -j -O mi.json
python -m radon cc . -s --show-closures --total-average --md -O complexity.md

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.