1 / 38100%
Implementing Design Patterns with Python Assignment Grading Rubric
Criteria
Levels of Achievement
Advanced
Proficient
Developing
Not present
Selecting a pattern to be used in an
application or software task.
14 to 15 points
Pattern selected fits well in the
selected application.
11 to 13 points
Pattern selected will work in
selected application but does not fit
well and/or serve a beneficial
purpose
1 to 10 points
Pattern and application do not
fit well. For example, a
Mediator pattern makes little
sense in a single class
application.
0 points
Pattern and/or
application not
selected.
Singleton pattern integrated into a
previous assignment ensures that
there is only one instance of the
class in the application.
14 to 15 points
Code correctly implements the
Singleton pattern including just-in-
time initialization
11 to 13 points
Code correctly implements the
Singleton pattern but not just-in-
time initialization
1 to 10 points
Code implementing the
Singleton pattern is partially
correct
0 points
No implementation
Original application still functions
correctly after Singleton integration
14 to 15 points
No loss in functionality
11 to 13 points
No loss in functionality but usage
has new requirements
1 to 10 points
Some loss of functionality
0 points
No implementation
Documentation source code is
well documented
5 points
Functions, variables, code blocks,
etc., are well documented.
Variable names follow industry
convention. Improper call syntax
results in a usage message back to
the user.
4 points
Modest but correct comments,
generally consistent and correct in
variable/function naming
1 to 3 points
Inaccurate and sparse
comments. Naming
conventions generally
inconsistent.
0 points
No comments
CSIS 354 Design Patterns Rev. B
Page 1 of 2
IMPLEMENTING DESIGN PATTERNS WITH PYTHON
Software Design Patterns may be thought of as blue prints or recipes for implementing common
models in software. Much like re-using proven classes in Object Oriented design, re-using
proven patterns tends to produce more secure and reliable results often in reduced time compared
to re-inventing the wheel. In fact, some high-level languages have integrated facilities to support
many common patterns with only minimal, if any, user written software. That said, in software
design and construction, often the challenge is to know that a pattern exists and be able to
recognize when it is a good fit for a project. To give you a familiar frame of reference, below is a
Singleton Pattern implemented in Java:
public class MySingleton {
// reference to class instance
private static MySingleton instance = null;
// Private Constructor
private MySingleton() {
instance = this;
}
// Returns single instance to class
public static MySingleton getInstance() {
if (instance == null) {
instance = new MySingleton();
}
return instance;
}
public static void main(String[] args)
{
MySingleton s1 = MySingleton.getInstance();
MySingleton s2 = MySingleton.getInstance();
System.out.println("s1: " + s1 + " s2: " + s2);
}
}
If you run this example, you will see that the address for s1 and s2 are exactly the same. That is
because the pattern restricts the existence of more than one instance in a process. Of course this
example only implements the pattern but other functionality can be added to this class just as any
other class. The primary features of a singleton are:
1. Private or restricted constructor
2. Internal variable for holding reference to single instance
3. Static method for retrieving the instance
The primary goal of this assignment is not to teach you how to write singleton patterns in
Python, (though that’s part of it), but to familiarize you with the concept of design patterns as
well as give you experience in adapting one into one of your own designs.
Description
CSIS 354 Design Patterns Rev. B
Page 2 of 2
1. Using an Internet Search Engine, search for common software design patterns. There are
many good resources such as https://en.wikipedia.org/wiki/Software_design_pattern.
Describe, in your own words, how one of these patterns could be used in an application
or software task. You are expected to write professionally, with proper grammar and
spelling, but you are not required to adhere to a specific format or cite any sources.
2. Pick one of your previous assignments, either from MindTap or one of your Distributed
Systems assignments and integrate a Singleton Pattern into it. Hint: Any class can be
made into a Singleton.
Test your code completely. At each step of the test take a screen shot and
embed it into a Word document. At the completion of the test compress (ZIP)
the Word document and your code into one ZIP file. Submit the ZIP file to the
appropriate assignment.
Submit your Python source files and Design Pattern document by 11:59 p.m. (ET) on Friday of
Module/Week 8.
Es
Administrator:
Command
Prompt
-
python
job.py
-
a
Welcome
to
the
Bible:
To
use
this
app
please
supply
book name
and
the
vers
els
Book
Nmae
:John
ar
211
=]
-:
\Windows
\PASS>python
job
-
py
xx
as
chapter
to
exit
Book
Name:John
Chapter
Number:1
a
Enter
End
Verse:1
http:
//labs.bible.org/api/?passage=John+1:1-1&type=json
<Response
[200]>
ale)
se
ee
In
the
beginning
was
the
Word,
and
the
Word
was
with
God,
and
the
Word
was
fully
‘eere
Welcome
to
the
Bible:
To
use
this
app
please
supply
book name
and
the
ver
ele
Book Nmae
:John
Enter
xx
as
chapter
to
exit
Enter
Book
Name:
Ee
Administrator:
Command
Prompt
-
python
job.py
-
a
Thapter
:11
tt
o:
3
nter
xx
as
chapter
to
exit
T=
eee
ae
nter
Chapter
Number:1
nter
Verse:1
nter
End
Verse:1
ittp:
//
labs.
bible.org/api/?passage=John+1:
1-1&type=json
“Response
[200]>
Welcome
to
the
Bible:
o
use
this
app
please
supply
book
name
and
the
verse
ele
fore)
a
ee
ea
nae
xx
as
chapter
to
exit
Book
Name:Genesis
Chapter
Number
:1
Verse:1
er
End
Verse:2
ittp:
//
labs.
bible.org/api/?passage=Genes1s5+1:1-2&type=json
<Response
[200]>
a
ginning
God
created
the
heavens
and
the
earth.
senesis:1:2
Vow
the
earth
was
without
shape
and empty, and
darkness
was
over
the
surface
of
he
watery
deep,
but
the Spirit
of
God
was
moving
over
the
surface
of
the
water.
Welcome
to
the
Bible:
o
use
this
app
please
supply
book name
and
the
ver
cele
tele
a
ee
ela
xx
as
chapter
to
exit
Book
Name:
Administrator:
Command
Prompt
-
python
job.py
ER
eee
uae
[tn
the
beginning
God
created
the
heavens
and
the
earth.
Se
se
eee
ec
eect
oe
ae
hats
Peat
Ete
ona
supply
book name
and
the
vers:
oe
eee
eC
ec
Ree
Ce
Eee
ae
Nee
wel
ee
eee
eset
ae
a
eas
Es
Administrator:
Command
Prompt
-
Enter
Verse:1
w
:
Se
eee
ae
nia
eee
ee’
<Response
[200]>
Genesis:1:1
|
he
beginning
God
created
the
heavens
and
the
earth.
Genesis:1:2
Now the
earth
was
without
shape
and empty, and
darkness
was
over
the
surface
of
he
watery
deep,
but
the Spirit
of
God
was
moving
over
the
surface
of
the
water.
Welcome
to
the
Bible:
To
use
this
app
please
supply
book name
and
the
ver
eal
ne
sook
Nmae
:John
xx
as
chapter
to
exit
Book
Name:
John
Chapter
Number
:5
Verse:1
End
Verse:2
»:
//labs.bible.org/api/?passage=John+5
:1-2&type=json
2)
ae
eee
s
went
up
to
Jerusalem.
ae
eee
Now
there
1s in
Jerusalem
by
the
Sheep
Gate
a
pool
called
Bethzatha
in
Aramaic,
which
has
five
covered
walkways.
Welcome
to
the
Bible:
To
use
this
app
please
supply
book name
and
the
ver
eee
Book Nmae
:John
Chapter
:11
Verse:
3
To:
3
Enter
xx
as
chapter
to
exit
Enter
Book
Name:xx
mPa
atalt
(eA
ie
Installing
Please
wait
while
Erlang
OTP
241s
being
installed.
Nulsoft
Install
System
v3.05
Installing
Please
wait
while
Erlang
OTP
241s
being
installed.
\Windows
Firewall
has
blocked
some
features
of
el.exe
on
all
pubic
and
private
networks,
(eee
Ea
Path:
‘Ci\progran
fles\er-24.0\bin\erLexe
Allow
erl.exe
to
communicate
on
these
networks:
Private
networks,
such
as
my
home
or
werk
network
[Public
networks,
suchas
those
in
aports
and
coffee
shops
(not
recommended
Nulsoft
In
because
these
networks
often
have
ite
or
no
security)
What
are
the
risks
of
allowing an
app
through
firewall?
Oe
ak
Name:
Publisher:
Unknown
Path:
c:\program
fes\erl-24.0\erts-12.0\bin\epmd.exe
‘Allow
epmd.exe
to
communicate
on
these
networks:
Private
networks,
such
as
my
home
or
work
network
[Public
networks,
such
as
those
in
airports
and
coffee
shops
(not
recommended
Nuleo
n
because
these
netuerks
often
have
lite or
no
security)
What
are
the
risks
of
allowing
an
app
through
a
frewal?
=
=o
>
Gaim
&
>i
Editor
-
C:\Windows\PASS\send.py
|
temp.py
a
Administrator:
Command
Prompt
-
python
receive.py
send.py
dient.py
server.py
receive.py
oe
Oper
rio
RC
ee
oe
ae
RC
ee
oe
ae
Ds
ZO
GROFF
WH
S=EZED
EBX
£2
Editor
-
C:\Windows\PASS\send.py
GQ)
temp.py
a
Administrator:
Command
Prompt
-
python
receive.py
send.py
dient.py
server.py
receive.py
ara
ee
oe
cate
ee
oe
cate
ee
oe
cate
[SSDP
BK
Fe
Spyder
(Python
3.5)
-4
CC:\Windows\PASS
8X
Heb
ax
4%
Source|Console
|
Object
va
&
a
ro]
Administrator:
Command
Prompt
-
python
send.py
ane
Pay
a
qare-an-scnool
[6]
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]
Kernel
died,
restarting
Python
console
History
log
End-of-lines:
CRLF
Encoding:
ASCIT
Line:
42
Column:
13
Memory:
68
%
Spyder
(Python
3.5)
-4
Permissions:
RW
CC:\Windows\PASS
vil
®
3
x|
heb
ax
Source
[Console
~|
Object
via
&
5 5
wi
Administrator:
Command
Prompt
-
python
send.py
°
OBB
ewww
yp
aes
qare-an-scnool
[6]
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]'
Kernel
died,
restarting
Python
console
End-of-lines:
CRLF
History
log
Permissions:
RW.
Encoding:
ASCII
Line:
42
Column:
13
Memory:
68%
=o
>
Gaim
&
>i
Editor
-
C:\Windows\PASS\send.py
|
temp.py
a
Administrator:
Command
Prompt
-
python
receive.py
send.py
dient.py
server.py
receive.py
Soe
ai
tera
Cee)
eae
ae
he
Me
eeu
eee
he
Me
eeu
eee
he
Me
eeu
eee
ee
a
a
ee
eer
Ds
ZO
GROFF
WH
S=EZED
EBX
£2
Editor
-
C:\Windows\PASS\send.py
GQ)
temp.py
a
Administrator:
Command
Prompt
-
python
receive.py
send.py
dient.py
server.py
receive.py
Ree
Lers
Un
eae
rata
a
ee
eee
eat
a
ee
eee
eat
a
ee
eee
eat
Ce
a
Ee
eet
ang
eae)
cy
oat
cry
cry
cry
cry
cry
cry
Spyder
(Python
3.5)
-4
[SSDP
BK
Fe
CC:\Windows\PASS
BX)
Help
ax
&
Source
Console
|
Object
Administrator:
Command
Prompt
-
python
send.py
ay
a
eed
qare-an-scnool
[6]
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]
Kernel
died,
restarting
Python
console
History
log
Permissions:
RW
__End-of-lines:
CRLF
__Encoding:
ASCIT
Line:
42
Column:
13
Memory:
68
%
Spyder
(Python
3.5)
-4
et
et
vil
®
BX
Hep
ax
vi
am
CC:\Windows\PASS
&
Source
Console
|
Object
Administrator:
Command
Prompt
-
python
send.py
OBB
ewww
yp
qare-an-scnool
[6]
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]'
Kernel
died,
restarting
Python
console
End-of-lines:
CRLF
History
log
Permissions:
RW.
Encoding:
ASCII
Line:
42
Column:
13
Memory:
68%
=o
>
Gaim
&
>i
Editor
-C:\Windows\PASS\send.py
Q
temp.py
Ae
send.py
dient.py
server.py
receive.py
Administrator:
Command
Prompt
-
python
receive.py
Soe
ai
tera
b'Learning
ae
Cate
oo
Pam
asi)
Dea
U
Cate
a
Pam
asi)
Dea
U
Cate
a
Pam
asi)
Dea
U
Cate
a
Cerny
eeu
eaten)
Cerny
ees
b'Learning
python
most
fantastic
moment
of
ZO
GROFF
WH
S=EZED
EBX
£2
Editor
-C:\Windows\PASS\send.py
Q
temp.py
send.py
dient.py
server.py
receive.py
Administrator:
Command
Prompt
-
python
receive.py
Kes
ed
eet
eet
eet
en
eee
ae
Ce
eae
en
eee
ae
Tae
eet
Cee
ee
ee
eee
Spyder
(Python
3.5)
-4
cans
cry
cry
cry
cans
cans
ch
aa
[SSDP
BK
Fe
CC:\Windows\PASS
BX)
Help
ax
&
Source
Console
|
Object
Administrator:
Command
Prompt
-
python
send.py
°
OBB
ewww
yp
ae
qare-an-scnool
[6]
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]
Kernel
died,
restarting
Python
console
History
log
Permissions:
RW
__End-of-lines:
CRLF
__Encoding:
ASCIT
Line:
42
Column:
13
Memory:
68
%
Spyder
(Python
3.5)
-4
cry
cry
cry
cry
Cae
Cae
Cae
cry
cry
CC:\Windows\PASS
vil
®
BX
Hep
ax
vi
am
&
Source
Console
|
Object
Administrator:
Command
Prompt
-
python
send.py
°
TTY
aie
OBB
ewww
yp
es
qare-an-scnool
[6]
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]'
Kernel
died,
restarting
Python
console
End-of-lines:
CRLF
History
log
Permissions:
RW.
Encoding:
ASCII
Line:
42
Column:
13
Memory:
68%
=o
>
Gaim
&
>i
Editor
-C:\Windows\PASS\send.py
Q
temp.py
Ae
dient.py
server.py
es
Preeti
ty
ae
ae
ae
ae
ae
ey
ae
ae
2o
pam
F
Ic
Editor
-C:\Windows\PASS\send.py
Q
temp.py
Ee
Ee
Ee
Ee
Ee
Pe
Ee
De
dient.py
server.py
ae
ae
ae
ae
ae
ae
ae
ae
ae
Ee
Ee
Ee
Ee
Ee
Ee
Ee
Ee
De
receive.py
pr
cs
ar
ar
ar
ar
ar
the
ar
ar
receive.py
pr
car
ar
ar
ar
ar
ar
ar
ar
ar
ar
Administrator:
Command
Prompt
-
python
ce
ce
ce
ce
ce
ce
ce
ce
fe
ce
ce
ce
ce
ce
ce
ce
ce
ce
send.py
eka
era
Pacer
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
ace
atee
fantastic
n
fantastic
n
send.py
eka
era
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
fantastic
n
receive.py
cea
Tae
Tae
Tae
eae
ca
Sa
Tae
Tae
Administrator:
Command
Prompt
-
python
receive.py
cea
ca
cea
Tae
Tae
Tae
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
cry
Spyder
(Python
3.5)
[SSDP
BK
Fe
Permissions:
RW
Spyder
(Python
3.5)
et
et
et
=SS=npG
BX
Fe
Permissions:
RW
OBB
ewww
yp
OBB
ewww
yp
OBB
Bow
ww yD
BEBEEBEBE
e
Windows
PASS
vie
a
BX
Help
Bx
4
Source|Console
~]
Object
va
Pes
Administrator:
Command
Prompt
-
python
send.py
°
on
send.
py
qare-an-scnool
[6]
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
[x]
Received
b'
Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]*
Kernel
died,
restarting
In
y
Python
console
History
log
End-oflines:
CRLF
Encoding:
ASCIL
Line:
12
Column:
13
Memone_
68%
-
a
C:\Windows
PASS
vi
BX
Help
Bx
He
Source
Console
|
Object
vee
a
Administrator:
Command
Prompt
-
python
send.py
°
AG
qare-an-scnool
[6]
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[7]*
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[3]"
[x]
Received
b'Learning
python
is
the
most
fantastic moment
of
ma
life
in
school
[9]'
Kernel
died,
restarting
Python
console
History
log
End-of-lines:
CRLF
Encoding:
ASCIT
Line:
12
Column:
13
Memory:
68%
cs
Administrator:
Command
Prompt
-
python
job.py
-
Welcome
to
the
Bible:
To
use
this
app
please
supply
book
name
and
the
ver
elt
Book
Nmae
:John
SPAN
MDL
RN
em
Te
aed
5
xx
as
chapter
to
exit
Book
Name:
John
Chapter
Number
:2
Verse:l
tte
eeee
Now
on
the
third
day
there
was
a
wedding
at
Cana
in
Galil
0
here,
and his
disciples
were
also
invited
to
the
wedding.
ale)
see:
When
the
wine
ran
out,
Jesus’
mother
said
to
him,
“They
have
no
wine
left.”
Welcome
to
the
Bible:
To
use
this
app
please
supply
book
name
and
the
ver
ele
Book
Nmae
:John
Enter
xx
as
chapter
to
exit
AM
ae
tele
a
fee
eet
ae
fee
eet
ae
Administrator:
Command
Prompt
-
python
job.py
0
invited
to
the
wedding.
eA
k
name
and
the
SR
een
emer
a
Administrator:
Command
Prompt
-
python
job.py
eee
Reet
th
eter
eem
ane)
ae
UR
or
eee
Roe
cet
as
Poet
Gee
Re
UR
eT
Cee
rT
ma
Cue
Cae
7
Sa
Coa
Space)
ene
Ey
eee
Saat
Pore
Students also viewed