Posts tagged rant

Construction in Programming – Convention over Configuration

0

Tonight I was putting up an additional shelf in my closet and I didn’t have all the screws and wall anchors I need due to breaking some of the anchors. Thankfully, construction workers and engineers thrive off of convention over configuration! All I had to do is find the approximate size wall anchor in my toolbox.

Do you realize how annoying and unproductive it would be if every time during a construction project (whether a shelf or a house), construction workers had to cast all their own screws, bolts, joints, etc. No! They build from convention. They build with tools and parts that align to common specs and this allows them great customization.

So, why do programmers often say “we don’t have time” or “[convention over configuration] works in an ideal world”?! If programmers were construction workers, they’d be fired and construction would take even longer (think about that scary idea).

Convention over configuration isn’t a “nice to have.” It is paramount to us being productive, efficient, and effective developers. We should take the lesson and be Program Workers.

Construct away!

Popularity: 13% [?]

Parsing Algorithms – Creational Patterns

0

This is as much a recommendation as a rant, so pardon me while I do both :)

Situation
Open-source project or foundational classes for use within your organization that contains methods for parsing data.

Background
Often, I’ve run into issues where I am using an open-source library (public or private) and I need to add extra logic to a creational algorithm(s) and cannot or cannot easily do so. This is what has sparked me to write this post, because I am increasingly seeing these types of issues.

Recommendation
When creating algorithms that create objects from other objects (eg models and serialization) , please use offload the logic to accessible and easily modifiable methods. In Design Pattern terms, I’m requesting and ranting that the Factory Method Pattern, Strategy Pattern, or something similar be used. This only compounds in importance when there are several objects created in a single method!  <– That right there is arguably bad practice in general for large projects.

Example
NOTE: Showing a simple example seems to not show the problem, but I’ll try. For a better example, please refer to “Real-Life Example” below.

Mapping XML properties to models within a project.

protected updateList():void
{
var header:Header = new Header;
header.title = _xml.header.@title;
header.lang = _xml.header.@lang;
header.colors = _xml.header.colors.toArray();

var body:Body = _body;
var child:XML;
for (var i:Number = 0; i < _xml.body.item.length(); ++i)
{
child = _xml.body.item[i];
body.getItemAt(i).text = child.@text;
}
}


Real-Life Example
NOTE: I do not mean to pick on or criticize the fine work done by the peeps working on the OpenVideoPlayer Project and MUST EMPHASIZE that the project is very useful and saves time. This merely serves as an easy example to show. Moreover, I’ve written my fair share of problematic code along these lines too.

Popularity: 10% [?]

Go to Top