Great programmers and great chefs
A great chef can take the most basic ingredients and turn them into a lovely dish. A bad chef can take lobsters, mix them with nectarines and produce a horrorful dish. You have also chefs that make too complex food (e.g. using too many ingredients) or chefs that are dirty and don't create presentable food, but are really good at mixing flavours together.
Some of the properties of great chefs:
While watching Ramsey's Kitchen Nightmares I have found out that the chef analogy can be applied to programmers as well. Programmers take some ingredients (languages, tools, libraries) and produce a dish (a product). Some examples:
This analogy can be seen in some popular software projects:
I have looked at a lot of code in different languages and I know good code when I see it. When I look at my own code I see great functionality and simplification, but it's missing the last presentation touch and sometimes I am keen on doing it hacky style. To become better I have looked at what other great programmers are doing and here is what I have concluded:
The good codeI really like how Django is coded (I don't personally use Django). Looking through their code you'll notice cleanness, structure, comments and really good code smell. The bad codeWick is auto completion for JavaScript. The functionality is good, but their code and code smell is something taken from a programming horror movie. One of the functions look like this: function smartInputMatch(cleanValue, value) {
this.cleanValue = cleanValue;
this.value = value;
this.isSelected = false;
}//smartInputMatch
Another function looks like this: function registerSmartInputListeners() {
inputs = document.getElementsByTagName("input");
texts = document.getElementsByTagName("textarea");
allinputs = new Array();
z = 0;
y = 0;
while(inputs[z]) {
allinputs[z] = inputs[z];
z++;
}//
while(texts[y]) {
allinputs[z] = texts[y];
z++;
y++;
}//
Global scope is totally polluted and only global variables are used. Here is a clean rewrite (like in design, white space can do wonders to the code): function registerSmartInputListeners() {
var inputs = document.getElementsByTagName("input");
var texts = document.getElementsByTagName("textarea");
allinputs = [];
var z = 0, y = 0;
while(inputs[z]) {
allinputs[z] = inputs[z];
z++;
}
while(texts[y]) {
allinputs[z] = texts[y];
z++;
y++;
}
}
This can be done even better by using proper ingredients: function registerSmartInputListeners() {
allinputs = flattenList(
$bytc('input', 'wickEnabled'),
$bytc('textarea', 'wickEnabled')
);
}
flattenList, $bytc (by tag and class) are from AJS. Final wordsI have looked through my code and I can clearly see what I need to improve to become a better chef - and who knows, maybe a great chef one day :) 3 comments so far
Post a comment
Commenting on this post has expired.
|
Blog labels |