2 ms·
I've been programming for 15 years (so I was around for the rise of OOP). There's nothing fundamentally wrong with OOP. I still write a lot of classes. But what
by hliyan 8y ago
I've been programming for 15 years (so I was around for the rise of OOP). There's nothing fundamentally wrong with OOP. I still write a lot of classes. But what I haven't written in a almost a decade: code with inheritance, encapsulation or polymorphism. Nothing has exploded.
Also, objects are best when used to represent actual objects (i.e. collections of data rather than collections of functions).
This is OK
User user = new User("John");
But this:
StringTokenizer st = new StringTokenizer(str, ",");
while (st.hasMoreElements()) {
System.out.println(st.nextElement());
}
Might not be as clean as:
stdout(tokenize(str, ",")); // functions are hypothetical
- scarface74 8y agoI was about to reply in C# that would usually be done with LINQ, but then I realized I kind of just proved your point since LINQ is functional programming not OOP....
- _old_dude_ 8y agoThank you for posting this snippet of code, to me, it acts like the episode of the madeleine in the Swann's way. as you said, nowadays people are using String.split ``` List.of(str.split(",")) `` which is less poetic.
- theprotocol 8y agoExcellent examples. Minimalist OOP can be beautiful, but over-abstraction e.g. `FactoryObserverFactory` is absolutely disastrous.
- naasking 8y ago> Also, objects are best when used to represent actual objects (i.e. collections of data rather than collections of functions). Except these aren't objects, they're just records. I don't think it's a good idea to pollute the word "object" or OOP. You use objects specifically when you need procedural abstraction, otherwise you use other types of values, like products/records, sums/variants, etc. At high system levels, where you have client/server or other types of protocols, objects fit. At lower levels other paradigms tend to be better.
- u801e 8y ago> Also, objects are best when used to represent actual objects (i.e. collections of data rather than collections of functions). This reminds me of a certain blog post about Java flavored OOP[1] [1] https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...