sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Standardize on embedded structs or embedded interfaces

Open globalflea opened this issue 3 years ago • 4 comments

What would you like to be added: Need to standardize on using embedded struct or embedded interface, with the latter preferred.
E.g. OperationState embeds struct BaseState instead of interface State, whilst, EventBaseSwitchState.EventConditions embeds interface EventCondition instead of struct BaseEventCondition.

Why is this needed: With the various States - e.g. OperationState has an embedded struct BaseState. By doing so, these states do not implement the interface State even though BaseState does, i.e. OperationState does not implement the interface State, and this will disallow use of the more general / abstract State interface as a pointer to actual concrete states. I believe the interface State should have been used as the embedded property in the specific states

globalflea avatar Dec 28 '21 13:12 globalflea

I might be missing something, but the intention was to have all the states implement the State interface. If they are not it's a bug. Can you open a PR? Should be fairly simple to fix this.

ricardozanini avatar Dec 28 '21 19:12 ricardozanini

Think will need to provide a custom unmarshal func

globalflea avatar Dec 29 '21 00:12 globalflea

Let me know if you are ok sending a PR. Otherwise, I can get this one after the new year. :)

ricardozanini avatar Dec 29 '21 13:12 ricardozanini

I think it's major rework as all (or almost all) states current embed the BaseState struct. Would rather leave such a big PR to you since I am still pretty unfamiliar with the code base

globalflea avatar Dec 30 '21 05:12 globalflea

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 15 '22 00:11 github-actions[bot]