Friday, January 8, 2010

OOP, UML and MVC, What? and Why?

As a developer, there comes a time when you start to get deeper and deeper into learning new ways of writing and structuring your code. I've been doing TONS of research and playing around with some techniques that are of coarse well known but to be honest I'm not exactly sure who really uses them, at least and unfortunately many co-workers are quite clueless when it comes to these techniques.

The techniques that I am referring to are OOP (Object Oriented Programming), UML (Unified Modeling Language) and MVC (Model View Controller) which is basically a way to organize your stuff in a manner that you should already be doing in the first place.

First off, OOP. I can't be the only one that had a tad of trouble getting their foot into the door and actually understand what on earth this was and why it is so important when developing basically anything and everything from simple show a name applications to more complex applications where there are many functions firing off at the same time.

OOP is a beast and once you get it, you know because it hits you like a train, making you think, OMG I can do this and yes, yes I do understand it.

At first I began writing some functions thinking I was writing OOP even though all I was doing was creating a bunch of functions and firing a main function instead of creating any classes which means I was still technically writing procedural code, yucky.

But that one day came and I got hit by that train that made me say, Oh jeez I was doing this all wrong but thankfully I get it now and will continue to do it the right way.

Now for UML. This isn't exactly all that new to me in a sense because when I was handed a project I always always always created a simple diagram which included needed functions, database tables with row names, foreign keys and so on.

Thing is, I'm not sure anyone even uses this technique to build their applications and by all means if you do please let me know.

Finally MVC which let's be honest, you should be doing this technique no matter what because it makes sense. Like OOP, there are many developers that might have trouble understanding what this is and why they should really even bother with it. The truth is that you should and it helps greatly when applications start to get larger in scale and you need to scale your application with ease and ridden the possibilities of introducing big nasty bugs into them.

But what is MVC? It's simply a way to slice up the code for your application into sections that make sense. Model, View and Controller, which should be obvious of what they do but instead of me trying to explain it all, try reading the Wiki on it here...

Enough of my ramble, I plan on tossing up a few examples of some OOP concepts in some future blogs in a few different programming languages.

- Pete

1 comment:

Joshua said...


You ever feel like there is no one in the world to talk programming to?

I've got one week to build an entire recipe database application.

I'm stuck trying to figure out how to get from the UML Use Case Scenarios to the OOP/MVC components in a PHP framework that I wrote myself.

All the forums, blogs, books and articles I've read don't provide a well defined way to do it. But I've gotta figure it out because it will help on every project.