Dealing with duplicated code
We’ve all seen it: we’re working along, and we come across code that just has a feel to it. It’s like déjà vu. You’ve seen this code before. You open another file – sure enough, there it is. The same code. Almost line for line.
In large code bases, it’s likely that there are dozens if not hundreds of similar behaviors that have to be completed more than once. And as code grows, is worked on by multiple developers, or just for the sake of speed, the same code gets copied or rewritten over and over again in different places.
Making better object oriented design decisions
Last week I finished up the first section of The Object Oriented PHP Masterclass. The class was great, and I learned about as much from my students as they learned from me. One of the most common questions I got from my students was “how do I make decisions about how to design my object oriented applications?” This question got me thinking about object oriented design.
The syntax of object oriented PHP is relatively straightforward…
Avoiding object oriented overkill
In the second live session of my object oriented design class, The Object Oriented PHP Masterclass, I show my students domain modeling, both with slides and with a live coding demonstration.
In my demonstration, I show them how I break the single model they’ve been using into three component parts: a value object, a data layer object (usually that talks to the database), and a gateway object that stands between the other two.
Does your code keep you drowning in technical debt?
All of us would prefer to work on code that we love. And all of us are faced with code code that we feel…well, not so warm and fuzzy about. Its the nature of our business.
Legacy code is everywhere. From code that’s just been around a long time to code that was rushed to completion years and years ago and never fixed, we all have to deal with things that are imperfect and challenging to deal with.
Making Your App Infintely More Testable
You’re writing a PHP application. You know you need to write tests. Tests aren’t something that comes naturally to you yet; you’re still working on learning the ins and outs of PHPUnit (the default standard framework). But you know that right now, your app isn’t testable. What can you do to make it testable?
The single most important thing you can do to make your app testable
Abstraction In The Real World
Abstraction is one of the subjects in software development that’s really difficult to fully grasp without practice. It’s easy to read about it, talk about it, and profess doing it. To actually do it is another thing entirely: it requires practice, and patience, and experimentation.
I decided the best way to show abstraction in action is by showing the commits I made as I worked to abstract a model that contained the validation and database logic inside the same class. You can see my progress, as well as my notes about what I’m doing as I go along below.
Object oriented programming always leaves you with a headache. What if you could master it instead? Stop struggling with object oriented PHP. Mastering Object Oriented PHP is the answer!
Imagine if you could write clear, compelling code each and every time you sat down to work. You can do this. I'll show you how with The Ten Commandments of Clean Code.
Brandon Savage has been a software developer since 2003. Ever since discovering that he could use software to automate routine tasks, he's been hooked. Brandon is passionate about perfecting the art of software development.