Which Classes Methods to create?
class, java, methods
Solution
The methods you outline appear to be more suited towards being on a service.
The idea is this: you want to separate your concerns.
One concern is modeling the data. That means creating a container for your data, with methods that make sense to manipulate the data. You can create a base class `FlightData` and a subclass `BritishAirwaysFlightData` if it makes sense (if the data doesn't change from airline to airline, then you just need a generic object). Looking at your methods, it might make sense to have a class for `Airport` and `Flight` as well.
Another concern is getting your data. So you probably want a class that does nothing but interact with the source of the data. These classes are typically called Data Access Objects (DAOs).
The service is yet another class that will use the data access class and the data model class together to perform a unit of work.
So think about the method `getSourceAirports`, which I will assume means 'get all airports from which a flight originates'. If you have a data model called `Flight`, you can envision that this class would have `departureAirport` and `arrivalAirport` fields (as well as others). To get the source Airports, you would query your datasource for all unique departureAirports found in the Flight table (corresponding to the Flight class).
Problem
I'm looking to create a test application which can check various flight information from an airline provider I'm struggling with the concept of classes and methods and which ones to create. My current thought process is as follows: The data is downloaded from a website, due to the size of data, I only want to download the data once. My current thinking is: Class ``` BritishAirwaysFlightData() ``` Constructor ``` BritishAirwaysFlightData // Used to download the BA Flight database and store in the object (Assumging his is only small i.e. 500kb) ``` Methods ``` getStartDate(String source_airport, String dest_airport) // Takes source and destination airport and return date when flights start getEndDate(String source_airport, String dest_airport) // Takes source and destination airport and return date when flights finish getDestAirports(String source_airport) // Takes source airport name and returns a list of destinations getSourceAirports(String dest_airport) // Takes source airport name and returns a list of sources getNumofDestinations() // Returns total number of destinations ``` Hopefully, you get the general idea of what I'm trying to implement, but I'm just not sure if its the right way. I'd basically create an object from the Class, the constructor would then auto download the data and store in a suitable object array of some kind. A main program would be created to allow a user to query flight info etc. It would effectively query this object from the main program to find specific information about flights, dates etc. Would this be the best way to implement this type of functionality bearing in mind I don't want to access the data directly and I have a restricted bandwidth so need to implement some kind of local cached version? I'm concerned more with the actual makeup of the class/constructor/methods as opposed to the actual functionality of each method and calling parameters. Hope this makes sense, any pointers would be much appreciated and also any reference sites with lots of real world examples like this which could improve my initial analysis of problems, Thanks,