diff --git a/README.md b/README.md index 6d637eac..f69d8567 100644 --- a/README.md +++ b/README.md @@ -13,52 +13,54 @@ __Creational Patterns__: | Pattern | Description | |:-------:| ----------- | -| [abstract_factory](abstract_factory.py) | use a generic function with specific factories | -| [borg](borg.py) | a singleton with shared-state among instances | -| [builder](builder.py) | instead of using multiple constructors, builder object receives parameters and returns constructed objects | -| [factory_method](factory_method.py) | delegate a specialized function/method to create instances | -| [lazy_evaluation](lazy_evaluation.py) | lazily-evaluated property pattern in Python | -| [pool](pool.py) | preinstantiate and maintain a group of instances of the same type | -| [prototype](prototype.py) | use a factory and clones of a prototype for new instances (if instantiation is expensive) | +| [abstract_factory](creational/abstract_factory.py) | use a generic function with specific factories | +| [borg](creational/borg.py) | a singleton with shared-state among instances | +| [builder](creational/builder.py) | instead of using multiple constructors, builder object receives parameters and returns constructed objects | +| [factory_method](creational/factory_method.py) | delegate a specialized function/method to create instances | +| [lazy_evaluation](creational/lazy_evaluation.py) | lazily-evaluated property pattern in Python | +| [pool](creational/pool.py) | preinstantiate and maintain a group of instances of the same type | +| [prototype](creational/prototype.py) | use a factory and clones of a prototype for new instances (if instantiation is expensive) | __Structural Patterns__: | Pattern | Description | |:-------:| ----------- | -| [3-tier](3-tier.py) | data<->business logic<->presentation separation (strict relationships) | -| [adapter](adapter.py) | adapt one interface to another using a white-list | -| [bridge](bridge.py) | a client-provider middleman to soften interface changes | -| [composite](composite.py) | encapsulate and provide access to a number of different objects | -| [decorator](decorator.py) | wrap functionality with other functionality in order to affect outputs | -| [facade](facade.py) | use one class as an API to a number of others | -| [flyweight](flyweight.py) | transparently reuse existing instances of objects with similar/identical state | -| [front_controller](front_controller.py) | single handler requests coming to the application | -| [mvc](mvc.py) | model<->view<->controller (non-strict relationships) | -| [proxy](proxy.py) | an object funnels operations to something else | +| [3-tier](structural/3-tier.py) | data<->business logic<->presentation separation (strict relationships) | +| [adapter](structural/adapter.py) | adapt one interface to another using a white-list | +| [bridge](structural/bridge.py) | a client-provider middleman to soften interface changes | +| [composite](structural/composite.py) | encapsulate and provide access to a number of different objects | +| [decorator](structural/decorator.py) | wrap functionality with other functionality in order to affect outputs | +| [facade](structural/facade.py) | use one class as an API to a number of others | +| [flyweight](structural/flyweight.py) | transparently reuse existing instances of objects with similar/identical state | +| [front_controller](structural/front_controller.py) | single handler requests coming to the application | +| [mvc](structural/mvc.py) | model<->view<->controller (non-strict relationships) | +| [proxy](structural/proxy.py) | an object funnels operations to something else | __Behavioral Patterns__: | Pattern | Description | |:-------:| ----------- | -| [chain](chain.py) | apply a chain of successive handlers to try and process the data | -| [catalog](catalog.py) | general methods will call different specialized methods based on construction parameter | -| [chaining_method](chaining_method.py) | continue callback next object method | -| [command](command.py) | bundle a command and arguments to call later | -| [mediator](mediator.py) | an object that knows how to connect other objects and act as a proxy | -| [memento](memento.py) | generate an opaque token that can be used to go back to a previous state | -| [observer](observer.py) | provide a callback for notification of events/changes to data | -| [publish_subscribe](publish_subscribe.py) | a source syndicates events/data to 0+ registered listeners | -| [registry](registry.py) | keep track of all subclasses of a given class | -| [specification](specification.py) | business rules can be recombined by chaining the business rules together using boolean logic | -| [state](state.py) | logic is organized into a discrete number of potential states and the next state that can be transitioned to | -| [strategy](strategy.py) | selectable operations over the same data | -| [template](template.py) | an object imposes a structure but takes pluggable components | -| [visitor](visitor.py) | invoke a callback for all items of a collection | +| [chain](behavioral/chain.py) | apply a chain of successive handlers to try and process the data | +| [catalog](behavioral/catalog.py) | general methods will call different specialized methods based on construction parameter | +| [chaining_method](behavioral/chaining_method.py) | continue callback next object method | +| [command](behavioral/command.py) | bundle a command and arguments to call later | +| [iterator](behavioral/iterator.py) | traverse a container and access the container's elements | +| [mediator](behavioral/mediator.py) | an object that knows how to connect other objects and act as a proxy | +| [memento](behavioral/memento.py) | generate an opaque token that can be used to go back to a previous state | +| [observer](behavioral/observer.py) | provide a callback for notification of events/changes to data | +| [publish_subscribe](behavioral/publish_subscribe.py) | a source syndicates events/data to 0+ registered listeners | +| [registry](behavioral/registry.py) | keep track of all subclasses of a given class | +| [specification](behavioral/specification.py) | business rules can be recombined by chaining the business rules together using boolean logic | +| [state](behavioral/state.py) | logic is organized into a discrete number of potential states and the next state that can be transitioned to | +| [strategy](behavioral/strategy.py) | selectable operations over the same data | +| [template](behavioral/template.py) | an object imposes a structure but takes pluggable components | +| [visitor](behavioral/visitor.py) | invoke a callback for all items of a collection | __Others__: | Pattern | Description | |:-------:| ----------- | -| [blackboard](blackboard.py) | (architectural model, assemble different sub-system knowledge to build a solution, AI approach - non gang of four pattern) | -| [graph_search](graph_search.py) | (graphing algorithms, not design patterns) | +| [blackboard](other/blackboard.py) | architectural model, assemble different sub-system knowledge to build a solution, AI approach - non gang of four pattern | +| [graph_search](other/graph_search.py) | graphing algorithms - non gang of four pattern | +| [hsm](other/hsm/hsm.py) | hierarchical state machine - non gang of four pattern | diff --git a/behavioral/__init__.py b/behavioral/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/catalog.py b/behavioral/catalog.py similarity index 100% rename from catalog.py rename to behavioral/catalog.py diff --git a/chain.py b/behavioral/chain.py similarity index 100% rename from chain.py rename to behavioral/chain.py diff --git a/chaining_method.py b/behavioral/chaining_method.py similarity index 100% rename from chaining_method.py rename to behavioral/chaining_method.py diff --git a/command.py b/behavioral/command.py similarity index 100% rename from command.py rename to behavioral/command.py diff --git a/iterator.py b/behavioral/iterator.py similarity index 100% rename from iterator.py rename to behavioral/iterator.py diff --git a/mediator.py b/behavioral/mediator.py similarity index 100% rename from mediator.py rename to behavioral/mediator.py diff --git a/memento.py b/behavioral/memento.py similarity index 100% rename from memento.py rename to behavioral/memento.py diff --git a/observer.py b/behavioral/observer.py similarity index 100% rename from observer.py rename to behavioral/observer.py diff --git a/publish_subscribe.py b/behavioral/publish_subscribe.py similarity index 100% rename from publish_subscribe.py rename to behavioral/publish_subscribe.py diff --git a/registry.py b/behavioral/registry.py similarity index 100% rename from registry.py rename to behavioral/registry.py diff --git a/specification.py b/behavioral/specification.py similarity index 100% rename from specification.py rename to behavioral/specification.py diff --git a/state.py b/behavioral/state.py similarity index 100% rename from state.py rename to behavioral/state.py diff --git a/strategy.py b/behavioral/strategy.py similarity index 100% rename from strategy.py rename to behavioral/strategy.py diff --git a/template.py b/behavioral/template.py similarity index 100% rename from template.py rename to behavioral/template.py diff --git a/test_command.py b/behavioral/test_command.py similarity index 100% rename from test_command.py rename to behavioral/test_command.py diff --git a/test_observer.py b/behavioral/test_observer.py similarity index 100% rename from test_observer.py rename to behavioral/test_observer.py diff --git a/test_publish_subscribe.py b/behavioral/test_publish_subscribe.py similarity index 100% rename from test_publish_subscribe.py rename to behavioral/test_publish_subscribe.py diff --git a/test_state.py b/behavioral/test_state.py similarity index 100% rename from test_state.py rename to behavioral/test_state.py diff --git a/test_strategy.py b/behavioral/test_strategy.py similarity index 100% rename from test_strategy.py rename to behavioral/test_strategy.py diff --git a/visitor.py b/behavioral/visitor.py similarity index 100% rename from visitor.py rename to behavioral/visitor.py diff --git a/creational/__init__.py b/creational/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/abstract_factory.py b/creational/abstract_factory.py similarity index 100% rename from abstract_factory.py rename to creational/abstract_factory.py diff --git a/borg.py b/creational/borg.py similarity index 100% rename from borg.py rename to creational/borg.py diff --git a/builder.py b/creational/builder.py similarity index 100% rename from builder.py rename to creational/builder.py diff --git a/factory_method.py b/creational/factory_method.py similarity index 100% rename from factory_method.py rename to creational/factory_method.py diff --git a/lazy_evaluation.py b/creational/lazy_evaluation.py similarity index 100% rename from lazy_evaluation.py rename to creational/lazy_evaluation.py diff --git a/pool.py b/creational/pool.py similarity index 100% rename from pool.py rename to creational/pool.py diff --git a/prototype.py b/creational/prototype.py similarity index 100% rename from prototype.py rename to creational/prototype.py diff --git a/test_abstract_factory.py b/creational/test_abstract_factory.py similarity index 100% rename from test_abstract_factory.py rename to creational/test_abstract_factory.py diff --git a/test_borg.py b/creational/test_borg.py similarity index 100% rename from test_borg.py rename to creational/test_borg.py diff --git a/fundamental/__init__.py b/fundamental/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/delegation_pattern.py b/fundamental/delegation_pattern.py similarity index 100% rename from delegation_pattern.py rename to fundamental/delegation_pattern.py diff --git a/other/__init__.py b/other/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/blackboard.py b/other/blackboard.py similarity index 100% rename from blackboard.py rename to other/blackboard.py diff --git a/graph_search.py b/other/graph_search.py similarity index 100% rename from graph_search.py rename to other/graph_search.py diff --git a/other/hsm/__init__.py b/other/hsm/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/classes_hsm.png b/other/hsm/classes_hsm.png similarity index 100% rename from classes_hsm.png rename to other/hsm/classes_hsm.png diff --git a/classes_test_hsm.png b/other/hsm/classes_test_hsm.png similarity index 100% rename from classes_test_hsm.png rename to other/hsm/classes_test_hsm.png diff --git a/hsm.py b/other/hsm/hsm.py similarity index 98% rename from hsm.py rename to other/hsm/hsm.py index 13c5a657..e40d88c4 100644 --- a/hsm.py +++ b/other/hsm/hsm.py @@ -1,5 +1,5 @@ """ -Implementation of the HSM (hierachrical state machine) or +Implementation of the HSM (hierarchical state machine) or NFSM (nested finite state machine) C++ example from http://www.eventhelix.com/RealtimeMantra/HierarchicalStateMachine.htm#.VwqLVEL950w in Python diff --git a/test_hsm.py b/other/hsm/test_hsm.py similarity index 100% rename from test_hsm.py rename to other/hsm/test_hsm.py diff --git a/3-tier.py b/structural/3-tier.py similarity index 100% rename from 3-tier.py rename to structural/3-tier.py diff --git a/structural/__init__.py b/structural/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/adapter.py b/structural/adapter.py similarity index 100% rename from adapter.py rename to structural/adapter.py diff --git a/bridge.py b/structural/bridge.py similarity index 100% rename from bridge.py rename to structural/bridge.py diff --git a/composite.py b/structural/composite.py similarity index 100% rename from composite.py rename to structural/composite.py diff --git a/decorator.py b/structural/decorator.py similarity index 100% rename from decorator.py rename to structural/decorator.py diff --git a/facade.py b/structural/facade.py similarity index 100% rename from facade.py rename to structural/facade.py diff --git a/flyweight.py b/structural/flyweight.py similarity index 100% rename from flyweight.py rename to structural/flyweight.py diff --git a/front_controller.py b/structural/front_controller.py similarity index 100% rename from front_controller.py rename to structural/front_controller.py diff --git a/mvc.py b/structural/mvc.py similarity index 100% rename from mvc.py rename to structural/mvc.py diff --git a/proxy.py b/structural/proxy.py similarity index 100% rename from proxy.py rename to structural/proxy.py diff --git a/test_adapter.py b/structural/test_adapter.py similarity index 100% rename from test_adapter.py rename to structural/test_adapter.py diff --git a/test_bridge.py b/structural/test_bridge.py similarity index 100% rename from test_bridge.py rename to structural/test_bridge.py diff --git a/test_flyweight.py b/structural/test_flyweight.py similarity index 100% rename from test_flyweight.py rename to structural/test_flyweight.py diff --git a/test_proxy.py b/structural/test_proxy.py old mode 100755 new mode 100644 similarity index 100% rename from test_proxy.py rename to structural/test_proxy.py