Why this matters
Tuples without descriptive titles can make code difficult to understand and maintain. Named classes provide clarity and improve code readability.
Ensure that titled classes are used instead of untitled tuples for complex data structures. Tuples should only be used when their purpose is immediately clear.
Tuples without descriptive titles can make code difficult to understand and maintain. Named classes provide clarity and improve code readability.
Side-by-side examples engineers can pattern-match during review.
Tuple<int, string> result = new Tuple<int, string>(1, "Hello");public class Result
{
public int Id { get; set; }
public string Name { get; set; }
}
var result = new Result { Id = 1, Name = "Hello" };
Tuple<int, string> result = new Tuple<int, string>(1, "Hello");public class Result
{
public int Id { get; set; }
public string Name { get; set; }
}
var result = new Result { Id = 1, Name = "Hello" };
From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.