Archives for category: On Codes

I’ve been using MVC frameworks for a while now, and it makes me think why I didn’t use it earlier… Yeah, back when I started learn programming I was exposed to procedural way of thinking, remember BASIC on IBM XT ( Yup, I wrote my first program on those awkward looking beige box from IBM, with amber monitor and glorious Hercules graphic card ), and that’s already called a luxurious home PC, considering that at the time, my sister work involving boxes of punched cards and magnetic tapes :)

Ok, back to MVC, I’m not going to do another framework comparison here, rather, just a story about my learning experience…

My first encounter with MVC was using Java, learning to program desktop application using Swing and AWT, pretty enlightening experience, but i dropped it somehow because I have no real use for it, let alone any project to work on using it… then came J2ME, when I really have fun with, creating interesting stuff for mobile devices. I also learn a lot about object oriented programming concept here, another interesting stuf, tightly related to MVC.

Now, so many MVC frameworks pops up, it’s confusing … all popular programming languages have at least one implementation of it as a framework, notably Ruby on Rails, Python’s Django & Turbogears, PHP’s Prado, CakePHP, CodeIgniter, and many others…

Which one do I use ? I tried not to get stuck and become single minded on a framework, since in my perspective, all is just tools to get things done. Currently I use CodeIgniter for my project, while I also use Django to learn Python. Why, because CodeIgniter seems to be easiest to learn, and have certain tolerance to my lazy and messy programming practice :) , tried CakePHP once, and I was lost in convention of plural singular naming… I notice Django has similar idiosyncracies, but I think I’m a bit more ready for it , after all, it’s in different language so everything is new ( I think it’s just me, it is hard to do things on convention, while I already get used to the way PHP done stuff, free and very tolerance to any kind of programming style )

Beware though, for those who just want to start learn programming, jumping into a framework to learn the language ( and learn programming in general ), is not recommended practice. I suggest learning from the very basic, the very fundamental concept like what is programming, what is procedural, OOP, functional programming, and so on. Otherwise, learning using a framework is like signing up to a flying school to learn to fly, but jump direct into the cockpit of a 747 to learn the “basic” of flying and being a pilot.

Well, I’ll be a bit lazy and uncreative here, I saw an interesting one here :
How to Switch to the Mac at The Tao of Mac site.

I’m not going to start any platform comparison, but simply, article above should give a good insight before buying a mac. I switch to Mac for about 2 months now, and I regret I didn’t see this article beforehand. Not that I will drop my decision to switch if I did, but at least I didn’t have to learn some things the hard way.

IMHO, Mac is a great platform, I should say, way more than Windows, but less real power than UNIX / Linux. Of course I am biased, I see everything from developer standpoint, I don’t really care about how nice iPhoto could do photo album, or about downloading music from iTunes ( I wonder, how are those people listen to their 50.000 songs collection ? ). After all, I pick Mac because :

  1. Now it’s Intel based
  2. OS X is basically UNIX, with less security headache, spyware and myriad of malware lurking to get in.
  3. From price performance ratio standpoint, it’s very much worthwhile to spend a thousand buck for it, since I can get nice looking, dual core Intel system, that comes with neatly organized OS that I can use right out of the box. I reckon similarly configured Windows laptop will cost around US$ 1500, if ever it match a Mac, at all.. I don’t know how much a Windows Vista license cost, as if I ever really care :)

What I find a bit annoying about Mac is :

copying folder on top of similarly named folder will overwrite the old folder, not merge into it. I learn the hard way about it, I move a java source package into /opt directory, and all I see later on is a glob of data file named opt in the root directory… Yaiks… of course I’ve done that in terminal using command line ( for those asking “How come…” ), move a file is the same with renaming a file in UNIX world, and in my head “mv somefile.tar.gz /somedir” usually move the file into the directory, not renaming the file and overwrite the directory, the operating system should be able to distinguish the type of the target, whether it’s a regular file or a directory… pretty much a brain dead way on doing simple thing, especially for highly praised and overhyped platform … sigh..

I know, i know, there’s a warning when you do sort of thing, but mind you, I was doing it in the shell terminal, not in Finder GUI, anyway, I still think that Mac OS should be able to merge folders, or at least distinguish between regular file and directory and then act accordingly, not just giving stupid useless warning telling that user is stupid on attempting such action.

Other thing is the warning on “leaving a secure website” which only have one button “OK”, hmm.. oh no, that’s for other stuff, not Mac OS .. haha :D

I’ve been working on a social networking site for a while now, and here’s some basic concept I’ve learn from he process ( warning : These are based on my experience, maybe different with you, but what do i care… ) :

Basic Entity of a Social Network Site :

  1. User ( could be Person or anything else, think about social network for your pet )
  2. Message
  3. File

Expecting something more ? well, I tell you, nothing more than these I can tell you about :)
Anything else is built on top of those entities as extension, or simply connecting those three, in meaningful way of course.

Example :

  • User connected to other User as friend
  • User send Message to other User, to her / his friends, or simply make it available to public
  • A File attached to a Message sent from one User to another.
  • User make a mark ( a tag , for you pundits ) to a File, then send Message to other user about it.
  • User make comment on other User’s Message with a File attached to it, a comment itself is another form of Message

Think about it, we can create so many other kind of relationship between those three objects, tangle it, twist it, of course it has to be in meaningful way, and then you got your social networking site, as simple as that, in a geek point of view.

So far, with all these basic knowledge about those three basic entities, I have abandon one CMS system ( Drupal, sorry for all you Drupal fans out there… ) because I then realize that generic CMS can only accomodate the relationship the way it want me to, not the way I want it to, well, maybe because I have insufficient knowledge for the CMS, or maybe I just mess around too much with it, I don’t know… All I know is that I can’t get scalability and speed by just plugging around all different add-on modules created by all different people and way of thinking and then try to configure smoothly as if it was all come from same people. It was simply hard to imagine how to scale up, if early in development phase you already have at least 40 tables in the default database ( yaiksss… ), not to mention the way add-on, modules, and hooks works… with more than 20 modules installed, a simple process like saving a node will take significant time since the system will have to enquire which hook implementation should be triggered, and amny other part of the system need to be triggered to keep everything in sync.

I tell you, it was like fishing with a shot gun… really, you are on boat, aiming for a fish with your shot gun, fire up, and then … the thundering sound will drive away the fish , along with everything else that can move, and the shot gun kick back will send you off the boat on the other direction :) … not good, not good…

I move on rewriting the whole thing, using CodeIgniter, a sleek simple MVC based PHP framework, and so far I get by with only 15 tables in my database to carry all the data required by those 3 basic entities, including all the relationships between them, not a bad setup, as I expect I will end up with less than 20 tables when the site will be launched.

Okay, I admit, I do a great deal of denormalization, because I need speed and less query, the wisdom came from my mobile content days… And I also feel sick about table joins, so I’d rather make the DBAs and business application programmers disappointed, than make my life less joyful, couldn’t care less about their feelings anyway, if you ask me… After all, theory is good, but when you have to face real world, all you can think of is how to get there in simplest, fastest way possible.

After several times dealing with major open source CMS ( Mambo, Joomla, Drupal, WordPress ), I have developed certain wisdom over the matter in a holistic ( pvuwaah !! :) ) ) approach.

Well, NOT… haha

Okay, seriously… in my point of view now, a CMS is a rigid blob of code, needed to be hacked, tweaked, whipped hard like a mule, just to get it working the way you want it to, that is manage your content…

Yes, true that they are designed to ease the development process, especially when you don’t have that much resources around. A web designer could use Joomla for example , to have a dynamic website up and running in matter of days from scratch, but that’s just a plain good website taking its content from database, plus some some plugins and add on stuck all over it just to get client eat the eye candy happily…

The fact is, after the final payment, the designer going home happy, while the horror for the client has just began … CMS usually designed to be general purpose, therefore many things are just unnecessary bloat… to make it flexible, the developer usually compromise on many thing, like deliberately unoptimized query… why it’s not optimized ? because it is necessary to be unoptimized… otherwise no way to get things done, not necessarily done gracefully, but just done. period.

My latest experience is with Drupal… a CMS with great review, popularity, and a horde of fanatical fans… how am I doing with it ? I tell you, my first impression is great, it’s slim ( just under 400kb of source script ) , easy install, no nonsense administrative panel, multiple site with one installation, possibility to make sigle sign on for multiple site, etc.

The “community plumbing” motto sounds good, the plug in architecture is nice, user management is just about everything you need… but then comes the horror… what i needed to for the site i developed is a full featured media management system, that is a system that is capable to handle video, audio, and image, plus i have to develop certain degree of social network and commerce function on top of it. I tried all available add on , plug ‘em in, configure, tweak… no use… everything just plain messy, disintegrated, and worst, it force user ( and me as developer ) to think the way Drupal ( or its developer ) think. The ugly magic showed up, weird stuff popping up here an there… just like you are on a boat in the middle of a lake, where the boat turn out to be a wreck because the shiny paint that looks great on shore , simply dissolve in the water, revealing horrific holes and ugly creaking patches.

okay, enough with the horror story, the thing is that after grinding my brain on moving things in Drupal molasses, I just fed up and swallow the fact that it’s just only good for prototype, a proof of concept. I wouldn’t even bother to imagine using it for real production site, which will handle thousands of concurrent user every second. It just won’t stand it.

Now, back to square one… well not entirely, i got the whole plan mapped out and all pitfalls and bewares noted from the proto site. All i need to do now is to rewrite the whole thing nearly from scratch, using lower level library and framework. that way I know what’s under the hood, as I’m the one writing it, i know the kinks and bends as i created them :)

So… don’t get too excited with CMS, my good friend… it could only get you that far, but never beyond…