2009
08.14

I received a project written by another coder who was sacked which contained some pretty good examples on how NOT to write a web page.

Example #1:

This is the pseudo-code representation of the PHP code I received:

query('SELECT * FROM users');
foreach user:
->if (user.username == my_username):
-->if (user.password == my_password):
--># Do some other checks...
--># User is allowed to log in:
-->break;

Why not use this code? Because it is inefficient! Let the database do the filtering of usernames and then run your checks.

Example #2:

Edit page of an item. The edit form comes from a PHP script. The previous values for the form fields are filled in how? With AJAX of course! Why bother with default values for the form fields? AJAX is so much cooler!

But seriously, who does crap like that? It’s just wrong on so many levels. AJAX has it’s uses, but this certainly isn’t one of them.

Example #3:

We need to create a web page with a sidepanel with 3 tabs. How do we do it? Of course we write the main page first. Then we add the code for the first tab of the side panel.

Now comes the tricky part: We copy paste the page and sidepanel code, modify the sidepanel so that it becomes tab number 2 and add some if statements around those copy pasted sections. And then we repeat it for 3rd tab.

Conclusion

Schools don’t teach students anything. Don’t go to school to learn basic IT, grab a book and dive into open source code!

Ok, I might be wrong with the last statement, as I really don’t know what is being taught in universities on a programming related course, but I sure am disappointed in the quality of code the graduates write.

No Comment.

Add Your Comment