Author: Justin Lee

  • Similarly Human, Different Lives

    Yes, the title comes from the Chinese saying 同人不同命, meaning we are all similarly humans, but we lead different lives.

    I just read Jac’s Blog and it seems that she’s so stressed at work until she lost 4kg. While I would certainly need to lose some weight, I think Jac’s not the right candidate for this weight lost programme.

    Unfortunately as well, 同hamster不同命. Casper made an escape and when wifey came home, he was not in his cage and we found him in the kitchen drain drowned to death. This is his 5th month birthday. Sigh. Silly hamster, why did you choose to jump into a drain when you could go elsewhere? We will miss you. 🙁

    And then while some people very heng to stay in landed property, I have to live in a measly overpriced government flat (a.k.a pigeon hole) with a bloody inconsiderate neighbour upstairs who doesn’t sleep. I mean, there isn’t once I see their room lights go off, not even at 4am in the morning. Actually, I don’t care if they don’t sleep – maybe they do shift work – but that’s not my problem. If they choose not to sleep then they should be considerate to the rest of the people who’s sleeping.

    I keep hearing wooden furniture dragged along the floor, heavy objects dropping and people walking like King Kong. It’s not occasional – I can tolerate that. It’s persists through the night like a JavaBean. I mean, I can have a great day at work and have a great dinner with friends, but the moment I come home, these noises totally ruins my entire day (and sometimes the next.) These aren’t continuous background noises that our minds could filter (e.g. people chatting, piano playing, traffic). These are sudden bursts of loud noises that makes me jump, irritated and stressed out. It’s not I can’t cover the noise, but it’s so resonant that it overpowers my TV!

    Back in December 2009, I tried going upstairs and talking sense into them, but it ended up into a yelling session on the 3rd approach. Then I resorted to knocking on my ceiling with a wooden stick and calling the police. The noises went away for a while, and recently they’re back again. I knocked on the ceiling a few times, but it seems they’ve decided to turn rebellious and knock back. So that’s it, I’m fucking fed up already, I’ve had enough, no more Mr. Nice Guy. I’m going to a psychiatrist because I’m so stressed out, and I am going to send them a lawyer’s letter. If talking and knocking doesn’t work, maybe paying for legal fees will.

  • It’s Really Very Hiong

    Even if I only have one module to do, this one is surely, confirm, 100% chop very hiong. For the past few days I’ve been working on the CS3216 Facebook Assignment and my wife is nagging my ears off because shes says I boh hiew her. I think my teammates lagi worse because they’ve been staying late in school, but it’s good for them lah, once in a while so hiong, otherwise they come out to work, sometimes even more hiong.

    So if you wonder if there’s ever once I had to camp overnight in office to work, the answer ish YES. But the difference is that I wasn’t building a killer app that could potentially earn millions. I was actually working on a major system outage, i.e. debugging.

    Anyway, need to relax my mind so no geek talk, no work talk. Here’s a video just for laughs, this is really funny but a little bit vulgar.

  • MVC Quick Hack in PHP, Tips on Web Development

    Unlike Java, PHP wasn’t designed with MVC in mind, but with bigger projects MVC becomes important to keep code clean and readable. I’m sure a lot of crazy people in the class would have figured out their own MVC quick hack, but I’ll just share mine here.

    • The Model shall remain as MySQL. I’m not going to spend waste time creating beans-like objects because I personally believe beans are inefficient things for retrieving even the simplest of things. In PHP, the mysql_fetch_assoc() function is really all that you need. The web is a stateless thing, let’s keep it that way.
    • The Controller shall be the direct PHP file that gets called, i.e. your URL links to the controller, your form submits to the controller. The controller contains purely logic.
    • The View shall be a PHP file that sits in another directory and gets called using the include() or include_once() function and contains HTML/CSS/JS and some bits of PHP such as loops for displaying content.

    Also, here’s some of my personal tips when developing public-facing web applications.

    • Do create an error handling routine. You may implement this in any way you want, but I typically use an array and use the array_push() function to push errors into the array stack. If the array is empty, we know there’s no errors. But a simple array can be quite ugly, so you might want to create a data structure to take care of where exactly the error message shows.
    • Always end your files with .php. Don’t end it with .inc or .somethingelse because you will be vulnerable to expose your source code, unless you configured Apache to parse .inc files as PHP. Even so, I’d still advise to keep the suffix as .php in an event the files get deployed on another server with missing Apache config. The lesser moving parts, the better.
    • Always escape your string using mysql_escape_string() before querying the database to prevent SQL Injection.
    • Always take care of integer parsing. I like to use intval() because it doesn’t throw a fatal error. If it sees a string, it returns 0. This also prevents SQL Injection.
    • Always clean up output using htmlspecialchars() to prevent Cross-Site Scripting.
    • Never put filenames as parameters as you can be vulnerable to Path Traversal. Try to use other methods if you need to have filenames passed around, such as server-side sessions or constants.
  • The Second Lecture

    So the second lecture was on Software Engineering. Big word and unfortunately means big problem. The class was introduced to Agile/Scrum which is a newer methodology compared to the old waterfall/spiral SDLC model that I was taught in school.

    I used Agile/Scrum about two years ago in my previous job and my experiences were much similar to the ex-students who presented. I worked with teams from about 2 to 6 in size. Honestly, not many teams can get past 10 pax because of $$$. I must say 80 is an awesome huge group!

    So here’s my observations:

    • The common effort multiplier is between 2.5 to 3 not because people are slow or bad at estimating, but because they did not consider time taken for communication and other context switching overheads. However as the team gets better and better at estimating their effort this multiplier can go down to about 2. Don’t forget, Project Manager doesn’t do the actual work but still gets paid. 🙂 So where does his effort go?
    • The biggest problem with estimating effort is with companies billing by the hour. I was constantly questioned for high estimates (thanks to my 3x multiplier) because it ballooned the cost of a project and I was pressurized to push it down, but guess what? It always overruns, i.e. the original high estimate was correct.
    • Agile works well with small projects too, just that you may not need to religiously hold the daily scrums, but the idea of having broken parts down into bite-sizes is the key to easing project management.

    Wei Man is right. Geeks are bad at estimating effort, but we have to know what it takes to do something so that we can manage ourselves. Time, energy and life are finite and therefore our efforts are finite as well. If you don’t learn the skill of estimating efforts I can 100% assure you that you’ll overrun your projects. This is from a personal experience from not getting paid and even almost being sued. 🙁

    ***

    On the documentation part, Prof. Ben is right. There’s a job market out there with people writing documentation. This type of job is called Technical Writing. If you’re good with language, maybe this is a job you can pursue. There’s not many of these companies around and their clients are usually huge (Aerospace, Military, etc.) so you get paid pretty decent. Not to late to change courses now.

  • Ayiah, Another $6 for Parking at NUS

    Ayiah, what to do. I was already one hour late for a meeting with my teammates, but as the saying goes better late than never so I decided to park nearer to COM1 so I have a lesser chance of being knocked over by the NUS shuttle bus or errant drivers while walking up from Yusoff Hall.

    OK, you know I’m lying. Truth is that I’m just fat, lazy and wanted to save 5 minutes of my time walking up a dreaded slope. So for that, I’ve paid my “fine” of $6.85.

    Prof. Ben told me learning is never easy. I didn’t know he meant my wallet!

    So meeting teammates was done over my “official lunchtime” and somehow every time I meet these folks, something interesting comes up. We ended up talking super enthusiastically about a potential gambling app but later found out that it was against Facebook’s policy.

    Damn, otherwise we’ll be the next millionaires by the end of this course. Another fat hope dream busted.

  • Taking it Easy

    Prof. Ben commented that I’m having fun in my previous post. Well, in fact, I really am! I enjoy chatting with my team mates and messing around with my assignment.

    Actually if I put myself into the shoes of a student, I might not have done all these. Reflecting on myself seven years ago as a Poly student, I was too snobbish and competitive. I guess most students are like this, especially when they/their parents paid a fortune for the fees. Of course there are some others who couldn’t care less since they felt they were “forced to study”.

    But I’ve learnt to lighten up a little. Let me share a short story.

    I spoke to a friend A of mine who told me about this guy B whom he met many years ago. B was a very popular figure at many events and A always wondered why. He started to observe B’s actions – B would dress in jeans and tees when others were all dressed up, he’d talk cock at seminars and chat about irrelevant topics at business/networking events. At first, A thought B was an idiot and didn’t take things seriously, but yet he was so popular. A later made friends with B and found out that B didn’t really care what people thought of him and just wanted take it easy and have fun. A saw some light and started to take things easy as well.

    Fast forward, A and B are currently successful businessmen.

    Unfortunately, I’m not like any of them yet, but I’m starting to take things a little easier. I realize that doing so gives me a broader view of things. When I was a student, behaving the way I did only narrowed my vision as I was all out to impress… god knows who, but back then I was hoping it would be girls.

    (Unfortunately, I got my equation all wrong and I found out that girls aren’t exactly attracted to snobbish geekguys.)