P
Paul A.
Hello,
I have a general question about OOP with Ruby. If I have 2 class: Home
and Person for instance, such as:
Then, a home instance can include a lot of people. And that's cool. And
a home instance can apply action on a person using a method just like:
@person2.play_wii_game
But if a person want to open a window in its home? Here, with a such
design it's impossible, isn't it.
So to allow this kind of action, I think we need to pass as parameter
self inside Home initialization process, becoming:
Now, a instantiated person can do it using open_a_window proxy method.
And any other proxifyable home's methods.
But is it ethics? I mean, is that lawful under the principles of
object-oriented programming. Maybe this is so much power, to pass self
inside person instance inside its home... 'cause it's almost as if there
was no class, no partitioning.
What do you think about this?
Thanks for any considerations.
I have a general question about OOP with Ruby. If I have 2 class: Home
and Person for instance, such as:
Then, a home instance can include a lot of people. And that's cool. And
a home instance can apply action on a person using a method just like:
@person2.play_wii_game
But if a person want to open a window in its home? Here, with a such
design it's impossible, isn't it.
So to allow this kind of action, I think we need to pass as parameter
self inside Home initialization process, becoming:
Now, a instantiated person can do it using open_a_window proxy method.
And any other proxifyable home's methods.
But is it ethics? I mean, is that lawful under the principles of
object-oriented programming. Maybe this is so much power, to pass self
inside person instance inside its home... 'cause it's almost as if there
was no class, no partitioning.
What do you think about this?
Thanks for any considerations.