I have a question in my work,please help me!

Looks suspiciously like an instance of the pattern "do my thoughtworks
code review for me"

Almost word for word....

:wink:

I manage it with another method ,but i is still wrong.The code is:

def exa_stops
exa_with_stops(params[:ss1],params[:es1],params[:stops],0)
end

private
  def find_route(s1,s2)
    start_routes=Route.find_all_by_start_station(s1)
    end_routes=Route.find_all_by_end_station(s2)
    middle_array=Array.new
     for s in start_routes
       for e in end_routes
        middle_array<<s.name+e.name
        end
      end
      pair_group=middle_array
    if pair_group.length !=0
     for p in pair_group
        pair_group.delete(p) if p[2,1]=="A"
     end
     return pair_group
    end
  end

  def route_with_onestop(s1,s2)
   Route.find_by_name(s1+s2)
  end

def exa_with_stops(s1,s2,esn,n)
if $exastops_array.include?(esn)
  @part_of_exastops_array=Array.new
  $exastops_array.each{|e|@part_of_exastops_array<<e if e==esn}
  return @part_of_exastops_array.length
else
  pair_group=find_route(s1,s2)
  @n=n
  for p in pair_group
   if p[1,1]==p[2,1]
    s=2+@n*2
    $exastops_array<<s
    exa_with_stops(p[1,1],p[2,1],esn,@n+1)
   elsif Route.find_by_with_name(p[1,1]+p[2,1])
    s=3+@n*2
    $exastops_array<<s
    exa_with_stops(p[1,1],p[2,1],esn,@n+1)
   else
    exa_with_stops(p[1,1],p[2,1],esn,@n+1)
   end
  end
end
end

You may want to start over with some heavy BDD.

I do not know your means.Anyone can help me?

Keynan Pratt wrote:

http://www.youtube.com/watch?v=oOFfHzrIDPk&feature=related

You should be able to modify this pretty easily to get you the routes
from any given starting point to any given ending point at a set
distance.

Lets assume this is rails and not just ruby Were working with.

Guo,

How about setting up a table of the stations and then a table of the routes that has a serialized field containing the ids of the stops along the way (something like stops_id)?

hello:
   Thank you Ryan Bigg and Keynan Pratt ,i have resolve my question.Maby
if i modify my database table ,i can do it .I will try it.I have managed
it in my method design in another way.Thank you!Good luck!

Ryan Bigg wrote: