|
Jeremy Falcon wrote: three four major aspects to OOP
The fourth one (first one?) - I got to learn from a candidate I was interviewing, Abstraction.
|
|
|
|
|
To me that's closely tied to encapsulation.
Jeremy Falcon
|
|
|
|
|
In C#, I relate it to Inheritance as in the case of abstract classes.
I say, we stick to three aspects!
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Careful... "Aspects", as in AOP, are totally different than OOP.
|
|
|
|
|
Abstraction is closely tied to encapsulation, but different enough from an architectural viewpoint.
Abstraction is the design of the class to be an abstract representation of some real world object (Person, Car, Critter, etc.). That is how the class interface is designed.
Encapsulation is how the implementation is encapsulated within the class, and not exposed.
I can abstractly represent a car as a Car class. The GasPedalPercentage property or the Start function have code behind the interface elements, which is encapsulated within them to abstractly produce their real world counterpart.
I understand that a lot of programmers may, in practice, do abstraction and encapsulation as one. But for me, it helps to use abstraction in the design work, and encapsulation in the implementation coding work.
|
|
|
|
|
No; there are only the three he listed.
|
|
|
|
|
Your answers are all fair, just remove that C++ tag. Object-oriented is not paradigm of C++ only. Anyways, I would change the routine of that list.
- Encapsulation.
- Inheritance
- Polymorphism.
Because the later one (somewhat) depends on the former one.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
What I really want to say to the interviewer is only n00bs use OOP, functional is where it's at. WTF bro.
Yeah, I'm passed the immature epeen phase, I'd just want to see what they'd say.
Jeremy Falcon
|
|
|
|
|
True words, OOP ain't worth it!*
*Says the person who uses C#, Java and C++ only.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
That means that there's a collission if I find another God-object after the interview.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
There can be only one.
Jeremy Falcon
|
|
|
|
|
Polymorphism: the ability to take on the shape of any person, big or small.
Inheritance: the money I got when great aunt Matilda popped her clogs.
Encapsulation: covering oneself in peanut butter and nutella to hide from the boss.
Abstraction: sorry, I wasn't listening to your inane questions...
|
|
|
|
|
R. Giskard Reventlov wrote: Abstraction: sorry, I wasn't listening to your inane questions... Niiiiiice
Jeremy Falcon
|
|
|
|
|
What about open recursion?
My teacher always had five 'pillars' for his OO; definitions simply vary, and wikipedia can not have the last word.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Your teacher favored a fifth? It shows.
|
|
|
|
|
Tx
|
|
|
|
|
Eddy Vluggen wrote: What about open recursion?
Didn't we already talk about that?
|
|
|
|
|
What? Did we discuss on .this or SO?
|
|
|
|
|
I'm not going to go over it again!
|
|
|
|
|
I might reply:
"Well, that depends on what you consider OOP is; are you referring to the concepts of C.A.R. Hoare, or to the work of Dahl and Nygarrd, or to the refinements proposed by Sutherland, or to Alan Kay, and the refinements of Kay's work by Goldberg et. al. ...
or, are you referring to the almost meaningless collage of associations and usages bandied about like a shuttlecock by the digerati of today ?" [^]
... of course, if you don't several hours to plumb that deeply, we could move on to the next question ...
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
I like to use non-programming examples when describing abstract principles.
This is how I usually explain these three areas:
polymorphism
A vehicle can have one wheel, two wheels, three wheels or more. Passengers in a vehicle can also be encased in a shell or in the open.
Power steering assists the steering wheel so that the steering wheel behaves differently at high vehicle speed in contrast to slow vehicle speed.
inheritance
A car is a vehicle. By telling people that a car is a vehicle they will know that it is a form of transport.
encapsulation
I don't need to understand everything about how an engine works to drive a car. I just put my foot down on the accelerator pedal and I know that the car will accelerate.
[edit - corrected polymorphism analogy]
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 30-Jan-16 16:26pm.
|
|
|
|
|
That's a good idea. I like the last two examples especially.
Jeremy Falcon
|
|
|
|
|
Thanks - I find it helps me if I can associate abstract principles with things I understand at least a little bit about.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Sounds good, but I think you meant method overriding (override default behavior with behavior specific to a derived class) and not overloading (provide an alternate signature for a method).
/ravi
|
|
|
|
|
I meant the latter. But both would provide an example of polymorphism in my book.
Jeremy Falcon
|
|
|
|