Skip to content

Update AV1500: Methods should not exceed 15 statements#359

Open
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av1500
Open

Update AV1500: Methods should not exceed 15 statements#359
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av1500

Conversation

@dennisdoomen
Copy link
Copy Markdown
Owner

This PR updates guideline AV1500.

It was split out of #298 so the change can be reviewed independently.

Files:

  • _rules/1500.md

Part of the replacement for #298.

Split from #298.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
severity: 1
---
A method that requires more than 7 statements is simply doing too much or has too many responsibilities. It also requires the human mind to analyze the exact statements to understand what the code is doing. Break it down into multiple small and focused methods with self-explaining names, but make sure the high-level algorithm is still clear.
A method that requires more than 15 statements is simply doing too much or has too many responsibilities. It also requires the human mind to analyze the exact statements to understand what the code is doing. Break it down into multiple small and focused methods with self-explaining names, but make sure the high-level algorithm is still clear.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could additionally mention the concept of different abstraction levels, as described in Clean Code, if it isn't already covered by another rule. What I mean is that each method should have a single level of abstraction.

So not the code below in the same method:

if (IsPremiumCustomer()) // functional; the "what"
{
}

// ...

if (regex.IsMatch(value.ToUpper().Trim().Substring....  // technical; the "how"
{
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants