More Design Patterns!

Composite - The whole is a sum of it's parts!
	Main idea - add a structural layer to polymorphism
	Polymorphism - provides a common interface for different objects
	Composite Design Patter - add a layer to govern how these objects relate to each other (provide a common structural interface as well as a functional interface)

	Why? We want to be able to treat/interact with basic components the same way as more complex components


	Example - Modifying Paint to accommodate composite shapes (Car and Snowman)


	- Make interface Component with one method - draw(GraphicsContext g2d)

	- Edit Shape to implement component (automatically ensuring all the concrete shapes will implement Component as well)

	- Make composite class which implements Component

	- Make a car and snowman component

	- Add buttons to ShapeChooser

	- Edit PaintPanel switch case in handle to make a new car and snowman

	- Change PaintPanel s attribute Shape->Component, and the for loop in update

	- Change PaintModel shapes attribute Shape->Component


Builder - simplify your constructor!

	Main idea: organize customizable parameters that are needed to instantiate a new object into a separate class as a means to simplify the constructor call (and make it more modular)

	PPT example: Ordering a burrito from the Burrito Boys website - that constructor is long!

	Worked Java example: making a pizza!
		- Allow the customer completely customize a pizza from scratch (PizzaBuilder)
		- Or...subclass the builder to give the user some pre-made options (Deluxe, Hawaiian)


Visitor - How to react when you come a-knocking!

	Idea: To structure your code to allow different types of objects to perform customizable actions when they interact/visit various objects

	Context on slides:
		When a Maid(Visitor) visits your house (Element), their action within your house as a MaidVisitor will be different when a Neighbour(Visitor) visits your house. Same element being visited, but the actions being performed by each visitor are different, 

	Coded Java example: Element is a Tree, and we have preOrder and postOrder visitors. 

	Homework: implement levelOrder visitor


SOLID - why we care so much about design patterns
	
	Who's making up these rules? 
	Why are these design patters are the way they are?

	There is a set of guiding principles that, if all followed, the resulting application is bound to be modular, flexible, scalable, and easily maintainable. 

	All of these design patterns directly relate back to, these 5 principles.

	See slides for the 5 principles

