Lesson 1 of 45 · Tools, Not Rules
Introduction - Tools, Not Rules
The trap this course could fall into
You're about to read 44 more lessons, each one introducing a pattern, a principle, or a habit. It would be very easy to read them as a list of things to do. "Use value objects. Apply Tell, Don't Ask. Always inject dependencies. Write tests this way."
If you take that reading, this course will hurt your codebases. You'll arrive on Monday morning with a checklist, you'll start applying things to projects that didn't ask for them, and you'll end up exactly in the over-engineering trap.
So before any of the actual content lands, this opening lesson sets the posture. None of what's coming next is a rule. All of it is a tool.
Why this course exists
Foundations was the why. It gave you vocabulary for what makes code rot, what makes it last, and how to think about the trade-offs. It deliberately didn't tell you what to do.
Some "advanced PHP" content jumps straight into specific patterns or specific architectures without helping you decide when to use them. I've seen repositories wrapped in factories wrapped in interfaces, all for a CRUD admin tool that has twelve users. Somebody read about the patterns, applied them honestly, and the team is now paying the cost forever.
Patterns and Principles is the bridge. Each chapter introduces tools you can pick up, look at, try, and put back down. Some of them will fit your current project. Others won't. That's normal. The skill is knowing the difference. The course is opinionated about which patterns are worth your attention and doesn't try to be a complete catalog.
Tools, not rules
The distinction matters enough to spell out:
A rule says "always do this". It doesn't ask about your context. It doesn't ask about your team size, your product age, or your change rate. It assumes one right answer for all situations.
A tool says "use this when X". It comes with conditions. It earns its place when the situation calls for it, and it stays in the box when it doesn't. It doesn't pretend to be the right answer everywhere.
Software engineering has a lot of rules disguised as tools, and a lot of tools disguised as rules. Mistaking one for the other gets expensive in a long-lived codebase.
Every honest answer in software starts with "it depends". This course is what "it depends" looks like in practice. Each tool comes with a story about when it depends in its favor, and when it doesn't.
What's in this course
A quick map of where you're going. Each chapter is a category of tool:
Small objects. Primitive obsession, DTOs, value objects, named constructors, immutables. The simplest tools in the box, with the highest payoff per unit of effort.
Object design principles. Tell Don't Ask, Law of Demeter, composition over inheritance, anemic vs rich models, SOLID, guard clauses. Tools for shaping how objects behave and how they talk to each other.
Wiring things together. Dependency injection, factories, repositories, Active Record vs Data Mapper, service patterns. Tools for assembling the system out of its parts honestly.
Behavior and variation. Decorator, strategy, specification, null object, domain events, singleton (and why to avoid it). Tools for handling change without modification.
Commands and queries. Command-query separation, commands and their handlers, queries and their handlers, separate models for reads and writes. Tools for giving every use case and every screen its own entry point.
Commands, queries and events on a bus. The command bus, the query bus and the event bus. Tools for putting one dispatcher between the callers and the handlers, so a concern that wraps every call lives in one place.
Persistence, flow and state. Unit of Work and Identity Map, pipelines, the State pattern, builders. Tools for saving changes together, running steps in order, and keeping status rules in one place.
Failure and validation. Exceptions as design, domain vs framework exceptions, result objects, validation placement. Tools for handling the parts of software where things go wrong.
Testing as a discipline. Test doubles, TDD, BDD, mutation testing, refactoring. Tools for keeping the rest of the toolkit honest.
Putting it together. A capstone where the tools meet a real codebase and not all of them get used. Watching what gets picked, what gets dropped, and why.
The tools come from different places. Decorator, Strategy and Singleton are patterns from the Gang of Four book, test-driven development comes from Extreme Programming, and value objects come from Domain-Driven Design. What matters here is whether the tool earns its place.
How to read this course
A few practical instructions, because the reading style matters:
Don't apply everything to your current project. If you do, you'll be deep into a refactor that nobody asked for, and your colleagues will be unhappy. The codebase has the shape it has for reasons. Some of those reasons are good and some are bad. Telling them apart takes more than reading 45 lessons.
Pick one tool that addresses pain you have today. If your controllers are full of inline string keys, read the chapter on small objects and try value objects in one feature. If your tests are slow because they need a database for everything, read the testing chapter and try fakes in one place. The point is to use the tools where the pain meets them, not where the lesson schedule sends them.
Keep the tools that earn their place; drop the ones that don't. Some patterns will feel like they fit your codebase the moment you try them. Others will feel awkward, and the awkwardness is information. If a pattern needs five wrappers and three explanations to fit, it isn't fitting. Trust that signal.
Some lessons will feel academic. A lesson on the Specification Pattern in isolation can feel like an answer to a question nobody asked. The day you're trying to express a complicated business rule that keeps slipping out of your code, the lesson will click. This material lands the second time, not the first.
An honest disclaimer up front
Patterns often look elegant in small examples and awkward in real code. The textbook decorator is a pleasure. The decorator wrapping the third-party SDK in a Laravel project, with two flavors of caching and a metric collector, is a different animal.
This course will try to be honest about that. Where a pattern hurts in practice, or the framework already provides something close and rebuilding it would be over-engineering, the lesson will say so.
The goal is to make you good at recognizing which pattern to reach for, which one not to, and how to tell the difference.
The two failure modes you'll avoid
If you read this course as tools rather than rules, two failure modes get much less likely:
"I read about it so I'll use it." This is over-engineering and premature abstraction wearing a course-completion badge. The pattern is fresh in your head, the codebase has nothing pushing for it, and you apply it anyway because it feels professional. The cost lands on whoever maintains the code next.
"I don't see the point." The opposite trap. You skim the lesson, the example feels small or contrived, and you decide the tool isn't useful. Then you're hand-coding a worse version of the same thing because you didn't recognize the problem the tool was for.
Both traps come from treating patterns as fashion, which is "in or out", when tools are "right for this job or wrong for this job".
The one thing to remember
Every chapter that follows is a box of tools. You don't have to use all of them, and you probably shouldn't. The point is to know what's in the box, so when a problem in front of you fits one of them, you can reach for it without inventing it from scratch.
If at any point in the next 44 lessons something feels like a commandment, that's a reading mistake. Push back on it and ask "in what context?" and "what's the smaller version of this tool that would work in my situation?". Those questions are the toolkit. The patterns are just specific instances.
Related Links
- YagniMartin Fowler on the Extreme Programming principle behind not building something before the situation calls for it.
- CodeSmellFowler's definition of a code smell as a signal to investigate, not a rule to apply automatically.
- Design PatternsAn index of the classic design pattern catalog, several of which this course revisits as tools rather than defaults.