FAI-CIVL / FAI-Airscore

AirScore - online paragliding / hanggliding GAP-based scoring software.
https://airscore.cc/
GNU General Public License v3.0
13 stars 17 forks source link

The separation of state and task. #50

Open philderbeast opened 4 years ago

philderbeast commented 4 years ago

Could we please refactor the task class, removing database stuff? One of the maintenance problems with FS is that the XML data access is pervasive. More generally, can we try to have more pure functions and reduce the use of state?

https://github.com/kuaka/airscore/blob/b5d0bfacfac44ccd31c38e29c326b3f7554382db/airscore/core/task.py#L34-L36

kuaka commented 4 years ago

Sure. Help us understand a bit better what you mean by this. A lot of the objects have DB methods. Usually a read and a write method. I think this is fairly standard for OO python but I could be wrong. Certainly for the SQLalchemy it seems to be the norm. Having looked at Task, there are a lot of methods with DB stuff, I didn't realise it was so pervasive there. I think some refactoring would make it a bit more pure and easier to test. Are you asking about task in particular as it has more DB stuff in it, or perhaps because it's the class you have looked at so far? What do you suggest and how would it make it easier to maintain?

philderbeast commented 4 years ago

The IO stuff should be at the outermost layer but here we have the innermost classes reaching out to read from and write to the database.

When the same inputs give same outputs and when class and instance state is not involved, testing is easier.

kuaka commented 4 years ago

Ok I'll try to clean it up once the front end is done.