Skip to content

Commit 2ffb92d

Browse files
bkoelmandennisdoomen
authored andcommitted
Added tuples and exception for TryParse (#113)
1 parent ee64668 commit 2ffb92d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Src/Guidelines/1500_MaintainabilityGuidelines.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,11 @@ C# 4.0's named arguments have been introduced to make it easier to call COM comp
388388
If you create a method with more than three parameters, use a structure or class to pass multiple arguments, as explained in the [Specification design pattern](http://en.wikipedia.org/wiki/Specification_pattern). In general, the fewer the parameters, the easier it is to understand the method. Additionally, unit testing a method with many parameters requires many scenarios to test.
389389

390390
### <a name="av1562"></a> Don't use `ref` or `out` parameters (AV1562) ![](images/1.png)
391-
They make code less understandable and might cause people to introduce bugs. Instead, return compound objects.
391+
They make code less understandable and might cause people to introduce bugs. Instead, return compound objects or tuples.
392+
393+
**Exception:** Calling and declaring members that implement the [TryParse](https://docs.microsoft.com/en-us/dotnet/api/system.int32.tryparse) pattern is allowed. For example:
394+
395+
bool success = int.TryParse(text, out int number);
392396

393397
### <a name="av1564"></a> Avoid methods that take a bool flag (AV1564) ![](images/2.png)
394398
Consider the following method signature:

0 commit comments

Comments
 (0)