Skip to content

Instantly share code, notes, and snippets.

View ErikPohl-Lot49-Projects's full-sized avatar
🎯
Focusing

Erik Pohl ErikPohl-Lot49-Projects

🎯
Focusing
  • Boston
View GitHub Profile
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / sets.py
Last active January 3, 2019 20:05
Python Set Examples
'''
Created on Dec 31, 2018
@author: Erik Pohl
'''
# make two lists
print("make two lists")
y = [1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5]
z = [5,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10]
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / Interpreter.py
Last active December 13, 2018 14:04
Interpreter Design Pattern
'''
Created on Dec 11, 2018
@author: Erik Pohl
'''
'''
cake := frosting | layer | filling
layer := strawberry cake | chocolate cake | vanilla cake
frosting := coconut icing | cream cheese icing | fudge icing
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / flyweight.py
Last active December 12, 2018 01:59
Flyweight Design Pattern
'''
Created on Dec 11, 2018
@author: Erik Pohl
'''
"""
With the flyweight, a factor method uses a shared pool to create large numbers of fine-grained objects
efficiently in memory
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / factory_method.py
Created December 11, 2018 20:16
Factory Method Design Pattern
'''
Created on Dec 10, 2018
@author: Erik Pohl
'''
"""
Define an object creation interface
, and let subclasses decide
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / Composite.py
Last active December 11, 2018 18:49
Composite Design Pattern
'''
Created on Dec 11, 2018
@author: Erik Pohl
'''
"""
The composite creates a recursive tree structure of
leaf and composite components.
Each type of component is treated uniformly
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / Adapter.py
Created December 11, 2018 17:43
Adapter Design Pattern
'''
Created on Dec 11, 2018
@author: Erik Pohl
'''
"""
Adapter changes the interface of a class into the interface a client expects.
Adapter adapts the interface so that classes can work together which otherwise
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / Strategy.py
Last active December 11, 2018 17:41
Strategy Design Pattern
'''
Created on Dec 11, 2018
@author: Erik Pohl
'''
"""
Create algorithm classes using encapsulation and make their handles
interchangeable. The Strategy Design Pattern lets the client class
-- the Context -- leverage a common handle to address
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / Observer.py
Last active December 11, 2018 04:46
Observer Design Pattern
'''
Created on Dec 10, 2018
@author: Erik Pohl
'''
"""
The subject object has a one to many dependency on the observers
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / visitor.py
Last active December 11, 2018 04:40
Visitor Design Pattern
'''
Created on Dec 10, 2018
@author: Erik Pohl
'''
"""
An abstract class represents an action to perform on another class.
The visitor class visits the element and the behavior changes
of the element class without changing the class itself.
@ErikPohl-Lot49-Projects
ErikPohl-Lot49-Projects / template.py
Created December 10, 2018 19:32
Template Design Pattern
'''
Created on Dec 10, 2018
@author: Erik Pohl
'''
"""
The template design pattern defines a generalized
algorithm, asking the subclasses to fill in some