- In the beginning of this one, we only have two files.…One file, output.php, with the behaviors we're using…and the index.php, which calls them.…Unfortunately, to get at the behaviors,…we have to call each one individually with its own name.…Even worse, if we need to add additional behaviors,…we have to modify the output class to add them…or extend the class, add our custom behaviors,…and now maintain both classes.…The strategy base solution is quite a bit different…but simpler in a number of ways.…Now we create individual classes…that implement the behavior we want.…
Then we pass them into the class at runtime…and deal with the output in a single way.…We need to add more behaviors.…We don't need to modify the existing classes.…We just add additional classes.…In this case, our Square, Cube…and Fourth classes do all the work.…We just call them individually by the identical interfaces.…A nice side effect of this is that we get to re-use…these behaviors all over the place with very little effort.…At first glance, this may seem quite similar…
Author
Released
1/28/2015- Accessing data with the active record and table data gateway patterns
- Creating objects with the factory, singleton, and mock objects patterns
- Extending code with decorator and adapter patterns
- Structuring applications with MVC and Action-Domain-Responder patterns
Each chapter features a design pattern in a real-world coding scenario, and closes with a practice challenge to test your new skills.
Skill Level Intermediate
Duration
Views
Related Courses
-
PHP: Creating Secure Websites (2014)
with Kevin Skoglund4h 15m Intermediate -
PHP: Accessing Databases with PDO and MySQLi
with David Powers3h 47m Intermediate
-
Introduction
-
Welcome51s
-
-
1. The Active Record Pattern
-
2. The Adapter Pattern
-
3. The Decorator Pattern
-
4. The Factory Pattern
-
5. Mock Objects
-
Introducing mock objects2m 18s
-
-
6. The Model-View-Controller Pattern
-
7. The Action-Domain-Response Pattern
-
8. The Publish/Subscriber Pattern
-
9. The Singleton Pattern
-
10. The Strategy Pattern
-
11. The Table Data Gateway Pattern
-
Conclusion
-
Next steps2m 8s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Exploring a use case for the strategy pattern