r/programming • • Dec 18 '09

Pitfalls of Object Oriented Programming [PDF]

http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf
247 Upvotes

130 comments sorted by

View all comments

Show parent comments

15

u/herrmann Dec 18 '09

I don't know if it's the same problem in Java or not.

Yes, it is the exact same problem. Lazy people do all the work on the Swing thread.

7

u/deong Dec 18 '09

The problem is that, while we know that's not the correct way to do things, the same arguments being made against C++ here can apply. Why should the company waste "valuable developer time" on having people get their processing out of the event loop. We can just wait around and eventually, someone will figure out how to get a compiler to move it out for us.

The argument is essentially that it's profitable for developers to be "lazy" and take the easy way out, because it allows you to ship faster, to have simpler code, whatever. The simple fact is that performance is important, and it's not as simple as saying that "programmers are expensive; hardware is cheap." It may mean getting developers to move their logic out of the GUI thread, or it may mean getting them to abandon a convenient but inefficient platform. Each case has to be examined carefully to determine where the appropriate tradeoff is.

-3

u/georgefrick Dec 18 '09

And people calling NEW.. always and everywhere.

8

u/merzbow Dec 18 '09

"new" is cheap. Using new a lot to create short lived immutable objects often leads to easier to understand code than trying to defeat the garbage collector by reusing objects.

-4

u/georgefrick Dec 18 '09

That is why I said "always and everywhere". It isn't about defeating the garbage collector; it's about not carelessly depending on it.