I-Am-Bot Code, technology and life

18Mar/100

Status Update

Posted by Srinath

It's been a while since I posted anything worthwhile. This is a brief update on what I'm upto and what plans I have for this blog

1) I'm planning a minor update to dScript - to fix a couple of minor bugs, and make it easier to customize (Done!)

2) Work has started on a comprehensive PHP User authentication system - something that is simple, secure and has loads of customization options. I know there are a lot of options around, but I was looking for something that is pure OO and is extensible. It will require PHP 5+ compiled with PDO. Will be released with an appropriate open source license once done

3) Will release an PHP API for ZNISMS service. It is by far the best bulk SMS service I've used and I would heartily recommend it to anyone searching for such a service in India.

Other than this, I've finally figured out a bit more about JavaScript than before and even though they aren't new, I will put up those as code snippets for those who might find it helpful.

Code On.

Tagged as: No Comments
31Jan/104

Of application rewrites

Posted by Srinath

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.

Tagged as: 4 Comments
8Aug/094

Welcoming a new author

Posted by Srinath

I'd like to welcome my friend Sandeep as a new author on this blog. In the meantime, I'll be taking a temporary leave of absence, and entrust this blog to him, whom I trust to make better use of this space. You can find him at twitter as @sandyssn and email him at sandeep [AT] iambot [DOT] net

See you when I see you.

Tagged as: 4 Comments
3Jul/090

India and cheap IT

Posted by Srinath

As an Indian, I don't consider IT to be a savior of the country. Just don't. Sure it THE fastest growing sector, and booming along with mobile and internet penetration in the country, but its known as a place for cheap labor, and not otherwise. India probably needed such a boom for its economic revival, but at what cost? The companies hire in thousands, dumping the freshers right out of college in one of their many development sheds, where they code as zombies all day, day after day. And the sad part is, they don't mind it!

2Jul/090

PHP bashing has to end!

Posted by Srinath

Of late, I've been noticing a lot of PHP bashing around the web. Most of it is related to one major issue: Security. Granted, PHP's security implementation isn't the best out there, and it is a widely discussed topic. But more often than not, the security loopholes are due to bad/inconsistent programming principles, rather than a core PHP issue.

Also, PHP's lack of support for threaded programming is another major let down. While this is a genuine issue, rewriting the entire PHP core and the parser to support threads is not worth the effort. But I genuinely haven't felt the need for multi-threading in PHP till date. While threading is a must for system programming, the need for it in a web environment is not entirely clear. Also, the major strength of PHP - its simplicity will be compromised if threading is to be introduced.

Another genuine concern is the confusion caused by settings such as "register_globals" , "magic_quotes", "safe_mode" . These three variables have had a major impact on the deployment of PHP scripts. Web hosts allow ways to tweak these settings, but for the layman who just wants to get a blog up and running, its a bit of a hassle. Also its an issue that needs to be addressed by web developers who want maximum compatibility for their applications. The next major release PHP 6.0 aims to completely do away with this settings for good, and that will indeed clear up a lot of mess.

Most of these issues boil down to one thing - the lack of a an official formal specification. Although the PHP Group oversees the continued development, it is still a community effort, and as such requires stringent software engineering and management. Since the original PHP parser was completely rewritten for version 3 and above, there have only been attempts to patch up vulnerabilities, and add new features like Object Oriented Programming, namespace support among others. PHP 6 is touted to be THE release, which will address most of the major concerns.

For all its shortcomings, its still THE easiest server side scripting language to work with. The C/C++ syntax, seamless integration with MYSQL, support by almost all web hosting providers still make it THE web language IMHO. The LAMP stack is undoubtedly the king of the web, and will continue to be so, owing to the simplicity and widespread community support offered by all its components. And not to forget, its completely free.