Designing object oriented programming
- by Pota Onasys
Basically, I want to make api calls using an SDK I am writing.
I have the following classes:
Car
CarData (stores input values needed to create a car like model, make, etc)
Basically to create a car I do the following:
[Car carWithData: cardata onSuccess: successHandler onError: errorHandler]
that basically is a factory method that creates instance of Car after making an API call request and populating the new Car class with the response and passes that instance to the successHandler.
So "Car" has the above static method to create that car, but also has non-static methods to edit, delete cars (which would make edit, delete API calls to the server)
So when the Car create static method passes a new car to the successHandler by doing the following:
successHandler([[Car alloc] initWithDictionary: dictionary)
The success handler can go ahead and use that new car to do the following:
[car update: cardata]
[car delete]
considering the new car object now has an ID for each car that it can pass to the update and delete API calls.
My questions:
Do I need a cardata object to store user inputs or can I store them in the car object that would also later store the response from all of the api calls?
How can I improve this model?
With regards to CarData, note that there might be different inputs for the different API calls. So create function might need to know model, make, etc, but find function might need to know the number of items to find, the limit, the start id, etc.