Skip to content

Commit c71e9a2

Browse files
committed
Corrected description of Factory Method pattern.
1 parent f851891 commit c71e9a2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

creational/factory_method.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
"""
5-
*What is this pattern about?
4+
"""*What is this pattern about?
65
The Factory Method pattern can be used to create an interface for a
76
method, leaving the implementation to the class that gets
87
instantiated.
@@ -11,22 +10,24 @@
1110
The code shows a way to localize words in two languages: English and
1211
Greek. "getLocalizer" is the factory method that constructs a
1312
localizer depending on the language chosen. The localizer object will
14-
instantiate a different class according to the language of that
15-
localized, but the main code does not have to worry about which
13+
be an instance from a different class according to the language
14+
localized. However, the main code does not have to worry about which
1615
localizer will be instantiated, since the method "get" will be called
1716
in the same way independently of the language.
1817
1918
*Where can the pattern be used practically?
2019
The Factory Method can be seen in the popular web framework Django:
21-
http://django.wikispaces.asu.edu/*NEW*+Django+Design+Patterns
22-
For example, in a contact form, the subject and the message fields are
23-
created using the same form factory (CharField()), even though they
24-
will have different implementations according to their purposes.
20+
http://django.wikispaces.asu.edu/*NEW*+Django+Design+Patterns For
21+
example, in a contact form of a web page, the subject and the message
22+
fields are created using the same form factory (CharField()), even
23+
though they have different implementations according to their
24+
purposes.
2525
2626
*References:
2727
http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/
2828
https://fkromer.github.io/python-pattern-references/design/#factory-method
2929
https://sourcemaking.com/design_patterns/factory_method
30+
3031
"""
3132

3233

0 commit comments

Comments
 (0)