scientistproject / Scientist.net

A .NET library for carefully refactoring critical paths. It's a port of GitHub's Ruby Scientist library
MIT License
1.47k stars 95 forks source link

Properties vs Methods in interfaces #23

Closed M-Zuber closed 8 years ago

M-Zuber commented 8 years ago

While browsing the code, one of the first things that will be come across is this file.

Personally I was very confused at the beginning as to how it all works. I did find that the implementation is here, but it is not clear if methods like public void Use(Func<Task<T>> control) { _control = control; } would ever do more then just set the field.

If it is true that they will only be setting/getting the method to be scienced, then I would like to propose changing the interfaces to declare properties and not methods.

joncloud commented 8 years ago

In its current implementation using the methods offers the ability to pass a Func<T> into the method, and re-write the delegate so that it gets converted into Func<Task<T>>. With a property, only one or the other would be allowed to be defined.

Also in the Ruby framework the try member allows callers to submit a couple of different pieces:

I have #14 being evaluated to better align the .NET framework to the Ruby framework, which begins to implement these features.

M-Zuber commented 8 years ago

Thank you for the explanation. Maybe I'll have to write up some documentation and put this in.