FamousPhil.com -- Home My Calendar Youtube LinkedIn Facebook MySpace Twitter RSS Blog Feed

Blog Navigation

Blog Home



Partners

Latest Activity

MySQL Singleton Classes in PHP and Python

Phil gives the source code for implementing a MySQL singleton class in both PHP and Python.



Posted on: October 17th, 2009 by Famous Phil

Just by looking at the title, I’d hope that you can at least partially relate to what I’m going to blog about today.  As you may or may not know, I am a computer science major at the University at Buffalo going on my 4th year of studies.  In computer science classes, it is well known that you will be expected to complete programming assignments, it makes common sense doesn’t it.  A big chunk of the computer science program at UB deals with programming assignments, and most of these projects are not trivial.

: Normally when completing a math assignment, there is only one way to come out to the correct answer (eg. 2+2=_;   _=4).   In programming, this is not the case.  Usually there are at least 5 to 10 different methods to solve the same problem in a given language (C, C++, .NET, Java, Erlang, Prolog, Lisp, etc).  For example, to add up all the numbers from 1 to 10 in Java, a programmer may choose to implement any kind of loop that increments a variable each time and save the answer or they may choose to just flat out add 1+2+3… on one single line and print out the answer.

To get back to the topic in hand, thr0ugh my entire time here at UB (up to but not including this semester), I would always begin my programming assignments the day they were handed out.  I would then spend countless hours with all of my free time finishing them well ahead of schedule.  This was partially because I am an early person and I hate being late with any type of commitment I have.  The other half of this was because I normally had no clue what had to be done so I would spend countless hours researching the topic to figure out where to begin (this process included visiting professor and TA office hours).  Almost always between this research and working on a project, I could expect to spend anywhere from 10 hours to 150 hours per project from start to finish.

An example of a 10 hour project when I first started learning Java in a freshman course was to make this fish tank program that had swimming fish.  Naturally, most of the support code and advanced code was already written for me, but it would be my job to figure out what that code did and tie it together into what the assignment was asking.  Unfortunately, not knowing what I was doing (I might have had a clue but not much more), it would take me on average 10 hours to learn what the assignment was asking me to do and figure out the 10 lines of code that made the project work.  The projects that fall in this category tend to have a week to complete the assignment and I barely had enough time to learn what I was supposed to learn.

Later in the program, I got into projects that would easily take 100 to 200 hours to complete.  A good example of such a project would be a program that works with storing data in the computer.  In computer science, there are methods that allow the programmer to store data and these are called data structures.  One such data structure that I had to work with in this project was a binary search tree.  I doubt you know what this is, but the important part is to picture a tree outside.  Think that all the leafs on the tree are the data stored in the tree and the branches are a way to get to those leafs, this is a very vague picture of what a binary search tree does.  Anyways, the project example would use a tree of some sort to store a dictionary and implement a spell check functionality using a tree, which tends to be much faster in dictionary lookups than other data structures.

If you don’t understand whats above, don’t worry, I don’t expect that anyone outside of computer science would have the slightest clue to what I said above is actually trying to get across.  The fact is, through all of my past 3 years, I discovered that I’m really good at estimating how long a project will take and I decided that I’d plan ahead for a project that was due a couple weeks ago.  I gave myself *just* enough time to complete that project based on what I felt it would take in terms of time, etc.

You might say that I kind of started it at the last minute (although I started days ahead of time because I estimated it would take 100 hours or so).  Anyways, I choose to start precisely 1 week prior to the due date for a project that had a full month to complete.  Normally, this is acceptable in most disciplines.  Since I thought I knew enough to do this project in 100 hours, that is why I decided to start later.

Up until this project, I have never risked starting a project so late, especially a programming project that I really care about.  You might say that I was experimenting with seeing how late I could start and still finish on time.  Unfortunately, starting late because I thought I knew what I was doing burned me.  I ended up doing a programming marathon with little sleep from that Thursday to that Sunday when the project was due.

From this experience, I have learned never to start late.  I consider it my one trial for lateness to see what happens when I start something late, and for me, I write horrible code and my work is crappy.  I also learned that when I work under pressure, I tend to give up a lot easier on tiny bugs, and I also found that I didn’t even do common sense error checking that I normally would do.  The result, I submitted a half working project that might get a 75/100.

Perhaps you can use this example to convince yourself that you should never plan time without adding a buffer to it.  Starting at the last minute is bad news, especially if you need to ask questions that may not come up until you actually attempt to submit your project.

Tags: , , ,
Posted in Student Life
|| No Comments »