mt-mods / mail

Mail mod for Minetest
https://content.minetest.net/packages/mt-mods/mail/
Other
14 stars 22 forks source link

Optimize with OOP #70

Open Athozus opened 1 year ago

Athozus commented 1 year ago

Rewrite the whole code using OOP, to optimize performances (reduce lags, etc).

S-S-X commented 1 year ago

I would recommend restructuring only parts where issues have been identified and make some core components modular (one by one, not through single PR that rewrites whole thing). For many parts functional programming is almost sure still way better option, especially for public API but also for large portion of internal API.

fluxionary commented 1 year ago

what does OOP have to do w/ performance, even theoretically?

S-S-X commented 1 year ago

what does OOP have to do w/ performance, even theoretically?

Theoretically nothing. Practically it depends on decisions. Either better, worse or same but it has more to do with decisions. Main thing is that OOP brings way better life cycle management, it enforces well defined interfaces and it makes stuff stay where it belongs.

For machine code there's no difference really, theoretically you can generate exact same result with any programming model. It is more about how developers manage things. OOP does not fit every situation and same goes with functional or procedural programming. That's exact reason why I did recommend restructuring only parts where issues have been identified and for mail mod message set life cycle management seems to be what is really messed up here.

By really messed up I mean there's been a lot of duplicate code, user interface mixed up with data operations and even data operations somewhat mixed up with storage back end. If you need to update data operations you have to go through code that is primarily meant to handle user interface and you cannot just change data operations logic.