OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Change Funcs and Actions to explicit delegate in public interfaces #5175

Open Piedone opened 9 years ago

Piedone commented 9 years ago

Having Func<T1, T2, ...> or Action<T1, T2,...˙> delegates in public interfaces is most of the times confusing, since you don't know the meaning of the arguments. If there is a single output or a single input/output argument, that is most of the time fine, but it's gets really hard to understand once we have three-four type parameters for Func.

E.g. you have to dig through the code to eventually find out that the parameters of the Func<string, string, string, PlacementInfo> stored in BuildShapeContext.FindPlacement expects shapeType, differentiator, location.

Instead, we could define explicit delegates, e.g. for the above:

public delegate PlacementInfo PlacementFinder(string shapeType, string differentiator, string location);

I'm sure there are similar cases elsewhere too.

A quite similar issue is #4759.

sfmskywalker commented 9 years ago

+1

MpDzik commented 9 years ago

+1

Piedone commented 9 years ago

And this makes you wonder why GitHub doesn't have a voting feature for issues. Probably the only aspect in what Codeplex is better :-).

sfmskywalker commented 9 years ago

Yeah exactly. Maybe submit an issue for that? ;)

Piedone commented 9 years ago

There is one :-): https://github.com/isaacs/github/issues/9 Well, kind of...

sebastienros commented 9 years ago

Breaking change :/

sebastienros commented 9 years ago

Or maybe not breaking ...

Piedone commented 9 years ago

Not breaking :-).

MpDzik commented 9 years ago

Theoretically, it can be breaking if someone explicitly created a Func<T1, T2, ...> and passed it as an argument. However, I think everyone uses lambda expressions these days, so this shouldn't be a problem.