Today I have three recommendations for your CCR methods. For methods that are public interfaces to components I would recommend methods that returns ports like this:
1: public PortSet<ResultType, Exception> DoSomething()
This makes it easy for the consumer (yourself or other developers) to just call the method and then use the port returned. As a consumer I do not need to know how to create the port needed and I think that is convenient. It also means the implementation may complete synchronously or asynchronously. As a caller I don’t really care.
For internal helpers I however tend to use the following two variants:
1: private IEnumerator<ITask> DoSomething(PortSet<ResultType, Exception> resultPort) 2: private void DoSomething(PortSet<ResultType, Exception> resultPort)
The first one should only be used if the method itself needs to yield return. If it ends up having a yield break in the end just to pass compilation you should go for the second variant. However if the method is part of an interface definition I always use the first (iterator) variant.
So wait you may think. isn’t an interface public and hence should have the variant returning a port? And the answer is yes, if the interface is public. But if the interface is internal and it may make sense to treat it as an internal helper.