Is the supremacy of object oriented programming coming to a close?
blog.objectmentor.com
blog.objectmentor.com
This nails it. I find so much of my programming now is shoving data into objects, only to almost immediately pull it out again into JSON, XML, HTML templates, or relational databases (in both directions). Most of the code in these "objects" are just getters, setters and member declarations, with very little in the way of actual logic. There is little point in having objects at all for this kind of programming, as opposed to a map, struct, or type class of some sort.
The point of having named and typed member variables is that I actually know what's in there. I know that a User object has a displayName property, so I can use that. I know that the address property is actually a List of Address objects, not a string, and not a Map. And I can know this instantly using my IDE's auto-complete and tool-tips. It's also exposed via Javadoc, which means if your front-end team is writing the JSPs, they can just look at the Javadoc to know what they have access to, without bugging me every 10 seconds.
Not only do I know, but the compiler knows, and can let me know if I'm trying to access something that doesn't exist, or I typo'ed the name, or if I'm trying to treat a String like a Date.
If you're using a good IDE, creating the members and even getters and setters shouldn't take you much time at all, and will be well worth it in maintainability, compile-time checking, debugging, extensibility, etc...
I don't totally disagree with what you say, but having your IDE auto-generate lots of code automatically for you gives me the heebie-jeebies.
The problem is that with a language as verbose as Java, you quickly have a bajillion files filled with far more characters than it should take just to define some property names and their types. Especially considering how having a public field in an object is a Java Mortal Sin.
I could go on, but Yegge has summed up the problems with generating mountains of code with an IDE, that then requires an IDE to move around, here:
Or pick a language in which the difference is an implementation detail, where an object defaults to a bag of data, but getters and setters can be transparently substituted when it becomes necessary.
If you have lots of objects that are just glorified structs, then you are factoring badly. I have been in lots of projects. Not all OO is like that. Apparently, yours is.
(Oh, and XML glue should be considered a "Framework Smell!")
How about object relational glue? JSON glue? HTML template glue? Google Protocol Buffer glue? (Sure I am missing lots of others.)
I do not know how you go about modern web programming without lots of glue that takes some square data and transforms it into some round data for some other piece of software, be it a browser, a client of your web service, a relational database that has data you cannot live without, etc. etc.
If functional programming is thriving, I feel that it's only because FP has been more honest with its goals, and has done a better job achieving them. FP is supposed to be mathematical in nature. It's uncomfortable to learn, but once you do, FP languages, for the most part, live up to their billing.
What is really needed is a new paradigm that is what OOP was supposed to be: programming that matches the patterns of human thought. In this respect, I think the author's suggestion of OOP-style modularization with FP-style pattern matching and function mapping is the future of programming.
It seems to me that since the advent of OOP hitting the mainstream, the world has seen more and better software than ever before, written by more people. So in what way is this a failure?
nobody understands it -> everybody scrambles to use it -> people start to get some benefit from it -> people overuse it -> people hate it and say it's dead -> people retreat to where it makes sense.
Objects are as dead as methods or loops. They're not super interesting anymore, they're just fixtures.
I agree that functional programming (while hardly new) will probably start to gain traction, similar to the cycle above. I think FP will also be a successful technology, eventually becoming a fixture in mainstream languages.
I wrote my first object oriented program a few years ago, and it seemed obvious that database fields would keep getting added, deleted and changed. My goal was to isolate this stuff from the rest of my program, not try to hardcode it everywhere.
I got a bit lost in all the buzzwords, but if that what his point, I agree.
Object Oriented Programming, as an all-encompassing paradigm that will solve all your problems if you faithfully and blindly devote yourself to applying it, and only it, anywhere and everywhere that you possibly can, is dying.
Hopefully, the notion that such a paradigm can ever exist will die with it.
(Also "X Considered Harmful" Considered Harmful!)
Same goes for table normalization.
One of the greatest things about experience is that you know when you should use the "proper" way of doing things and when you should make things work faster/better/more directly.
Look inside the Smalltalk image sometime. There is a clear attempt at OO everywhere for everything and it feels natural and unforced. (Well, it's about 70%, to be completely accurate, because there's also some functional and some OO newbie code in there.)
"proper" is all about cost/benefit tradeoffs, and it's very context-dependent. Expressing things polymorphically in an environment like Smalltalk, Python, or Ruby has low coding overhead.
Sometimes, it is just better to crank out an old-fashioned procedural routine and be done with it.
One of the key tradeoffs: Am I trapped, or will I be able to change my mind? So long as you can keep yourself from getting trapped, you're mostly safe.
I know what you mean, its just kind of sad that this is the case.
The problem with OOP is that it encourages the proliferation of mutable state. If each object has mutable state, then a large object-oriented program has distributed mutable state, potentially in hundreds of different silos. Problems like concurrency become impossible to reason about.
FP encourages the careful sequestration of mutable state. It's false to say that FP outlaws it entirely, since it's hard to do anything useful without side effects. However, functional style limits and sequesters mutable state to such a degree that it's usually easy to reason about what side effects are happening.
It should be pointed out that this is a characteristic of the languages and not actually OOP. The original insight, something like "Hey, let's bundle together data structures and their methods into one unit, and communicate with them via messages!" (which got turned into "method calls") actually has nothing to say about mutability. You can and people have build object systems based on immutable objects.
The implications of doing that are deep and profound and color the rest of the system and are beyond the scope of this posting, but it can be done.