The Lazier, The More Modular Programmer

Might not be totally true but here’s my hypothesis: “Lazy programmers tend to code in a more modular way and do more automation.”

snapshot407I do like SQL. But don’t like to write it. So, i decided to write a class for adding/deleting/updating from database.

$sets['fname'] = 'John';
$sets['sname'] = 'Smith';
$where['sex'] = 'm';
$where['country'] = 'USA';

$db->update('users',$sets,$where);

equivalent to

UPDATE users SET fname = 'John',sname = 'Smith' WHERE sex = 'm' AND country = 'USA';

Another example of automation is when i want a clean setup of a website i’m working on. I just go on phpMyAdmin. I drop the database. The next time the engine of the website is triggered, it checks if database exists, creates it if not, runs an install script which will recreate the tables.

$db_selected = mysql_select_db($dbsettings['dbname'],$con);
if (!$db_selected) {
___mysql_query("CREATE DATABASE {$dbsettings['dbname']}",$con);
___$db_selected = mysql_select_db($dbsettings['dbname'],$con);
___// If an installer exists, we try to run it.
___if(file_exists(ROOTDIR.'inc/install.php')){
______header('Location: '.ROOTURL.'inc/install.php');
___}
}

This laziness pushed me to write a templating system in PHP for my university Web assignment so as my HTML and PHP codings are separate.

$recipes = $Recipes->get_multiple("ORDER BY timeposted DESC");
$recipelist = "";
foreach($recipes as $recipe)
_eval("\$recipelist .= \"". $templates->simple_get("gallery_recipe") ."\";");
eval("\$contents = \"".$templates->get_page("gallery_page")."\";");
eval("\$headerincludes = \"".$headerincludes."\";");
$templates->output_page($contents);

If i would been a “hard working” guy. I wouldn’t have bothered to do these extra simple things. I would have enough energy to write 100 update queries manually. Have long html codes inside PHP loops and so on..

What do you think?

Wisdom for Idiots

My theory: Wisdom at the hands of an idiot is twice as much as dangerous to a casual idiot.

I’m responsible for what I say, not for what you understand

This is in reference to the “wise quotes” people usually share on Facebook. Do you really think people /teens especially have become more mature with those wise quotes? I don’t think knives can be used as toys for any age group; neither can guns nor nuclear bombs..

// I may be an idiot too but I am afraid when others play with guns.

24Hrs vs Rs 50 Million gov.mu Website

Recently WebCup organized a competition to make a website in 24 hours. Have a look at the websites a team of 4 people had to do in 24hrs only!

  • Ceridian – http://ceridian.webcup.mu
  • Chesteroc – http://chesteroc.webcup.mu
  • Esokia – http://esokia.webcup.mu
  • Extension Interactive – http://extension-interactive.webcup.mu
  • FRCI – http://frci.webcup.mu
  • Elite Business School – http://elite-business-school.webcup.mu
  • Paperboat – http://paperboat.webcup.mu
  • TNT – http://tnt.webcup.mu
  • Team Urban Error – http://urban-error.webcup.mu
  • Wanderers – http://wanderers.webcup.mu
  • Web Thugs – http://web-thugs.webcup.mu
50 Millions government Website
50 Millions government Website

 

Now compare those to our dear 50 Million Government Website: gov.mu. If such websites can be made in 24Hrs, why did the gov.mu cost Rs 50 Million? Food for thought….

When bus “sonnet” doesn’t work

Recently, a bus had a break failure killing 10 people and the Prime Minister didn’t give a ****. I’m gonna raise another issue of public transportation we face daily i.e. the Bus Bell fails.

How people deal with it:-

1. Most youngsters usually walk to the door while the bus is still running. The driver stops at the next bus stop.

2. Some try to press the button and release it suddenly so as it makes a noise. The conductor sometimes notices it and alerts the driver.

3. Older people shout and usually add some “spicy” words towards the driver. (zourer mama) 😀

Actions to be taken:-
Policeman could periodically stop a bus so as to check if the bells are working. Wouldn’t this rather be the responsibility of the NTA (National Transport Authority) or where fitness is given etc? I don’t know these things much but checking bus bells are an important thing.

Source
Source
Source
Source

If fitness is given to NTC buses which can have break failures, then i guess we’re doomed to have crappy service at all levels. Why do we need a transport Minister? Just to agree to request because bus owners have been requesting a raise for a long time?

“The price of transport is being increased because the owners of the bus companies have been asking for an increase in the transport fees from quite a long time”. Source

No, Seriously!? Is that all you’re worth?