alvin159 / TrainWeatherInsight

This project is a comprehensive tool that allows users to track train data, explore cities, and get weather updates in an interactive and visually engaging way.
1 stars 0 forks source link

Design EventTypes and Payloads to Events.java #12

Closed JuhanaKivela closed 1 month ago

JuhanaKivela commented 2 months ago

OLD INFO BELOW Backend components should take Objects of pre-defined classes as a payload (payload is similar to function parameter input) and process the request based on information there. For example AbbrevConverterComponent.java might take a very simple Object that only has 1 variable "Abbreviation" as a payload. In this case we would create e.g. "AbbreviationObject.java".

When we return the value, there are at least two possible ways to do it:

  1. Add information to the AbbreviationObject.java
  2. Return different Object (e.g. create AbbreviationResponseObject.java and fill it with the full name of the station) This needs a bit investigation/testing to define which one is better
Ynnz commented 1 month ago

I have implemented the AbbrevConverterComponent.java. Since it has the most basic functionality, I didn't create "AbbreviationObject.java". The process is frontend sends a request with a string(e.g. "ATL") and backend responds with a string(e.g. "Aittaluoto"). But for all the remaining components, creating "Object.java" would be necessary. I will look into the two possible ways.

Ynnz commented 1 month ago

Now I modified "AbbrevConverterComponent.java" and made the pre-defined class "AbbreviationObject.java" which is taken as payload. I follow the first way because in my opinion it might be easier to implement.