Description/Scope
There are 3 datastore related endpoints exists on the proxy controller.
/v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-operational:
$ref: 'ncmp.yml#/getResourceDataForPassthroughOperational'
/v1/ch/{cm-handle}/data/ds/ncmp-datastores:operational:
$ref: 'ncmp.yml#/getResourceDataOperational'
/v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-running:
$ref: 'ncmp.yml#/resourceDataForPassthroughRunning'
It would be better to have just one handling all the cases like /v1/ch/{cm-handle}/data/ds/{ncmp-datastore-name}
where can be set to ncmp-datastore:operational or ncmp-datastore:passthrough-operational or ncmp-datastore:passthrough-running
Open questions
- If want to have full backward compatibility than we will have ':' in the URL, alternative way: just remove "ncmp-datastore:" prefix
Proposed solutions
- Use just a switch to execute the appropriate function from the old functions
- Use Factory pattern alone
- Use Builder pattern to make a the config for the Factory (Thanks Andras for the idea)
- Make handler Builder (Solution will be proposed by Andras)
Advantages and Disadvantages of Proposed Solutions
Advantages and Disadvantages of the simple switch
Advantages | Disadvantages |
---|---|
Really easy to understand cos one can clearly see the switch and the original interface functions | All the logic will be present in the switch |
Hard to maintain and expand | |
Hard to see the common parts |
Advantages and Disadvantages of the Factory Pattern
Advantages | Disadvantages |
---|---|
Easy to understand by look | It cannot be a classic Factory |
All the business logic is abstracted away (switch and the handlers) | Factory has a constructor because of the common services and constants used in the logic of the handlers |
The business logic of the handlers are in their own Handler class | Handlers has many parameters because of the different parameter list used by the original endpoints |
Advantages and Disadvantages of the Builder Pattern and Factory used together
Advantages | Disadvantages |
---|---|
Like above | Like above |
The user can clearly see which parameter has been set to which value on the constructor of the Factory | One more layer of abstraction |