Hi Just interested in anybody''s opinion on the following: I have one model class called Diagram, that contains a number of Node classes (ie 1-many relationship). One of the Node classes must be the start node. Which would be better: 1. Attribute in Diagram class called StartNode containing id of the start Node. 2. Boolean attribute in Node class called StartNode? and set to true if its the start node. Would be interested in knowing the ''Rails'' way of doing this :) Cheers Jason -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 22 August 2012 19:37, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > > Just interested in anybody''s opinion on the following: > > I have one model class called Diagram, that contains a number of Node > classes (ie 1-many relationship). One of the Node classes must be the > start node.Some questions: Are the other nodes in a sequence or is it just the start node that is special (in other words could you link from node to node)? I am not saying you should do that, just asking the question. Is the start node considered by the Diagram to be different from the others, or is just that it happens to be the start one (whatever that may mean)? Is the node intrinsically a start node, in other words is there something special about it, or is it only from the point of view of the Diagram that it is node of this type. Or to put it another way are there nodes of two types, ''start'' and ''ordinary''? Colin> > Which would be better: > > 1. Attribute in Diagram class called StartNode containing id of the > start Node. > > 2. Boolean attribute in Node class called StartNode? and set to true if > its the start node. > > Would be interested in knowing the ''Rails'' way of doing this :) > > Cheers > > Jason > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Without thinking about it too much I recommend your first suggestion. It just seems cleaner to me. On Wed, Aug 22, 2012 at 2:37 PM, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > > Just interested in anybody''s opinion on the following: > > I have one model class called Diagram, that contains a number of Node > classes (ie 1-many relationship). One of the Node classes must be the > start node. > > Which would be better: > > 1. Attribute in Diagram class called StartNode containing id of the > start Node. > > 2. Boolean attribute in Node class called StartNode? and set to true if > its the start node. > > Would be interested in knowing the ''Rails'' way of doing this :) > > Cheers > > Jason > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
I second this opinion, my argument being it will be more difficult to maintain the second approach, because you''d have to ensure there is only 1 of these per diagram at any one point. If starting points can change around (they probably will in the future if it ain''t so yet), then you can get yourself into extremely hard to diagnose bugs. While with the first option you at worse will have an incorrect starting node, which you can fix with either DB or Rails console even. 2012/8/23 Charles A. Lopez <charlesalopez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Without thinking about it too much I recommend your first suggestion. > > It just seems cleaner to me. > > > > On Wed, Aug 22, 2012 at 2:37 PM, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Hi >> >> Just interested in anybody''s opinion on the following: >> >> I have one model class called Diagram, that contains a number of Node >> classes (ie 1-many relationship). One of the Node classes must be the >> start node. >> >> Which would be better: >> >> 1. Attribute in Diagram class called StartNode containing id of the >> start Node. >> >> 2. Boolean attribute in Node class called StartNode? and set to true if >> its the start node. >> >> Would be interested in knowing the ''Rails'' way of doing this :) >> >> Cheers >> >> Jason >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Pagarbiai, Gintautas -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.