design_patterns
design_patterns
From:
https://www.tonymarston.net/php-mysql/model-view-controller-01.png
MVC: What’s happening inside?
MVC: A Solution in Java
Code for this example can be found here:
https://www.tutorialspoint.com/design_pattern/
mvc_pattern.htm
Dependency in Object Oriented
Programming
Problem:
• Using the new operator inside the first class can create an
instance of a second class that cannot be used nor tested
independently. This is called a “hard dependency”.
http://best-practice-software-
engineering.ifs.tuwien.ac.at/patterns/
dependency_injection.html
Dependency Injection Pattern Exercise
https://www.tutorialspoint.com/design_pattern/
factory_pattern.htm
We can easily create new subclasses of Shape
and use the ShapeFactory to instantiate them
without changing the rest of the code.
Factory Pattern: Another Example
For implementation of the Document Example,
see:
http://stg-tud.github.io/eise/WS15-SE-18-
Factory_Method_and_Abstract_Factory_Design_
Pattern.pdf