What My Programming Course Taught Me

For the past term I have been taking a specialized course in which the teacher was kind enough to combine a course called programming A and another one called database management. The idea was to use PHP together with MySQL to put together various assignments. After solving a couple of assignments I started out working on the main project, a webshop with basic features. With one week to go I think that I have learnt several things from the course so far:

Object-oriented Programming Really Saves You Time

First thing I did was to put together a full-fledged database class that allowed me to focus more on the main application than the functions related to MySQL. I started out simple with two main methods:

// Query() - Send a basic SQL-query to the database and retrieve the result.
print_r($DB->Query('SELECT post_title FROM wp_posts LIMIT 0, 2'));

The result is an associative array:

Array
(
    [0] => Array
        (
            [post_title] => A Post Title
        )
 
    [1] => Array
        (
            [post_title] => Another Post Title
        )
 
)
// Action() - Only returns whether the SQL-statement was successful or not.
print_r($DB->Action('DELETE FROM wp_posts WHERE post_author = 1'));

Returns a simple boolean, true or false.

Thanks to the simplicity of having two main methods that works against the database I was able to further extend the database class to support more of the database functionality that PHP offered:

  • PostgreSQL
  • Microsoft SQL Server

Although the new internal functionality the external interface remained the same. No matter what database server I connected to the old main functions would still do their job.

// Connect to a <b>MySQL</b> database
$DB = new DatabaseConnection(<b>mysql</b>://user:password@localhost:port/db);
 
// Connect to a <b>PostgreSQL</b> database
$DB = new DatabaseConnection(<b>pgsql</b>://user:password@localhost:port/db);
 
// Connect to a <b>Microsoft SQL Server</b> database
$DB = new DatabaseConnection(<b>mssql</b>://user:password@localhost:port/db);

After the connection is established (through the creation of a new instance) the main functions work just like before.

I Do Not Want to Work as a Programmer

Programming for me is a passion, but that does not mean that I have the discipline to work as a developer on a real enterprise project with real deadlines. By taking this course I have proven once again to myself that I do not want to seek a career within the IT field. Not now, not ever.

Just like I cannot easily write an essay on demand, I find it very difficult to write software oriented towards certain goals and functionalities. It does not matter how simple it is, if I do not find it extremely interesting I will simply put if off, which I have basically been doing with the whole course.

Over-design Steals Your Creativity

After writing a thousand (1,000) lines of code for the main project I have finally realised that I am severely over-designing it. I have one class for each database table, one class for something else, one class for managing that and the list goes on. When you need to further complement a class with external functions you kinda lose the point in making that class in the first place. Back to the drawing board!

Leave a Reply