Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Ron McLeod
• Paul Clapham
• Jeanne Boyarsky
• Liutauras Vilda
Sheriffs:
• Rob Spoor
• Bear Bibeault
• Tim Cooke
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Piet Souris
Bartenders:
• Frits Walraven
• Himai Minh

# Distance between two Airports

Greenhorn
Posts: 25
• Number of slices to send:
Optional 'thank-you' note:
How is the distance between two airports obtained? As far as I could see, there are 2 options

1) Distance is calculated based on the co-ordinate/location of the two air-ports. So, in this option, there will be a SLSB which will take the location specific details of two air-ports, calculate the distance.
Pros : easy to maintain
Cons : consumes a few CPU cycles/time every time we need to calculate the distance. This could be improved by introducing server level caching though.

2) Database will have distances between all possible combinations of air-ports.
Pros: Better performance
Cons : Maintanance nightmare for DBA, as for evey new air-port, we have to get the distance between this air-port to all other air-ports in the database and make an entry in DB. Since we do not get to add a new air-port often, so it should be OK.

Ranch Hand
Posts: 88
• Number of slices to send:
Optional 'thank-you' note:
A dumb programmer like me would first ask you ...

1. When you say co-ordinates what is my (0,0)?.So to find out the distance between two points from point A to point B what would be my minimum path?...man you are asking me to solve a critical path problem...

:roll:

I am just not qualified enough .. get somebody else

2. If the min distance between two points(which normally does not change) is kept in a DB, I would look for a session bean which can query an entity bean which refers to a table containing point A ref, point B ref and distance(a primitive).I can find the ejb ...easily...!! and use the session bean ( which should be stateless) to get my results ..go home and sleep happily in my couch

Now if you say ..you should know that the number of rows are too many !! .. I would say .. then why do you have an EJB container ???Those guys should take care of it ...right ???

..let me know what you think about it...

Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:
Thanks a lot Bose. I am in agreement with you, not because it is difficult to program the distance between two points, but for the better performance. And also due to the fact that we don't get to add new air-ports probably in years.

Sheriff
Posts: 5782
• Number of slices to send:
Optional 'thank-you' note:
I am not sure why you need this to solve the assignment? If it is to calculate the fare, remember that the fare has no bearing on the distance. A trans-continental flight from NYC to LA can cost less than a commuter flight from LA to Las Vegas. Pricing is complicated and your assignment is not expected to address that. In real life, pricing depends on various factors such as how soon you book, how full the is the flight, the class, the time of the year and so on.

Good luck,

Rama Bhargav
Greenhorn
Posts: 25
• Number of slices to send:
Optional 'thank-you' note:
Thank you Ajith. I was carried over by the CEO comments wherein he indicates the pricing is simple, varies based on destination. Now I see your point.

I have one more question. What is "four 9's"? I know 24/7 but never heard four 9's.

Rancher
Posts: 43024
76
• Number of slices to send:
Optional 'thank-you' note:
Four 9s means 99.99% uptime (Five 9s would be 99.999%).

Rama Bhargav
Greenhorn
Posts: 25
• Number of slices to send:
Optional 'thank-you' note:
Thanks a lot Ulf.

Ranch Hand
Posts: 224
• Number of slices to send:
Optional 'thank-you' note:
On the side note, if you want to calcuate the distance between two airports, you just need a utility method, SLSB is just an overkill.

 You showed up just in time for the waffles! And this tiny ad: Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton