--
You received this message because you are subscribed to the Google Groups "Objects on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objects-on-rai...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
My view of a "family tree" data model would have a single class representing a person; having separate classes for "father", "mother", and "child" seems redundant and counter-OOP. People have properties, and that's it.
--
On Jun 21, 2013 11:27 AM, "Hugo Estrada" <hugo...@gmail.com> wrote:
>
> Your goal is pretty cool. I have done something similar in the .NET world, but not as well defined as you describe it. I do like it how the gem concept makes it even tidier. In one .NET project my lead and I just gave up on a relational persistence and just saved the objects themselves.
>
> If your quest is to understand inheritance, then this project may not be the best one. As others said, you essentially have one object, a person, that has relational links to others.
>
> Inheritance in OOP is more about sharing common data and methods between two different but similar objects. It is hard to come up with a good exercise for it. Try finding some domain, such as a racing game with different cars with different attributes, or simulating IC chips, or model an RPG character and its different classes.
I believe that you could also split factory objects and the human relation behavior by having a person class for your factory and use modules for each side of a relation.
module Aunt
attr_accessor :nieces, :nephews
... I'd add code for event listeners and emitters here to handle linking family members to the rest of their tree here.
end
This does suck in the way that it'd assume you want to mix this module into the person instance rather than the class. I'd also consider if this was worth doing, questioning whether there are many Aunt-specific behavior, if there isn't, I'd also posit that multiple classes would also not be a good way to compose your domain objects.
>
> In my personal experience inheritance for business applications seems to be rarely needed, but if you do have the need for it, then it is a powerful concept.
I like to treat classes as factory objects primarily and not as a means of describing my object inheritance, but I also prefer modules, so the bias is fairly clear.
~Johnneylee
--
My question is, how is this message passing working?
Passing attributes around. I heard someone call it "passing messages around" in Ruby. Not so sure why but it could be say Company.new('Google Inc.').should respond_to :nameSo #respond_to checks that Company understands the message :name.
Inheritance in OOP is more about sharing common data and methods between two different but similar objects. It is hard to come up with a good exercise for it.
tenderlove I met a guy who really preferred inheritance over composition. He was a super man. 6/14/13 1:59 PM |
--
--
You received this message because you are subscribed to the Google Groups "Objects on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objects-on-rai...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
Hi yall,I am trying to achieve a feat with Ruby that I have not ventured before. I read a blog by Jose Mota about entitled "Extract your business" and in the article he asks "Why isn't your business a gem of its own?"So I embarked on a simple lesson to see if I could write the business logic into a gem and forget relying on Frameworks that are constantly changing and breaking the business model of an organisation.So my quest is simple. I want to write a gem I called my_tree which details "My Family Tree". With just pure Ruby and Rspec for tests without ORM's or Persistence. My quest is to understand Inheritance and how to write better code and use Ruby Structures/Modules etc to create Associations/Validations like AR in Rails.
Hey Brian.
Thank you for this.
--
You received this message because you are subscribed to a topic in the Google Groups "Objects on Rails" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/objects-on-rails/3KU8rN_jZFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to objects-on-rai...@googlegroups.com.