What is the preferred naming convention for Func method parameters?

后端 未结 3 2180
时光取名叫无心
时光取名叫无心 2021-02-07 00:19

I admit that this question is subjective but I am interested in the view of the community. I have a cache class that takes a cache loader function of type Func

3条回答
  •  离开以前
    2021-02-07 01:01

    I like to name it like a method so that when you invoke it, like this:

    loadResult(result);
    

    it looks like an ordinary method call but the casing indicates that it is a variable, so both pieces of information are conveyed.

    You can append a suffix like Method or Delegate or Lambda but those often just make it verbose without adding clarity. It can depend on the situation and your coding standards, and of course your preferences.

提交回复
热议问题