[ACCEPTED]-Does Object Oriented Design have a place in web development?-oop

Accepted answer
Score: 14

The only time I don't use OOP is when:

  1. I'm 36 creating a simple project to test some logic. This 35 usually leads to creating the right classes...

  2. I'm 34 using Classic ASP (been awhile, thank god).

  3. I'm 33 not programming.

edit 3+ years after posting 32 the above; I'm appending a bit to my answer.

OOP 31 is great and allows us a tremendous amount 30 of flexibility for having multiple systems 29 interacting with the same data / logic. However, there 28 is certainly a situation in which you wouldn't 27 want to bother loading up a lot of objects.. Namely, when 26 you are simply pulling data for tabular 25 display.

Querying a database and getting 24 a simple record set back that is immediately 23 emitted to the browser usually doesn't need 22 OOP involved. As a matter of fact you might 21 want to sidestep OOP completely as tabular 20 data usually involves a roll up of other 19 information (sums of child records) and 18 you normally don't want to pull more data 17 from the database than what you are actually 16 using. ie. if you are only showing the name 15 and email you probably don't want to grab 14 the user name as that is just wasted cycles.

Now, putting 13 information into a DB usually involves making 12 sure that certain business logic is followed. For 11 example that the username follows certain 10 rules. In those situations leveraging an 9 OOP style keeps things a bit more encapsulated 8 and easily transferred between systems.

So, looking 7 at the specific example: I wouldn't bother 6 with more than handing a datatable to a 5 repeater when pulling data; but I would 4 have a user class for when I'm going to 3 create a new one or operate on that user 2 to make sure the business rules are properly 1 followed.

Score: 8

One question: does the data need to be coupled 36 with function/method calls? If not, OOP 35 is not necessary.

Your best approach might be to find 34 an empty whiteboard, create a high level 33 model using Object Oriented Design, then 32 with Functional Design, then with Procedural. You 31 might surprise yourself (and others) with 30 the results. The same language can be used 29 in vastly different ways depending on the 28 project. As mentioned by @wj. OOP is just 27 a paradigm, don't be afraid to step outside 26 of your comfort zone and design using a 25 different paradigm.

Taking time to design 24 using different paradigms will also help 23 you when you approach your boss to discuss 22 why you should or should not use the current 21 paradigm. Most bosses will appreciate that 20 you spent the time to research before approaching 19 them with an idea -- this isn't to say they'll 18 accept your idea, but being knowledgable 17 going in will potentially get you a few 16 extra minutes of his/her attention.

IMHO 15 (don't take this personally), "Object Oriented 14 Programming" has fallen with the likes of 13 "Web 2.0" -- a buzzword of sorts, which 12 is unfortunate; you now see developers forcing 11 OOP where it would be better suited to use 10 FP or PP.

The best professional advice I can give is to design (high level at first, then 9 dive down) in multiple paradigms (do your 8 best not to be biased -- keep an open mind) and 7 decide which one best addresses the way 6 your application works. In my 15 years experience, 75+% of 5 the time I find OOP to be unnecessary, although 4 my current project is strictly OOP.

A more 3 important/relevant question would be, "Does 2 Object Oriented Design have a place in my 1 current web development?"

Score: 3

OOP is nothing more than a programming paradigm !! but his importance 5 is that hi is THE actual paradigm in use implying that all 4 modern knowledge and best practices in software engineering 3 will be expressed following this style of 2 programming ...

A good example in your case 1 (web development) is the Core J2EE Patterns.

alt text
(source: sun.com)

Score: 3

Although objects make it easier for some 51 programmers to develop, I've read the perfect 50 example of how to build an entire website 49 without OOP. Not once ounce. Check out the 48 last page in a 20 page series entitled Clean 47 PHP:


Super easy to follow, clean way of building 46 an entire website. No confusing OOP, no 45 super nested folder, no crazy spaghetti 44 code to follow for hours... Just simple, clean, and 43 well laid out functions that do EVERYTHING 42 you need, without the use of OOP. And this 41 example has everything from login/registration 40 credentials, an admin section (CMS), even 39 database fixtures to get you started, a 38 search function that uses mapquest API to 37 do zip code / lat-long lookups... I mean 36 it has EVERYTHING for a core project, or 35 website.

Why bother with OOP? Clean, and 34 properly structured procedural code is great!

On 33 the topic of OOP. I remember another fad 32 that everyone thought it was cool, and everyone 31 did it, but then found out that smoking 30 gave you a whole bunch of problems.

Stick 29 to the simple, stick to what you know. Be 28 an expert in PHP and you never have to depend 27 on a framework again. Don't get me started 26 with OOP MVC Frameworks. Interpreted languages 25 for the web were never meant to be OOP. OOP 24 just adds another layer of complexity. Stop 23 being lazy. Use your PHP, and learn how 22 to freakin program!

On the other hand, I 21 can see how making games on a console can 20 be difficult without OOP. But then again, it's 19 apples an oranges. Console games keep their 18 objects in memory until the game exits, or 17 object is destroyed from within game. Think 16 about it... Why do they have a loading bar 15 in front of every level? Now, imagine a 14 web page that has to show you a loading 13 bar every time it loads because it has to 12 create objects from a database. SLLOOOOOOWWWWW 11 central! And once you navigate away from 10 this page, you have to start all over again.

Web 9 pages are applications within themselves. It's 8 like rebuilding your drag racer each time 7 you go to the starting line, only to take 6 it apart at the finish line. WTFridge? Seriously? Hey, super 5 geniuses who think OOP is sooo cool... Keep 4 your damn OOP out of my websites!

Just saying, this 3 is from my 10+ years experience with web 2 development, you know when we used to code 1 pages in HTML, one by one?

Score: 1

Of course it does. You (and more so your 7 boss) say "rebuilding" like it's a huge 6 chore.

What you mean by "rebuilding" is running 5 the program. Tell your boss that OOP in 4 general is stupid because even in a desktop 3 environment every time somebody runs a piece 2 of software the objects need to be rebuilt 1 so it's not even worth it.

Score: 0

Boss's comment is useless. The .net framework 4 consists of objects and nothing else. A 3 "response" is an object, even in "classic 2 ASP" - why would people have implemented 1 it if that were resource ineffective?

More Related questions