views:

128

answers:

5

I work at a web development shop so naturally we deal with user profiles. When dealing with one of our sites I noticed that there was no 'User' class, which struck me as odd since we certainly have users. Instead the site relies on interacting with DataRows (this is C#) returned through static methods with little to no instantiation. I asked my boss about creating a class for users and his response was that since the objects have to be rebuilt so much its often not worth it.

I am relatively new to web development and it does seem like a bit of a waste to have to instantiate objects each time the page is rebuilt but on the other hand I've always found object oriented programming to be useful. So I'm curious for some opinions, how much do you guys use OOP in web development?

+5  A: 

Your boss is (sadly) an idiot. OO helps create well structured maintainable code. Object creation is extremely fast and garbage collection of short lived objects is very quick too.

What you have here is premature optimisation leading to fragile code.

Paolo
+1 except for the last sentence. The example isn't premature optimization. It's just bad practice.
Chris Lively
True, but it's bad practice as a result of assuming OO is too slow and the half-arsed procedural mess is quicker without actually measuring and comparing. That's what I meant by premature optimisation.
Paolo
+1  A: 

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

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

Tyler Smith
+1  A: 

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

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

alt text

wj
Woah, imagine that system without OOP...
Daniel S
+3  A: 

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

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

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

  3. I'm not programming.

Chris Lively
+1 for the third bullet point :D
Paolo
+1  A: 

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

naivists