You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After working on few features/properties for this project, I noticed that it is pretty hard to work with especially when it comes to write tests for API. When we want to compare output of some API methods, we need to duplicate content of data.json file. Another thing is that currently we have JSON file (with almost 5000 lines 😱) and whenever we add/update/remove some property there, it is a bit annoying and hard to check those changes on code review.
What we could do is refactor JSON data file by splitting it to multiple JavaScript files and then using imports/exports to structure it. This way, we can achieve the same thing (having whole data in one) but also we could "build" smaller chunks for testing purposes (instead of duplicating data).
I have some concept how might it look like, but first I would like to see what you think.
Feel free to share your ideas and have an input how we could achieve this!
The text was updated successfully, but these errors were encountered:
Yes, @sthiepaan I agree with you completely. We need to modularize the codebase.
Testing and PR reviewing processes are kinda hard right now, no doubt about that.
What do you have in mind? Let's list out what all we can do to modularize the codebase.
Split data.json to separate JavaScript files for each country individually
In this case what we could do is for example something like:
...
├ data
│ ├ eu
│ │ ├ pl.js
│ │ └ de.js
│ ├ af
│ │ └ zw.js
...
This allow us to focus only on a specific country or countries for specific continent. We still need to provide properties for all countries to have consistent data model, but I think this could be solved in another way (e.g. Node.js task to add new property to all countries).
The downside of it is that whenever we populate the data, instead of working on a single file, we have to modify multiple files (which should not be a really big deal tho). On the other hand, as we mentioned earlier, the code review is pretty annoying at the moment.
Split index.js to separate JS files for each API Method
Splitted files, less confusion and whenever we want to add/change/remove a new method, we will not struggle with that many conflicts that we had so far.
Split getCountriesSpec.js to separate JS files for each API Test
Same as point 2. but for tests. Also, together with 1., this will allow us to reuse data model to compare output of the methods together with different combinations of the data models that we have (no more data repetitions across the project).
In general, we can split the problem into multiple smaller parts. For instance, points 2. and 3. can be done separately.
This way we do not make too big Pull Request, so on the code review we can focus just on one aspect of refactoring.
After working on few features/properties for this project, I noticed that it is pretty hard to work with especially when it comes to write tests for API. When we want to compare output of some API methods, we need to duplicate content of
data.json
file. Another thing is that currently we have JSON file (with almost5000
lines 😱) and whenever we add/update/remove some property there, it is a bit annoying and hard to check those changes on code review.What we could do is refactor JSON data file by splitting it to multiple JavaScript files and then using imports/exports to structure it. This way, we can achieve the same thing (having whole data in one) but also we could "build" smaller chunks for testing purposes (instead of duplicating data).
I have some concept how might it look like, but first I would like to see what you think.
Feel free to share your ideas and have an input how we could achieve this!
The text was updated successfully, but these errors were encountered: