aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes How is the segment implemented ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "How is the segment implemented ?" Watch "How is the segment implemented ?" New topic
Author

How is the segment implemented ?

Rolando jimenze
Greenhorn

Joined: Sep 22, 2006
Posts: 3
Hi all,
I'm writing my assignment for part II. I have come across the definition of Segment. I understand that a Segment has a 1 to 1 relation to a Flight, but how do you implement it in practice ?
Is it implemented by a plain JavaBean which holds information about the flight ? in other words when the client looks for a flight, system returns an Enumeration of Segment....

is it right ?
thank you
rol.
Newman Huang
Ranch Hand

Joined: Mar 31, 2003
Posts: 85

when the client looks for a flight, system returns an Enumeration of Segment


you have said that the relationship between fligh and segment is one to one. why does it return an enumeration of segment after searching a flight? i think you still need to make clear what the real business meaning about flight and segment. not only their relationship. the problem of flight&segment is a PO topic in ranchers forum. you can use the searching function to find them.


SCJP,SCJD,SCEA
Rolando jimenze
Greenhorn

Joined: Sep 22, 2006
Posts: 3
Hello,
thanks for your reply.

Well I was meaning that when search is performed, multiple flights are found (for example 5 flights on that day), so a Collection of Segments are returned to the user.

The user select which flight (=Segment) wants to buy. Each flight corresponds to a Segment.

Did I understand correctly the business model ?

Thanks
rol
Newman Huang
Ranch Hand

Joined: Mar 31, 2003
Posts: 85
try this:
real life example

yes, it is need to create VO for displaying of search result.
Francesco Marchioni
author
Ranch Hand

Joined: Sep 22, 2003
Posts: 190
I think he asked if the Segment is "mapped" as Value Object, transferred from the system when the search is performed. I have implemented too as value object both from the server side (Collection of VO returned after search) and from the client side (VO chosen in the list of flights).
Anybody wants to join the discussion ?
bye
Francesco


WildFly 8 Administration Book - JBoss Tutorials
Sharmila Rishi
Greenhorn

Joined: Oct 11, 2006
Posts: 20
How will you know which segments form the departure trip and which ones form the return trip?
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
Dear Newman Huang

Thank you so much for providing the real life example.
It really helps me understand how to book tickets in real life.


Steve Taiwan<br />SCJP 1.2, SCJD 1.4, SCWCD 1.3, SCBCD 1.3, OCP 8i DBA, SCEA
sai maddikay
Greenhorn

Joined: Jul 03, 2006
Posts: 14
here is my understanding...

An Itinerary must have at least 1 segment (Min. one-way i.e. a direct flight (can have more than one segment if not a direct flight))

Itinerary: includes everything from start to end.

When the user does a search; the search result could be a Collection of Itinerary objects each associated with a segment or collection of segments;

Round Trip:
Each Itinerary will have information about onward (could have > 1 segments) and return trip (could have >1 segments), [how this is generated i.e. different combinations depends on business logic]
To figure out the return flight you can maybe check the Airport codes (against the user input) and also possibly the Dates.

Let me know if anyone has any other ideas...
thanks
sai
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
My class diagram and sequence diagrams are exactly the same as what sai explained.

Regarding the VO and TO, in my class diagram and sequence diagrams, Itinerary, Segment and Flight are all VO.
And I am also thinking whether I shall have ItineraryUtil to contain some business logic, like 'calculation of total price'.
However, another way to do something like calculation of total price is to put the calculation algorithm in ItineraryVO because
ItineraryVO is the knowledge export who knows all prices. Doing this might make ItineraryVO unlike VO.
I don't make my mide yet.
Andrew Zilahi
Ranch Hand

Joined: Oct 16, 2006
Posts: 47
Sai,
I've been considering same approach as you. The search API returns a collection of itineraries. Assuming it's 2 way trip, user selects 2 of these. After final confirmation, these 2 itineraries will then be assembled into an itinerary attached to customer and possibly persisted?
At this phase of design I'm not involving any technical details such as TO or VO...

thanks,
Andrew


--------------------------<br />SCJP,SCJD,IBM XML, SCEA 1
Andrew Zilahi
Ranch Hand

Joined: Oct 16, 2006
Posts: 47
Also, using Itinerary as the search result has an issue, unless you change the BDM: itineraries returned by search *must* have at least 1 seat attached (acording to cardinality Equippment - Seats).
I interpret the "Seats" object in the BDM as the seats booked as part of prepare itinerary use case.

Am I missing something?

Thanks!
Andrew

ps
the plural in "Seats" also doesn't make sense...
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
Dear Andrew Zilahi

In my design,
An ItineraryVO could have many segments to complete a round trip.

Segment Class has 2 special attributes for GUI layout control, groupId and sequenceId. GroupId attribute means these segments with the same groupId must be combined to become a complete short distance trip. SequenceId attribute means these segment swith the same groupId should be displayed in the order which is indicated by sequenceId.
Another attribute, isReturn, indicates that this segment is for departure or for return trip.

Here is the example of segments in an Itinerary for a round trip.
groupid sequenceId isReturn departure destination
segment1 1 1 N Taipei Hawaii
segment2 1 2 N Hawaii New York
segment3 2 1 N Taipei Hong Kong
segment4 2 2 N Hong Kong New York
segment5 3 1 Y New York Detroit
segment6 3 2 Y Detroit Taipei

Help?

[ October 23, 2006: Message edited by: Steve Taiwan ]
[ October 23, 2006: Message edited by: Steve Taiwan ]
Andrew Zilahi
Ranch Hand

Joined: Oct 16, 2006
Posts: 47
Steve,
This is great. I just have a couple commebts though:
1.Segment belongs to the BDM, and hence should have no attributes/methods that are technology/GUI specific; you could wrap it though in a VO...
2. Segment mandates the existence of at least 1 seat, according to the BDM diagram. How would you handle it? There are no Seats assigned to your customer at the time the first search returns the result?

Thank you,
Andrew
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
Dear Andrew.

According to the BDM, Segment has Flight, Flight has Equipment, Equipment has Seat
so Seat can be associated with Segment. Also Itinerary has many Segments so an Itinerary can
have many Seats without doubt. My Seat has some interesting attributes, like location, customerId, status.
Location, such as J22, is the exact loction in an Equipment. CustomerId is for query purpose and makes Seat
associated with Customer directly. Status means whether the specific Seat is available, occupied or something else.

At the first search, no Seat will be assigned to the Customer who makes the query.
Andrew Zilahi
Ranch Hand

Joined: Oct 16, 2006
Posts: 47
Steve,
You just mentioned that initially you don't assign any seats as a result of the search. This is not possible due to cardinality (Equipment mandates it).
Also, you shouldn't have to add Customer attribute to seat, as Customer will be associated with Itinerary directly, and hence you hane the relationship from there.
I am considering using custom request/result objects for the search to keep the model clean.

thanks,
Andrew
[ October 24, 2006: Message edited by: Andrew Zilahi ]
Steve Taiwan
Ranch Hand

Joined: Jul 01, 2003
Posts: 166
Dear Andrew.

In prepare itinerary, customer selects seats in step 7 but not in the first query.

If Seat doesn't have customerId, how do you know the relationship between Customer and Seat?
The requirement said RDBMS will be used. So when you do OR mapping, you should have a attribute in Seat to indicate that
the specific seat number is occupied by the specific customer. Otherwise, I don't know how to retrieve the data from DB to Seats in doing OR mapping.
Andrew Zilahi
Ranch Hand

Joined: Oct 16, 2006
Posts: 47
Steve,
In this phase, you should *not* be concerned about the technologies used for the implementation (i.e. RDBMS, J2EE, etc). You just want to create a clean domain model first. Once this is done, you can think about how to wrap and persist these objects, as well as how to render them.
To answer your question, as long as Itinerary object is connected to customer, your relationship is right there.

I'm still puzzled about the best approach for returning the search results, so I am going to post a new topic for this.

rgds,
Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How is the segment implemented ?
 
Similar Threads
A question about part2
what do segment and leg mean?
Passed SCEA II/III
Route - Flight - Segment again.
Cade's BDM & Class Diagram