D
D
dezzcore2019-04-17 18:33:30
OOP
dezzcore, 2019-04-17 18:33:30

How to properly distinguish an object and a class in OOP?

Everywhere classes and objects are explained through simple examples, but what if I have the task of developing a system for recording buses on the lines for the fleet, where a record will be made in the data file. Which includes: date of exit to the line, exit time, brand of the bus, its city number, route number, name of the driver, etc. On simple examples, everything is clear and understandable, but what about this, what will be the class here? My guess is that it will be just an object called Info that contains all these data (fields), but I'm not entirely sure about this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2019-04-17
@dezzcore

The database helps a lot in breaking down a large task into classes. By normalizing tables, you are designing entities that are almost entirely suitable for you.
But if you start with code design, then look: the Info class is too general a name. You have everything - info.
There must be a Driver class that contains information about the driver (if the driver is not allocated to the Person class). There is a Bus class that knows about the make of the car. Perhaps it will contain a list of drivers - with information about who usually drives this car, or maybe you need a driver - a link to one object of the Driver class, if you need to know who is driving the bus right now.
Is the direction clear?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question