Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Per Mat's Mug's answerMat's Mug's answer:

I'd try to find a name that better indicates that truncation will occur when value is longer than maxLength... but WithMaxLength isn't a bad name.

I disagree that the method's name is the place to do this. It's not. And WithMaxLength is a perfectly fine name.

But... that truncation occurs should be documented. I'm not sure what's available exactly for C#, but most all languages have a format for showing in-IDE documentation.

I've been told the C# version of this looks something like this:

<summary>
This function does something.
<param name="string">The string to do things with</param>
</summary>

We should certainly add this sort of documentation to our method to be clear on exactly what happens with the method. I think any other sort of name for the method itself goes beyond to descriptive and ventures into the realm of too verbose (and this is coming from someone who writes Objective-C...).

Per Mat's Mug's answer:

I'd try to find a name that better indicates that truncation will occur when value is longer than maxLength... but WithMaxLength isn't a bad name.

I disagree that the method's name is the place to do this. It's not. And WithMaxLength is a perfectly fine name.

But... that truncation occurs should be documented. I'm not sure what's available exactly for C#, but most all languages have a format for showing in-IDE documentation.

I've been told the C# version of this looks something like this:

<summary>
This function does something.
<param name="string">The string to do things with</param>
</summary>

We should certainly add this sort of documentation to our method to be clear on exactly what happens with the method. I think any other sort of name for the method itself goes beyond to descriptive and ventures into the realm of too verbose (and this is coming from someone who writes Objective-C...).

Per Mat's Mug's answer:

I'd try to find a name that better indicates that truncation will occur when value is longer than maxLength... but WithMaxLength isn't a bad name.

I disagree that the method's name is the place to do this. It's not. And WithMaxLength is a perfectly fine name.

But... that truncation occurs should be documented. I'm not sure what's available exactly for C#, but most all languages have a format for showing in-IDE documentation.

I've been told the C# version of this looks something like this:

<summary>
This function does something.
<param name="string">The string to do things with</param>
</summary>

We should certainly add this sort of documentation to our method to be clear on exactly what happens with the method. I think any other sort of name for the method itself goes beyond to descriptive and ventures into the realm of too verbose (and this is coming from someone who writes Objective-C...).

Source Link
nhgrif
  • 25.4k
  • 3
  • 64
  • 129

Per Mat's Mug's answer:

I'd try to find a name that better indicates that truncation will occur when value is longer than maxLength... but WithMaxLength isn't a bad name.

I disagree that the method's name is the place to do this. It's not. And WithMaxLength is a perfectly fine name.

But... that truncation occurs should be documented. I'm not sure what's available exactly for C#, but most all languages have a format for showing in-IDE documentation.

I've been told the C# version of this looks something like this:

<summary>
This function does something.
<param name="string">The string to do things with</param>
</summary>

We should certainly add this sort of documentation to our method to be clear on exactly what happens with the method. I think any other sort of name for the method itself goes beyond to descriptive and ventures into the realm of too verbose (and this is coming from someone who writes Objective-C...).