H
H
howgreat212019-12-22 09:58:44
OOP
howgreat21, 2019-12-22 09:58:44

How to use OOP correctly when parsing?

Good morning. I have a task:
1. Sparsize and save data from a file in a local database.
2. View the list from the database with the ability to filter by year, by category.
3. Implement the ability to add/remove/update data from the database.
I parsed the file, implemented 2 and 3 with SQL - INSERT, UPDATE, DELETE.
But I have in the requirements for the task - "Use OOP". As I understand it, this is the creation of a class. I created a class, I enter the data there at the same time as entering the data into the database. Then, with the help of a cloud of getters, I display the data in the table (before, I simply displayed the data received by SELECT). But I don’t understand why all this is necessary, if during parsing the data is still entered into the database not using class methods? Or maybe with OOP somehow everything is done in a completely different way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2019-12-22
@howgreat21

Break the logic of your task into layers (groups of classes with a specific area of ​​responsibility).
At first glance, these are: file parsing, preparation for importing into the database, working with the database (crud, filtering), controllers for receiving / returning requests. Methods in classes should encapsulate a single task (don't make a single "run/execute" method that would just be a wrapper over procedural code).
In general - see how it is done in frameworks, the implementation of the task using OOP can be improved for a long time and tediously.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question