3 ms·
> The problem with the example of Rex the Dog is that classes are not about being able to represent your dog. It's about something completely different. Encapsu
by ozim 5y ago
> The problem with the example of Rex the Dog is that classes are not about being able to represent your dog. It's about something completely different. Encapsulation, modularization, abstraction - let's not pick nits about the precise meaning of these terms, they are all about the same thing, really: Managing complexity of your own code.
Author is also missing a big part of explanation here.
Real problem is that you won't have one dog, you will have hundreds of dogs with different attributes and you want to make them bark at each other.
When you have to implement bunch of running dogs - then you hit encapsulation, modularization and abstraction. Those properties are not some kind of given especially in example presented, but for me question "how can I make 100s of dogs" comes naturally.
So in the end author really misses Object vs Class distinction and I can see it in the writing. Author equates Object and Class where in reality Object is an instance of a Class in run-time, so you make "Rex" and "Lassie" dogs which are Objects in your program and can bark at each other. Classes cannot do anything as those are simply templates for creating Objects, you cannot do operations on a Class.
So below sentence is simply wrong:
> You have now defined a Dog class and can do operations with your dog by simply writing