Object Oriented vs Procedural Programming in small to medium projects

Hello everyone,

 As per the title I was looking to discuss with you the benefits of Object Oriented vs Procedural Programming, mostly in small to medium sized projects. I have studied and practiced both styles at University so I am up with both design principles, however when I am working on my clients web projects I find myself more often than not reverting to a procedural approach - especially in JavaScript.

I am actually a big fan of writing OO style code, especially in C style languages like Java - but I find with the prototype nature of JavaScript makes writing good OO code more difficult. I recently tried the Prototype JavaScript Library and I have to say I was very impressed with the way it allows you to write traditional OO style code.

I did some research on the Prototype library and the general consensus seems to be that the jQuery Library is far more popular than that of its Prototype counterpart. I also read some concerns that some of the Prototype Library uses code that may be rendered obsolete with future iterations of the Document Object Model (true?).

With this in mind would I be wise to adopt this Library in more projects in the future? Or perhaps It would be advantageous to stick stick to my tried and tested Procedural style of code?

I very much look forward to your opinions on the subject!

Kind regards and thanks,

Matt

This might not be helpful but to be frank, it depends on what you are doing.

Like for example, if you are creating a jQuery style image slider, OO techniques will most likely be overkill; unless you have a heap of customization options or if its particularly advanced.

If you are just checking whether a form field is completed, a procedural script is fine.

If you are however creating a RIA then you’ll probably want to use OO as the size of the application will probably benefit from it and even then a procedural approach may be fine.

Basically, it depends on the application you are working on & knowing which is best is something that will come from experience and understanding of what OO is and what the benefits of both approaches are (in the context of what you are doing).

ETA:
JavaScript isn’t as suited to object orientated programming when you compare it to the likes of java or php; where you can ideologically say OO is best.

But even then, with PHP; I usually create stuff using OO as my framework is an OO framework using an MVC design pattern. If I look at some of the smaller applications I have created that are OO, there are quite a few where I could have used a procedural approach and I wouldn’t have really lost anything from doing so; but then I wouldn’t have really gained anything either.

With JavaScript its a bit more complicated and so many factors come into play that the answer is really fluffy. Which is what lead to my initial answer of “it depends on the project”, it will also depend on your application design, what parts of the application are handed over to server side scripts which may be OO, what you are trying to achieve etc, etc.

Also your application design will be influenced by the above. A bit chicken and egg I know.