Three engineers were standing around chatting at a children’s birthday party. The host approached them and asked, “can you help me hang this piñata somewhere in the house for the children to hit?” The engineers agreed, and set off to figure out the best approach to the problem.
The most junior engineer was young and unsure of himself. He looked around for obvious items that could hang the piñata, and after rejecting several as unsuitable, he proposed that the engineers simply place the piñata on a table, so the children could break it open and access the candy inside. The host didn’t like this suggestion very much; while it met the goal, it failed to meet the scope.
Occasionally folks will ask me, “what does it take for me to earn more money as a freelancer?” They want to know if I have a magic bullet, or if I’ve learned anything through my travels in the business world. The truth is that there’s only one thing you can do to increase your revenues as a freelancer, and it’s this:
Provide more business value for the client.
When returning large amounts of data, it can be common to turn to a built-in PHP data structure: the array. But in object-oriented code, arrays make poor object-to-object data transfer mechanisms. Object-oriented programming is and should be focused on objects. That means that each array should be converted into an object, and collections too.
The reason is simple: when one object makes a request to another object, it should generally get back an object unless the response is scalar. For example, asking for a data set from the database ought to generate an object, not an associative array of data.
It’s a pretty common pattern: instead of listing all the dependencies, you simply pass in the service locator, and look up the dependencies you need at runtime. Many frameworks (coughSymfonycough) advocate this model, but it has some serious drawbacks. So many, in fact, that I have a general rule of thumb for controllers:
Service locators don’t belong inside controllers. Period.
As programmers, we don’t really make anything. Oh sure, we write code, design applications, and create open source libraries. Yet we so willingly refactor away our hard work, delete and close down apps, and at the end of the day, really have little tangible outcome from the work that we do. Unlike a furniture maker or a home builder, we don’t have something we can touch and say, “I made that.”
Looking back through my career, precious little of the code I’ve written remains in production. This isn’t uncommon: for most developers, refactoring is a normal part of the job, and the HEAD branch tends to forget us if we’re not actively contributing.
I currently have a few projects wrapping up and I’m available to take on new projects, both large and small in the PHP development world.
With more than ten years of experience as a PHP developer, I can help you to develop your project efficiently, effectively and with the best possible outcomes. I’ve worked on projects large and small, with big data and high uptime requirements. Do you want to have a great outcome on your next project? Then we should work together!