To start with the project that I am currently making, I need to input two arguments, "online or offline" and another "online or offline" when running the program.
- The first argument is input and the second argument is output.
- Each of the arguments can either be online or offline.
- When the first argument is set as online, a certain process such as showListofSomething() should be derived from an online rest API, if offline, just from a text file with mock data.
- When the second argument is set as online, the output should be stored in the database, if offline, just in a text file.
For example, the program runs with the command, run --args="online offline".
When switching in between online and offline, I used a facade pattern and therefore my code in the main class became simple
e.g) facade.online(); or facade.offline();
So what I want to ask is,
I need to cover up the two arguments, not just one like the above. So, which design pattern should I use in order to write code in the main class like:
facade.online().offline(); or facade.offline().offline()?
Is the builder pattern appropriate to be used for this?
Aucun commentaire:
Enregistrer un commentaire