UML model and code examples of design patterns for Python. The model is created with Astah.
Model and code examples of GoF Design Patterns for Python.
This project is available for the following objectives:
UML model example:
Python code example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ˅
from structural_patterns.composite.file_system_element import FileSystemElement
# ˄
class File(FileSystemElement):
# ˅
# ˄
def __init__(self, name, size):
self.__name = name
self.__size = size
# ˅
super().__init__()
# ˄
def get_name(self):
# ˅
return self.__name
# ˄
def get_size(self):
# ˅
return self.__size
# ˄
# Print this element with the "upper_path".
def print(self, upper_path):
# ˅
print(upper_path + '/' + self.to_string())
# ˄
# ˅
# ˄
# ˅
# ˄
UML Modeling Tool
Python Development Environment
Code Generation from UML
Run (if you use PyCharm)
main.py
for the pattern you want to run, and click Run
icon in the left gutter.
This project is licensed under the Creative Commons Zero (CC0) license. The model and code are completely free to use.
C++, C#, Crystal, Go, Java, JavaScript, Kotlin, Ruby, Scala, Swift, TypeScript