Replies: 8 comments
-
@hangy @john-gom @stephanegigandet @zigouras @yuktea what do you think ? |
Beta Was this translation helpful? Give feedback.
-
Hi @alexgarel . I would personally like to see a more long-term vision of how we want the code to be structured in the future, e.g. how we might partition the code into multiple, smaller services. I know we can't achieve this quickly, and activities like the ones you suggest are likely to be part of the path to getting there, but it is helpful to know the ultimate goal to be sure that the work we are doing is heading in the right direction and not down a side path. |
Beta Was this translation helpful? Give feedback.
-
@alexgarel Thanks for writing this down. It makes a lot of sense. Regarding the objects, I'm curious to see how well it can work with things like products (if we want to decompose them in smaller objects like ingredients lists, ingredients, nutrition facts, scores etc.), and then their recomposition/decomposition when we want to save/load them to/from MongoDB, JSON, disk etc. @john-gom I'm a bit scared of the multiple smaller services approach. Today's monolithic approach has the benefit that all products updates / analysis (e.g. analyzing ingredients, computing scores etc.) is synchronous and fast. There's only one state for products: the analysis is always complete. We can update the 3M products relatively easily (e.g. there's an ingredient taxonomy change, we recompute ingredient analysis, ecoscore, nutriscore etc. on all products). If we have separate micro services, and we still run them in a synchronous way with a defined order with a reasonnable performance cost (e.g. re-analyising 3M products does not take twice the time), then it's fine I think. But I would be very afraid of going in a direction where products can be partially updated, with for instance updated ingredients and nutrition facts but a score or analysis that would still be pending. |
Beta Was this translation helpful? Give feedback.
-
Hi @stephanegigandet , I recognise your concerns, but I think we do need to do something to address the size of the codebase in the server repository. Everything is taking much too long, which significantly impacts on productivity / willingness to contribute and makes it very difficult to adopt modern practices like TDD. It is exactly because of those concerns that you have that I think it is important that we have a discussion about which way we should go in terms of a longer-term strategy, as otherwise people might make assumptions... |
Beta Was this translation helpful? Give feedback.
-
Hi @stephanegigandet , @alexgarel I've started dumping my thoughts on future architecture here: https://docs.google.com/document/d/1I0ld47BwRaLg7ThNMrLSbKbgqygMWB0OdYfCI49Vp3g/edit?usp=sharing Please feel free to add your own thoughts, pros, cons, etc. |
Beta Was this translation helpful? Give feedback.
-
Wonderful, thank you @john-gom ! |
Beta Was this translation helpful? Give feedback.
-
@stephanegigandet about objects, I think I did not understand object in perl indeed. Because what I was seeking is enforcing / documenting the attributes names. And apart from using accessor (which is may slow down quite a lot and is a bit verbose in the code) there is no way to enforce attributes in blessed perl hash. Maybe we should use Class::Struct ? but what is the perf penalty ? |
Beta Was this translation helpful? Give feedback.
-
This issue has been open 90 days with no activity. Can you give it a little love by linking it to a parent issue, adding relevant labels and projets, creating a mockup if applicable, adding code pointers from https://github.com/openfoodfacts/openfoodfacts-server/blob/main/.github/labeler.yml, giving it a priority, editing the original issue to have a more comprehensive description… Thank you very much for your contribution to 🍊 Open Food Facts |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What
Following up on #2361 I propose a path to improve code quality on at least a first side, quite systematic.
We may discuss on this issue and the create sub-tickets
Why
See #2361. Main point is to make code testability and transformation more easy, and allow new developer to more easily contribute.
Proposed methodology
in
.pm
files: identify every call toparam
and replace by a field in request ref (this avoid having apache reference deep inside the code, which make thinks harder to identify and to refactor). Also avoid using directly add headers or that kind of http related stuff and put it in response ref instead, then process at the end.initialization of request_ref should do all HTTP related stuff and put them in meaningful structure (or a series of specific sub for specific cases)
incrementally replace a lot of hashmaps structuring the code with objects:
refactor the existing code in smaller chunks, trying to respect single responsibility principle and testability. To do it progressively:
#TODO: refactor to MODULE::function_name
on group of lines. Function name should really be choosen with care, and module also (it maybe a new module). We can do it progressivelyBeta Was this translation helpful? Give feedback.
All reactions