Archive for February, 2006

Confused programmer

Friday, February 24th, 2006

Beware – highly geek whining ahead. And it’s rather unorganized.

As a programmer, I’ve hit a huge stumbling block. Actually, it’s not something that happened at once. I’ve been feeling the pain for at least couple years, and I’m getting more and more fed up with the situation. And the worst part – I still haven’t found a way out.

When I started using it in 1999, PHP was somewhat a new language on the web. It’s a language that was made for the web. It did what I needed. It was very easy to learn, especially with my background in C, however rudimentary it was. I’ve built a site with it, and it worked. Not the best, but it worked. But ever since then, I’ve been stumbling on number of problems that these various “why PHP is bad” articles point out.

I think the worst problem I’m facing is that the apparent simplicity of the language is actually the cause of added complexity. I don’t know for sure – I’m just guessing. I don’t have the expertise in other languages like these bloggers. I must be missing something in the area of knowledge in software engineering, and the knowledge of the features that those languages offer.

The sites I manage here at work are getting bigger and bigger. The complexity adds on each time. At first, these sites were rather simple, just like some simple personal sites. I didn’t have code manageability in mind when I started on these sites. Spaghetti codes are everywhere. We’re managing the current sites fine, but I’m not sure how we’ll manage if we have to do a total overhaul of these sites.

I have no intention of abandoning PHP just yet. Despite the weaknesses that PHP has, I still think it’s possible to build a good software with somewhat clean codes with it. There are some major, successful projects built in PHP. Many popular blogging software like wordpress, drupal, b2evolution, etc are written in PHP. New wiki systems pop up quite regularly, many of them written in PHP. Large scales bulletin board systems too. Heck, I use b2evolution, PmWiki, and Simple Machines Forum, all driven by PHP. So I know it can do the job.

But on the sites that don’t rely on these pre-built software, I’m really struggling. First and foremost, the separation of the logic and presentation is not there. I’ve been reading on that topic for quite sometime. I’ve heard about Smarty template engine. I’ve read rants about smarty. I’ve looked at some much smaller template system such as this one. But I’ve never implemented these. And I just left it alone.

Ever since I read this article on slashdot, and learning what this WASP thing is about, the whole issue of separation of logic and presentation came back to me. Actually, it’s a bit more than that. It’s the concept of MVC – Model, View, Control. To me, this thought pattern makes the perfect sense. It does separate the logic and presentation. Not only that, it separates the data access logic from the core business logic. And here it is – WASP – a framework written in PHP that handles the MVC. Perfect.

Or was it? NO. A big no. It assumes I have certain libraries and such that I don’t have. It doesn’t work well forme. And my search for a perfect MVC framework started. Symfony? No. PRADO? No. Cake PHP? This one looked the most promising of all systems I looked in to. I spent about two weeks trying to learn this system. But still, it just isn’t flexible enough.

There is one problem when it comes to these systems written in PHP. Many of them assume that the hosting environment is Unix/Linux based, and is run with Apache web server, and MySQL is used as the database engine. My situation is completely different. I run my PHP site on Windows server, using IIS, and use an obscure database connected via ODBC, as well as IBM DB2. We connect to several others as well. Yes, multiple databases adds more complexity to the system.

Then I came across this series of article, Stupidly Easy MVC in PHP. It’s not a pre-built frame work. It’s a walk through on how you can build your own frame work in simple format. It takes inspiration from the same system that WASP and CakePHP did – Ruby on Rails. Great. I think this might work.

Right now, I’m in the middle of trying to figure this baby out. It still is quite a monster when I try to fit this monster spaghetti code in to this framework. I can no longer slap codes together as my instinct tells me to. I’m struggling hard to just rebuild one application using this simple framework. What I thought was somewhat simple when I coded it isn’t simple at all.

I really lack the proper knowledge of software engineering. I wish I could get some experience in larger software shop, and learn how to work in an organized software project. I want to learn how to manage large scale software projects. I just don’t know where to start. I feel like I’m trying to grab on to whatever piece of straw I can find.