What will you do if you write a shitty application? And what will you do when you find that you have written a shitty application? I’ve been haunted by these questions for the past two days, and yes, I’m guilty as charged. Before someone thinks I sound like someone who knows programming, let me clarify – NO I DON’T. And that is exactly the reason for this post.

The application that I worked on wasn’t something big and impossible. It was a simple school management system, written in PHP/MySQL with a liberal dose of javascript thrown in. Unfortunately, it just didn’t make it to the servers, and I abandoned it about 6 months ago. Much has changed in that time, and thankfully. I now really understand the need to follow Software Engineering processes, the most important being Design. So why did my team, and I choose to ignore something we’ve actually studied in college? Were we dumb enough to think that we wouldn’t be needing it? Probably. Were we not actually able to understand why we will need it? Possibly. The only reason that readily comes to my mind was because we never knew that we will actually need it.

Software Engineering courses in Indian colleges are often the most boring, monotonous and brain-dead courses among the lot. Throw in a thick rimmed, thick skulled man in his 40’s who has never worked on a real application all his life, to teach it and you have a 2012 waiting to happen. And it often does. We students cram the Pressman’s book a day before the exam, answer standard questions about SDLC, Testing, importance of SE, and get away with it. And that is that. We are never taught first hand on why we need it, how we should use it, how badly it will affect the software if you don’t follow certain principles, or why learn SE at all! Those are left to the student to discover after a few years, just like I have.

So what exactly was my application? It was

  • Very simple and modular
  • Web based for universal access
  • Not that huge or complex (Our team of 4 completed it in 3 working months)
  • Architecturally simple

Then why did we screw it up? We did everything that we could think of. We first gathered requirements, refined them, thought we did some design, then went on with the coding. Too bad we thought we designed it! We did not. Looking back, I feel really stupid about some of the decisions we took based on our understanding of the system. We knew we had to design it properly, but we didn’t take it seriously as we didn’t really know its consequences. I am no programmer, and if I feel my app is shitty, it really has to be!

Where did I go wrong?

  • No framework
  • No separating of logic from presentation. It was all embedded in a single file in true PHP fashion
  • No proper design of the entire system. No HLD/DLD
  • No glue. The code looks like disjoint pieces of a puzzle

What I did right?

  • Probably the architecture
  • With PHP/MySQL
  • Revision Control which was never used seriously

So the question beacons – When does one decide to rewrite/redesign an application? I need not have decided on redoing the whole thing. I could have as well patched it up, and sold it as many still do. It would still work, can be understood by almost any developer, and I wouldn’t have to waste time and money on a rewrite. Decorate shit and it will still be shit. If one doesn’t learn from mistakes at the first instance, he/she probably never will. So I finally did what I should have done in the first place:

  • Designed a breakdown of the entire system into modules and the coupling between them
  • Decided against going for a fully blown framework like Symfony as that will add unnecessary complication to a simple application, but rather write my own simple framework to separate code from design
  • Chose mysqli as the database driver and developed a simple wrapper around it
  • Added a logging system which was entirely missing
  • Work on a custom design from scratch, which will also work on portable devices
  • Write a generic framework for the reporting module with custom graphs and charts rather redo the entire code
  • And many many more…

The point I’m trying to make is, no one is perfect to start with. As a programmer, I was happy with my code 6 months back. Now I despise it. It is not something I can work on anymore. So rather than choosing to ignore the mistakes, swallow your ego, acknowledge the mistakes and redo it. Yes it is hard, painful, time consuming and costly. But software is a continuous process and the continuity is there for us to learn, undo and redo things the right way. I bet I will find blunders again after 6 months, but they will not be as bad as those I’ve found now. Maybe then, I can afford to patch things up, and be on my way.

For now, back to Software engineering : a practitioner’s approach by Pressman

P.S: This post is more of a reminder to myself than to others.

Ever wanted to get the MAC/IP address of your computer in a Linux shell script? The following two commands should work on most flavours of Linux/Unix

Note: It retrieves the address of eth0 interface by default. Make necessary changes as required.

IP:

/sbin/ifconfig | grep ‘\<inet\>’ | sed -n ‘1p’ | tr -s ” ” | cut -d ” ” -f3 | cut -d “:” -f2

MAC (H/W address)

/sbin/ifconfig | grep ‘eth0′ | tr -s ” ” | cut -d ” ” -f5

I was working on a project which required a simple calendar with inline edit. The calendar is for a school which marks if the day is working or not, and the comment (told ya, its very simple). Needs PHP, jQuery, jQuery jEditable plugin and a MySQL table to store the data.

The demo is here. If anyone is interested in the code, drop a comment.

P.S: Yea I suck at CSS. If anyone does a better job, please let me know.

Working on a project of considerable size will change one’s perception about coding. I happened to work on a tiny PHP/MySQL project with a team of 4 for a relatively short duration of 6 months. Before that, even though I personally followed sound programming conventions for my own convenience, I hadn’t a clue as to how important it is in a sizable project. Now that its over, I chanced to read up a little on programming conventions prescribed for various languages/projects here, here and here.

Read more

After weeks of searching for the perfect grid based data editor for my project, I’ve aspired to build one myself. Sure there are hundreds of existing plugins and more which are well established, and developed by well knowledgeable folks, I find a few shortcomings. Drawing inspiration from the existing plugins, here are my goals:

Goals:

  • Uses jQuery library
  • Small and light. Size should be less than 30 KB for minified version
  • Dynamic data source for easy table population (JSON or plain HTML)
  • Create, Read, Update and Delete (CRUD) operation
  • Sorting based on columns (using tablesorter plugin)
  • Searching based on filters for multiple columns
  • Follows KISS Principal – Keep it simple stupid. No unnecessary insertion of DOM elements
  • Insertion of checkbox for each row and defining custom button to perform an action

What seems like a huge list of features add to my very basic problem : I’m still a noob at jQuery and javascript. So, as a personal goal this project is a way for me to learn jQuery right from scratch, and to put it to good use.

Methodology:

  • Study the existing plugins to understand how they work
  • Use code snippets that are already available. Reduces work, and will be much better than reinventing the wheel the wrong way
  • Less attention to appearance (CSS) till the code really works, partly because I’m still learning CSS, and would be tough to combine both jQuery and css code when I’m new to both.

As you’d have guessed, its an ambitious project for someone who is new to javascript/jQuery. Nevertheless, I hope I can pull it off with guidance from knowledgeable people who know their jQuery. I plan to host it on either github or google code and put up a dedicated page on this blog to keep track of the development. As the first step, I’ll start with defining the various functions that are required, thus creating a skeleton jQuery plugin, which simply displays a one line output when called in order (yea, I’m pathetic).

So anyone who reads this, please leave your thoughts, advice, comments here. Thank You.

    Stuff
    Everyone
    Calendar
    March 2010
    M T W T F S S
    « Jan    
    1234567
    891011121314
    15161718192021
    22232425262728
    293031  
    Rate this blog
    Clickity
    15429
Get Adobe Flash playerPlugin by wpburn.com wordpress themes