r/programming • • May 28 '14

"Compression-oriented programming" - Casey Muratori's blog

http://mollyrocket.com/casey/stream_0019.html
125 Upvotes

67 comments sorted by

View all comments

11

u/[deleted] May 28 '14

If his stance is generally against OO, then I agree with him for the most part. OO has its uses, but it's far overused, overhyped, and over emphasized in terms of importance. 95% of OO code I've read (including my own) has been poorly implemented and naively designed.

I don't think any one paradigm is a one-stop solution in terms of its methodology (nor should a paradigm never be used). A lot of people in the industry tend to have a major hard-on for OO though...and it tends to be attractive to newbies as well, once they've grasped the concept of classes.

In my opinion, as soon as the focus shifts toward "objects" and extremely pedantic notions in regards to how aesthetically pleasing one's code is, the point has been lost. I still see a very large portion of code employing the use of getters and setters, the majority of which provide absolutely no benefit, and have witnessed near heated discussions on things like IsNullOrEmpty() function calls being argued against, not because of what they do, but because of their title.

Good code is code which is readable, as simple as it needs to be to function properly, is defensive where it needs to be, conforms to a clear set of pragmatic standards, and has a reasonable amount of comments. Anything else is pretty much subjective and detracts from the point, which is to write software which works well for the user and is only as complicated to maintain as is necessary.

So, OO itself isn't necessarily bad; it's the philosophical connotations and over-thought code pollution which unfortunately tends to come with it that's bad.

2

u/illiterate May 29 '14

This should be on a poster at workplaces.

Good code is code which is readable, as simple as it needs to be to function properly, is defensive where it needs to be, conforms to a clear set of pragmatic standards, and has a reasonable amount of comments. Anything else is pretty much subjective and detracts from the point, which is to write software which works well for the user and is only as complicated to maintain as is necessary.

1

u/loup-vaillant Jun 01 '14

and has a reasonable amount of comments

That part is redundant. Just write the comments that help, and delete those that don't. The "reasonable amount" cannot work everywhere. Some code is so simple that no comment could ever improve it. Some code is so complex (or obscure) that every other line needs a comment.