Reference pointer or Boolean attribute

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 :slight_smile:

Cheers

Jason

Without thinking about it too much I recommend your first suggestion.

It just seems cleaner to me.

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 [email protected]

Just interested in anybody’s opinion on the following:
2. Boolean attribute in Node class called StartNode? and set to true if


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Pagarbiai,
Gintautas

On 22 August 2012 19:37, Jason W. [email protected] 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