PHP OOP Way
PHP OOP Way
About the Book
What Is This Book About
Chapter 1 covers the fundamentals of the object-oriented programming: encapsulation, inheritance, and polymorphism. We will discuss the purpose of abstraction and inheritance, and why you should avoid using inheritance for code reuse. This chapter also covers such language specific features as traits and closures and their role in the object-oriented code. And at the end of the chapter, I will introduce such a powerful tool as Dependency Injection, different types of it and some code smells of its wrong usage.
Chapter 2 is fully devoted to SOLID principles. We will discuss each of them: the main idea behind the principle, how to apply it to your code and some problems that you can face following these principles blindly.
Chapter 3 is an introduction to an object-oriented design. It covers the well knows design principles such as:
- Tell, don't ask
- The Law of Demeter
- YAGNI
- Kiss
- Dry
This chapter also covers some basic anti-patterns that you can meet in the code with poor design.
Chapter 4 opens the topic of the design patterns and composition. We will discuss the difference between inheritance and composition and when each of them is more appropriate to use. This chapter covers such design patterns as State, Strategy, Adapter and their comparison with the inheritance approach.
Chapter 5 describes the problem "I don't have the interface that I want." . We will cover situations when we need to make two incompatible interfaces work together and how to reduce the complexity of the subsystem and hide it behind the friendly interface.
Chapter 6 is about GRASP principles and Responsibility Driven Design. It is often a challenge to choose the right object for a particular job and to decide how the objects should interact with each other. Correct responsibility assignments are the key to a good object oriented design.
Who Is This Book For
This is not a beginner's guide to OOP PHP. We are not going to cover the syntax of classes or the difference between public, protected and private keywords. I assume that you are already familiar with these things.
I assume that you are familiar with the language itself and have been using it in an object-oriented way for several years. The number of years does not matter. You can have a year of personal study and mastered the art of programming or ten years of maintaining the same application. Anyway, you know the basic concepts of the object-oriented programming, such as encapsulation, inheritance and polymorphism. Likely you have used a few of the modern MVC frameworks and even have studied their source code to go deeper.
The book is for you if you have left the basics behind some years ago and now feel free in writing complex OOP code. But you always feel that you don't fully understand why things should be in this way, and not differently. Maybe you know what every letter means in the SOLID acronym but have been always curious why strictly following these principles sometimes makes your application even worse than it was before.
Bundles that include this book
Table of Contents
- Introduction
-
Fundamentals
- Bundle Properties With Methods
- Define A New Type
- Families Of Related Types
- Different Types With The Same Behavior
- Interface vs Abstract Class
- Traits: Copy-Paste Behavior
- Making Polymorph
- Dependency Injection
- Closure
-
SOLID Principles
- Singile Responsibility Principle
- Open/Closed Principle
- Three Rules to Respect Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
- Rules Are Made To Be Broken
-
Object-Oriented Design
- Tell Don’t Ask
- The Principle of Least Knowledge
- YAGNI
- KISS Your Application
- Don’t Repeat Yourself
- Antipattern: God Object
- Antipattern: Poltergeist
- Singleton: Anti-Pattern Or Not
-
Favor Composition Over Inheritance
- The Decision Between Inheritance And Composition
- Replace Conditionals With Composition And Polymorphism
- More Composition
- When To Factory
- Does Static Factory Violate Open-Closed Principle
-
Changing Interface
- Change Incompatible Interface With Adapter
- Reduce Complexity With Facade
-
GRASP Principles
- Creator
- Information Expert
- Low Coupling
- High Cohesion
- Controller
- Polymorphism
- Indirection
- Protected Variations
- Pure Fabrication
- Conclusion
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them