5 views
How would you split into files a form that fetches several reference datasets from the backend, combines them, and calculates a calorie allowance?
Asked at
AI answer
I would separate responsibilities into layers: data retrieval, combining and calculations, form state, and presentation. For example:
api/— request functions for each reference data source;services/— loading and combining reference data, error handling, and data transformation;domain/orutils/— a pure function for calculating the calorie requirement;components/— the form and individual fields;hooks/orstore/— form state and loading status.
Requests to independent reference data sources can be run in parallel with Promise.all. It is best to implement the calorie calculation as a pure function and test it separately. The form should account for loading, error, and empty-data states, as well as user input validation.
Also asked at НПП Баум
- Tell me about the Event Loop in JavaScript: what does it consist of and in what order are synchronous code, microtasks, and macrotasks executed?
- Briefly tell us about yourself: what should we know about you?
- Briefly tell us about yourself and your work experience.
- What is a generic in TypeScript? Provide an example of its application.
- In which direction would you like to develop in the future?
Similar questions
- How would you divide a frontend calorie calculator application into parts, and what would each part be responsible for?
- How can you structure a frontend application by the purpose of its parts rather than by business features?
- Can onion architecture be applied to the frontend?
- How can you organize the reuse of existing code at the application level?
- Can anything else be extracted from the component besides child components?