Object Oriented Design Patterns - Creational Patterns IMPORTANT NOTICE TO STUDENTS: These slides are NOT to be used as a replacement for student notes. These slides are sometimes vague and incomplete on purpose to spark class discussions. Object Oriented Design Patterns - Creational Patterns CS 360 Lecture 6
Have you ever written code and got the feeling you’ve solved that problem before? Chances are you probably have! Write down your solution and refer to it when needed. This is the idea of a design pattern. Design Pattern: The re-usable form of a software solution. Optimized using good programming practices.
Object Oriented Design Patterns Gang of Four (GoF) Book Most cited OO Design pattern book
Design Pattern Categories Design Patterns Creational Ways to create objects Behavioral How objects interact with each other Structural How classes and objects are structured
Design Pattern Categories
Creational Design Patterns Goal of Creational Design Patterns: Abstract the instantiation process. Helps make the system independent of how its objects are created, composed, and represented.
Creational Design Patterns - Singleton Intent Ensure a class only has one instance, and provide a global point of access to it. Consequences Controlled access to a single instance of a class. The class then may provide access to other resources Reduced name space (reduced number of global variables)
Creational Design Patterns - Singleton
Creational Design Patterns - Prototype Intent Specify the kinds of objects to create using a prototypical instance. Then create new objects by copying this prototype instance. Consequences Allows new objects by varying attributes Allows new object by varying structure Must implement the Clone operation
Creational Design Patterns - Prototype
Creational Design Patterns - Factory Intent Define an interface for creating an object. Let subclasses decide which class to instantiate. Consequences Defers instantiation of objects to subclasses. Parent classes do not need to be concrete classes.
Project Group Activity Search online content for Creational Design Patterns implemented using languages for your project. Singleton Prototype Factory
Web Development ACM SIG Meeting today 4pm IEB Room 301