Join Jon Peck for an in-depth discussion in this video Identifying the singleton pattern, part of Object-Oriented Programming with PHP.
- View Offline
- Exercise Files
In this chapter, I'm going to explore a couple of different kinds of design…patterns that I've used throughout this course.…A design pattern is a reusable coding solution to common problems.…There are dozens of patterns available to solve all sorts of problems.…But in the interest of keeping this focused on object-oriented programming, I'm…just going to discuss three of them.…At the end of the course, I'll give you some resources where you can learn more…about design patterns if you'd like.…The first pattern I'd like to discuss is the Singleton pattern, which restricts…instantiation of a class to one object.…
This way, action can be coordinated throughout the application, and resources can…be intentionally limited.…I used the Singleton pattern for the database to ensure that only one connection…can occur at a time.…Let's look at the database class now.…Note the use of the static property instance to store the singular database…connection instance in the database class.…Another common use of the Singleton pattern is lazy initialization, where…
- Historical overview of object-oriented PHP
- Defining classes
- Creating a method/object context with $this
- Accessing classes without instantiation
- Creating a database class
- Extending and abstracting classes
- Cloning and comparing objects
- Error handling with exceptions
- Implementing design patterns, such as the factory and strategy patterns
Skill Level Intermediate
PHP with MySQL Beyond the Basicswith Kevin Skoglund10h 26m Intermediate
1. Introduction to Object-Oriented Programming
2. Creating Your First Object
3. Overloading with Magic Methods
Overloading property access6m 37s
4. Accessing Classes without Instantiation
5. Class Relationships and Interactions
6. Built-In PHP Objects
Customizing PHP exceptions4m 23s
7. Design Patterns
- 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.Cancel
Take 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.