Setup
- creation of empty project
- initial maven configuration
- gitignore
UDP Server
-
UDP server creation
-
Error handling:
- local recovery (retry listening)
- notify caller (failure to bind port in server)
- tear down application on fatal error (failure to start UDP server)
UDP Sender
- methods for sending UDP messages
- usage of static methods (when no context/state is needed from a class)
Data classes: UDPMessage
- data classes:
- record syntax
- overriding equals, hashCode, toString
UDPServer: Observer Pattern
- implement an Observer design pattern
- make library code generic and customizable
UDPServer: Thread safety
- prevent potential data races when accessing class data.
Test
- setting up tests with junit
- exploitation of the observer to gather the results of the test code
Note: When modifying pom.xml, you may need to update the project configuration (IntelliJ IDEA: right click on pom.xml > Maven > Reload Project)
Continuous Integration
- setting up the continuous integration to run compilation and tests with Github actions
Logging
- import the
log4jlibrary - add logging messages at different levels
- configure the logger
- with configuration file (default configuration)
- manually override log level to select the appropriate level for the use case (tests vs user-facing programs)
Note: the listening port can be found with socket.getLocalPort() (fixed in the git)