Week8 DesignPatterns Singleton
Week8 DesignPatterns Singleton
Week 8
Software Engineering
Wk Lecture Practical
1 Introduction Canvas, Assessment Understand the case
Software lifecycle study.
Write the user stories.
2 Work as a group! Agile
Design the database and
Plan the work on Review of the software
the software
the UI and the requirements and design
Set the version control
Use Case Review of the OOP concepts.
diagram.
3 User Stories Git
4 Plan the work on Graphical User Interface. MVC Coding
the user stories pattern. Retrospective
Check if you are on
5 Plan the work on Create and connect the database
track.
the database to the application.
6 Plan the current From UML to C# code
task
7 Plan the current Testing – Manual and Automated
task
8-9 Retrospective. Design patterns More coding.
Plan the current Accomplish the quality.
task. Secure coding.
10 Software Validation and Double check.
Verification No new features.
Enhancements.
11 Software Maintenance.
Learning Outcomes
Different designs.
Alexander, C., Ishikawa, S., Silverstein, M. & co., A Pattern Language, 1977
Design Patterns
A few examples….
Problem
Products
Gamma, E., Helm, R., Johnson, R., Vlissides, J.,Design Patterns, Elements of Reusable Object-Oriented Software, ISBN 0201633612
Let’s have a look at another set of similar examples…
Problem
Car Factory
A car factory builds three types of car:
small
luxury
saloon
The manufacturer (Ford, BMW) decides what components
go in each car.
Problem
Documents
Résumé, report, journal paper are types of document.
They contain different sections such as: introduction,
skills, education, experience, results, conclusion,
summary, etc.
Problem
The problems above define an interface for creating an object, but let
subclasses decide which class to instantiate. Factory Method lets a
class defer instantiation to subclasses.
If we know how to solve one of them then the same mechanism should
be applied to the other ones.
Gamma, E., Helm, R., Johnson, R., Vlissides, J.,Design Patterns, Elements of Reusable Object-Oriented Software, ISBN 0201633612
Design Patterns
Logger classes
See:
https://msdn.microsoft.com/en-us/library/microsoft.build.utilities.logger
.aspx
Problem
Database
Definition:
Gamma, E., Helm, R., Johnson, R., Vlissides, J.,Design Patterns, Elements of Reusable Object-Oriented Software, ISBN 0201633612
Singleton Design Pattern
Usage:
Implementation:
Private constructor - to restrict instantiation of the
class from other classes.
Private static variable of the same class - is the only
instance of the class.
Public static method - returns the instance of the
class. It’s the global access point for outer world to get the
instance of the singleton class.
Singleton Design Pattern
Gamma, E., Helm, R., Johnson, R., Vlissides, J.,Design Patterns, Elements of Reusable Object-Oriented Software, ISBN 0201633612
Observer Design Pattern
Singleton
• defines an Instance()
method that lets the other
application’s components
access its unique
instance. Instance() is a
class method (static).
• responsible for
creating and maintaining
its own unique instance.
http://www.dofactory.com/net/singleton-design-pattern
Singleton Design Pattern
Example:
SingletonDesignPattern project.
Reading List
http://www.dofactory.com/net/design-patterns
Questions