Earlier quoted context omitted.
You hit the nail on the head. Objects in OO shouldn't be a projection of the problem domain, they're a way to structure the program (there's some overlap, of course). Many people seem to get this wrong, probably in part due to introductory examples doing it wrong.
I suppose you disagree with Eric Evans method of Domain Driven Design (DDD - http://domainlanguage.com/ ) Don't people who practice DDD, including Martin Fowler, commonly talk about the benefits of some of it's concepts, while modeling the Domain using Aggregrate Roots, Bounded Contexts, etc?
Anthropomorphism Gone Wrong: OOP
31–40 of 64 posts
Re: Anthropomorphism Gone Wrong: OOP
#32Bad programmers write bad programs. It's not methodology. Good programmers have successfully written a lot of software in an OO design. That doesn't mean OO is the best solution for you , it just means that you can't judge a book by its cover, and in this industry, we're covered in bad programmers.
Disagree! If a programmer is good or bad is not a quality separate from how they actually develop programs! A good programmer is good because they choose appropriate tools and methodology etc.
I interview developers for positions all the time. Out of every 10 I interview, one can't write a basic "Hello, world" program that actually compiles, in the languages they list in their resume, on their own computers. About 7 or 8 more can't even close a database connection or file handle correctly. I can go a year and meet one, maybe two developers I would trust to write code in any methodology, in any programming language. And they usually have jobs they like and don't want to leave.
Projects don't fail because someone chose OO. They fail because most people claiming to be developers suck.
Re: Anthropomorphism Gone Wrong: OOP
#33I’ve spent quite a few years coaching and dealing with developers with a heavy electronics background work in OO/C++ environments and I came to the conclusion that they would be more comfortable and competent in C. All smart people but the bells and whistles of C++ AND OOP just was confusing.
I’m surprised at some comments here claiming that OO is ‘friendlier to the programmer’, I would put money on the average developer being able to work their way around even the Linux kernel quicker than a comparably sized C++ code base with all it’s OO goodness.
What OOP was trying to solve back in the day was and still is a real problem but it annoys me how many additional problems ‘full blown’ OOP introduces.
Re: Anthropomorphism Gone Wrong: OOP
#34"[OOP] just organized in a more systematic way." Managing complexity and abstraction is a main function of programming. How is having a simple, consistent, systematic way to organize complexity not an advantage?
Re: Anthropomorphism Gone Wrong: OOP
#35Like many people I went through an "objectify all the things!" phase, but now I find myself moving more and more to stateless service layers, which ends up looking like old-fashioned procedural code coated with a sugary OOP shell. Encapsulation and inheritance and stateful objects have their place, but the "object" metaphor can really lead down the wrong path when taken too literally (as it is in practically every co…
If I don't explicitly need "state" (user-data in models or GUI-state in view-models) I leave it out. Most of the time I use classes and their objects as a stateless bag of related methods. Like namespaces...
On a somewhat related note, http://www.newspeaklanguage.org uses classes for all kinds of things, including namespaces.
Re: Anthropomorphism Gone Wrong: OOP
#36This is the kicker. In most large projects(100k-million+ loc) the largest issue is complexity. Object oriented programming is just systematic way to organize that complexity.
The OP says that "In production code, I would split it in several files as appropriate. Or not. It doesn't really matter. What does matter is that we can easily find those procedures whenever we want to inspect or modify them."
It 100% does matter, and having all procedures that operate on and change the state of an object in the same file is super helpful. Being able to make guarantees that certain state cannot be changes outside of the organization unit of the class(encapsulation) is super helpful. Being able to abstract over certain related but non identical functions without having to resort to switch statements is super helpful.(polymorphism) And the ability to reuse code when different pieces of data share some identical features and we want to abstract over a portion of those features is useful(inheritance).
OOP doesn't give you any abilities you didn't have before, and you can write great readable structured procedural code. But it does give you more tools in your tool box that when used correctly can help structure your code in a way that limits the burden of the software's complexity.
Re: Anthropomorphism Gone Wrong: OOP
#37I think the procedural option is better. It is just so much less code.
After a while you realize that you're doing all this stuff to 'bad' students. This is where you really start to want some way to organize all the stuff you're doing to these bad students, as all the code you have dealing with them is sprinkled liberally through the codebase in conditionals in your procedures.
You'll start pulling out logic and things will start breaking. What you thought was less code is just crazy to manage.
The Gilded Rose kata illustrates the dangers of procedural code excellently.
http://craftsmanship.sv.cmu.edu/exercises/gilded-rose-kata
Sandi Metz has an excellent discussion on using OOP to improve the design of a codebase.
http://www.confreaks.com/videos/3358-railsconf-all-the-littl...
Re: Anthropomorphism Gone Wrong: OOP
#38When your objects act more like very lightweight processes ala Smalltalk or Erlang model that communicate with each other via messaging, OOP becomes a lot more than a "coat of syntax sugar over the procedural cake" and anthropomorphism sudden works very well. If you see objects as data structures with methods rather than isolated processes with message based interfaces (think actor model), it's not all that surprising anthropomorphisms don't add much value. However, when your conceptual model of objects implies each object is a concurrent and isolated process, anthropomorphisms make sense. I sometimes even give them names and imagine them as employees in an organization. Asynchronous communications can be conceptualized as inboxes and outboxes of messages and synchronous communications can be thought of one employee getting into a queue himself to personally deliver the message.
Sometimes metaphors translate surprisingly when you become a stickler for making sure all aspects of a metaphor are accounted.
Re: Anthropomorphism Gone Wrong: OOP
#39Earlier quoted context omitted.
If I don't explicitly need "state" (user-data in models or GUI-state in view-models) I leave it out. Most of the time I use classes and their objects as a stateless bag of related methods. Like namespaces...
IMHO classes are a "jack of all trades, master of none". They're sort of like namespaces, a bit like modules, kind of like closures, somewhat like types, almost like first-class functions, etc. On a somewhat related note, http://www.newspeaklanguage.org uses classes for all kinds of things, including namespaces.
But I have to admit, the dynamic properties of objects make them much more versatile than namespaces or modules.
If I would use them only as namespaces, by defining every of my (stateless) methods static, they would work exactly as a namespace. But when they're bound to an object instead, I can switch out implementation details easily when needed. So I would consider classes and their objects to be a more powerful version of namespaces.
Re: Anthropomorphism Gone Wrong: OOP
#40I was disappointed by this article in the end. I was ready for a good old fashioned OOP bash, supported by strong opinions and examples. We should always remain open to new (or old, in this case!) patterns. Instead we get a "tie" given a very simple (not real world) example. In the end I'm left with the same conclusion. Given that there is no obvious performance gain from a procedural approach, I would opt for a desi…
I was also disappointed by the atricle's end: Pretty much only the Dijksta quote was worth reading. The title promised to backup the claim with a real-world experience of OOP, but alas, it did not deliver such. OOP is better where you code more readably(in comparison with procedural) and where it makes you enjoy coding more. The conditions for when it does that differ from persons to person and from project to projec…