Skip to content

Maximum Public Methods per Class #215

Description

@Mayron

There is an existing option to set the maximum methods per class. However, after reading the clean code book I noticed the author emphasizes only being able to do 1 or 2 things per class from a usability perspective and encapsulate data as much as possible.

This plugin allows you to configure the maximum methods per class, but that also includes private methods. So, technically I could have 20 public methods, which I believe should break the single responsibility principle.

If a class was an aggregate root (using the DDD term) or an MVC controller, then it might have many public methods. I was mainly thinking of service classes where the limit should be smaller. Ideally, we could configure it on a namespace-level or class-level but that's far outside the scope of this extension.

Either way, it would be beneficial to at least be able to give public methods a different maximum value that by default is smaller than the maximum number of total methods. It could be somewhere around 5-10 instead of 20.

It's up for debate, of course, but I wanted to see what you think :)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions