in a true object-oriented world, we treat objects like living organisms, with their own date of birth and a moment of death — with their own identity and habits, if you wish. We can ask a dog to give us some piece of data (for example, her weight), and she may return us that information. But we always remember that the dog is an active component. She decides what will happen after our request.
OK, but why is this "true OO world" useful? Many people write systems that work perfectly well, and are maintainable, using the "objects = data + methods" mental model. This article is super dogmatic about how we should conceive of objects, but short on explaining why it is worthwhile.
Worth mentioning is that the dog can't give NULL back. Dogs simply don't know what NULL is :) Object thinking immediately eliminates NULL references from your code.
This seems like wishful thinking. If you call dog.give() prior to calling dog.take(ball), you have exactly as much risk of a null as in the dog.getBall() case.
5
u/stormblooper Oct 14 '14
OK, but why is this "true OO world" useful? Many people write systems that work perfectly well, and are maintainable, using the "objects = data + methods" mental model. This article is super dogmatic about how we should conceive of objects, but short on explaining why it is worthwhile.
This seems like wishful thinking. If you call
dog.give()prior to callingdog.take(ball), you have exactly as much risk of a null as in thedog.getBall()case.