099 – Keys to Enjoy Web Programming
In this week’s episode, Sean and Randy from beAutomated.com and I chat about the keys to enjoy web programming.
In order to be a successful programmer, you will have to enjoy your work, break it down into manageable pieces and write it so others can read it. Listen to the show to learn more!
Here is the outline we discussed:
The way to enjoy programming is to work in bite sized chunks of code, code that provides a single service.
– The inspiration for this came about from working on a large non WordPress project, where we were tasked with making patches to an unfamiliar system with half a million lines of code.
– Working with large programs means working with many developers. Each developer has their own style. The lack of standards creates bloat, confusion, and eventually bad security, performance, interoperability, and UX.
– Think of architecture as an analogy. Building a custom home is fun. Building a skyscraper makes even the tiniest of decisions highly complex.
WP Plugins allow us to concentrate a single service tied to the core API.
– All you need to know is the data model of the website, how to talk to the core, and the feature you are building.
– You do not need to know the inner workings of the WordPress infrastructure, nor the inner workings of any other Plugin or Theme, when you build this way.
– Developers often ?nd themselves dealing with a spaghetti mess of code.
– How do you remember thousands of lines of code that produces a result, especially among dozens of projects?
Earlier on, the key to keeping code scalable was the use of objects, and object oriented programming techniques.
– For example, you would create classes of functions and variables and store them in appropriately named ?les. For example: ?class.students.php? or ?class.teachers.php?.
Object oriented programming led into standardized frameworks and model-viewcontroller frameworks.
– Frameworks provide a stock set of objects, for example: ?users?. Frameworks separate the code that produces data, design, and structure. Web publishing platforms such as WordPress, take this concept even further by providing an inherent set of documented, supported objects, user interfaces, and community contributed bundles of design and functional packages.
WordPress provides what you might call master objects.
– For example, entities that log in; instead of thinking about many objects like ?students? and ?teachers?, you think about ?users?, user role/capability assignments, and ?usermeta?.
– Another example, entities that produce content; instead of thinking about ?schools?, ?departments?, ?programs?, and ?classes?, you think about ?posts?, post types, and ?postmeta?.
– Final example; instead of thinking about con?gurations, session variables, and caching, think ?options? particularly with the settings API, and ?transients?.
– All of these are documented and heavily used WordPress Plugin APIs.
We always preach about the need to keep design/layout/style code within themes or child themes, and any functional/logical code within Plugins.
– A new concept we like to put out there is keeping Plugins sized to these bite sized chunks because each Plugin becomes a unit test to work on, something that can be enabled/disabled, plugged-in and plugged-out, packaged and distributed among sites accordingly.
Often times marketing trumps the practice of keeping themes and Plugins simple, because packaging software features exposes more to the market.
– It?s preferable to help users manage their limited resources within their websites.
– A future concept of parent/child Plugins (think JetPack or EditFlow) may standardize this architecture further.
Developers prefer managing modules that they can easily comprehend the purpose and structure of, especially as multiple developers get involved.
– We always have best practices to follow to make everyone?s job more enjoyable.
– We have WordPress and Plugins to thank for this new way of thinking, and enjoying development projects.