Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any thoughts on multi-legged flights?

 
Jeff Wachhorst
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on an implementation of part II and ran into this-
In thinking about how you would come up with multi-legged flights, I've gotten stuck. My problem:
Say the user's departure city is S.F and arrival city is N.Y. My thinking is that you do the following:
1. Get all the flights departing from S.F.
2. Do any of them arrive in a city between here and N.Y.? If so, then for each of those cities, do steps 1 (substituting each city in between S.F. and N.Y. for S.F.) and 2 again. It sounds like recursion is certainly part of the solution. But this is the only piece of the solution that I can see so far.

From the first invocation of step 1, lets say you get 3 flights; S.F. to Milwaukee, S.F. to Denver and S.F. to Houston.
First question: Do you try to process all 3 at the same time or one by one?
If you do the latter, you take the flight from S.F. to Milwaukee. Now you do steps 1 and 2 again; get all the flights leaving Milwaukee, then of those, pick out the ones arriving in cities between Milwaukee and N.Y. Lets say there are 3; Milwaukee to Cleveland, Milwaukee to Chicago and Milwaukee to Philadelphia.
In order to build each multi-legged flight, you now need to add the S.F. to Milwaukee leg to each of these 3 flights. So, you now have 3 groups of two-legs. If I follow the strategy of trying to build each multi-legged flight one at a time, I go to Chicago and find out if there are flights
leaving there that go to cities between there and N.Y. Now its starting to get unwieldy; How am I going to keep all the legs organized? How am I going to assemble all the legs that I could be dealing with in an orderly fashion?
I've got to believe that a situation like this comes up in computing often enough that there is a known strategy for handling it; e.g. when you
have a 'trunk' with 3 branches and each branch has 3 branches and each of those branches has 3 branches etc., how do you build such a structure and how do you ensure that you can identify the components of each or any of what would be 27 separate 'lineages' (27 = 3 to the 3rd power).
Any comments/hints?
Am I WAY off?

Thanks in advance-

Jeff Wachhorst SCJP, SCWCD 1.4, SCEA Part 1
 
John Arau
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In an Oracle database you could do this...

find direct flights:

select a.id from leg a where a.from='SFO' and a.to='EWR'


Find flights with one overlay:

select a.id, b.id
from leg a, leg b
where a.from = 'SFO'
and b.to = 'EWR'
and a.to = b.from


Find flights with two overlays:

select a.id , b.id, c.id
form leg a , leg b , leg c
where a.from = 'SFO'
and c.to = 'EWR'
and a.to = b.from
and b.to = c.from

And so on...
[ May 22, 2005: Message edited by: John Arau ]
 
Thomas Taeger
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff Wachhorst:
[/QB]S.F

First, in an international forum it is a good and polite practice to give the full meaning of each abbriviation once.


Originally posted by Jeff Wachhorst:
[QB]Do you try to process ...

As an architect I do not try to process at this detail level but look at the scene more like a data modeller: which data is detail information like an "order line", and which data has to be accumulated like in an "order"? So for me it is a question of the business domain object model and class diagram. Do the others agree? (Don't be shy..., it's a forum)

Or do you [others] intend to provide interaction diagrams for these detail questions?


Originally posted by Jeff Wachhorst:
[QB][/QB](27 = 3 to the 3rd power)

Ok, if you fear to get an algorithm with a square or cubic effort (how to express in English?) this seems to become somehow relevant for the architecture too. Never the less I would delegate this warning to the detail designers and leave the decision up to them. That would be my decision because the decision directly affects the algorithm only and not the architecture.

Best regards
tomte.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic