Skip to content

Commit

Permalink
Minor changes in creational patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
0--key committed Jan 20, 2017
1 parent 918aebd commit d8af8a6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions creational/borg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __str__(self):
class YourBorg(Borg):
pass


if __name__ == '__main__':
rm1 = Borg()
rm2 = Borg()
Expand Down
2 changes: 2 additions & 0 deletions creational/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def build_size(self):
raise NotImplementedError

# Concrete Builder


class BuilderHouse(Builder):

def build_floor(self):
Expand Down
1 change: 1 addition & 0 deletions creational/factory_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def get_localizer(language="English"):
languages = dict(English=EnglishGetter, Greek=GreekGetter)
return languages[language]()


# Create our localizers
e, g = get_localizer(language="English"), get_localizer(language="Greek")
# Localize some text
Expand Down
2 changes: 2 additions & 0 deletions creational/lazy_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


class lazy_property(object):

def __init__(self, function):
self.function = function
functools.update_wrapper(self, function)
Expand All @@ -37,6 +38,7 @@ def __get__(self, obj, type_):


class Person(object):

def __init__(self, name, occupation):
self.name = name
self.occupation = occupation
Expand Down
4 changes: 3 additions & 1 deletion creational/pool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""http://stackoverflow.com/questions/1514120/python-implementation-of-the-object-pool-design-pattern"""
"""
http://stackoverflow.com/questions/1514120/python-implementation-of-the-object-pool-design-pattern
"""


class QueueObject():
Expand Down
1 change: 1 addition & 0 deletions creational/prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def main():
dispatcher.register_object('default', d)
print([{n: p.value} for n, p in dispatcher.get_objects().items()])


if __name__ == '__main__':
main()

Expand Down

0 comments on commit d8af8a6

Please sign in to comment.