samedi 9 janvier 2021

Design pattern for executing various operations depending on flags passed as arguments

For purposes of learning new technology, I want to create simple utility app that generates mathematical statistics. There are various operations that the utility can do, lets say for now there are 3 of them:

utility.sum(); utility.geometricMean(); utility.arithmeticMean();

User can request generating 3 statistics from above, depending on flags he specifies when executing app, let's say

-s -gm -am

The point is user can select any combination of N statistics, so when he runs app with -s -am flags, the app should execute utility.sum(); utility.arithmeticMean(); methods.

I am wondering, what would be an elegant design (probably using a design pattern?) of such module, that corresponds to all clean code, clean design and SOLID principles.

The flags can be represented in a way that suits the solution best - booleans, integers, enums - it does not really matter for me.

Aucun commentaire:

Enregistrer un commentaire