Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbids classes with too high coupling #1242

Open
sobolevn opened this issue Mar 6, 2020 · 0 comments
Open

Forbids classes with too high coupling #1242

sobolevn opened this issue Mar 6, 2020 · 0 comments
Labels
level:advanced Needs a lot of care question Further information is requested rule request Adding a new rule

Comments

@sobolevn
Copy link
Member

sobolevn commented Mar 6, 2020

Rule request

Thesis

Coupling is a very important concept in programming.

Currently, we don't enforce any rules about cohesion and coupling. But, we totally need to!

And while you can use https://github.com/mschwager/cohesion to measure cohesion, there's no tool to measure coupling.

I don't think that cohesion is important. Because the best class in my opinion is @dataclass:

@dataclass
def Some(object):
    field1: int
    field2: str

But, coupling is the whole other beast! High coupling makes refactoring very hard. Compare these two samples:

class SomeClass(ParentClass):
     def method(self, other):
          if other.some_field > other.other_field:
               other.first_method()
          else:
               other.other_method()

And:

class SomeClass(ParentClass):
     def method(self, other):
         other.smart_method()

The second one is way better.

Problems:

  1. I am not sure how to count coupling
  2. I am not sure about corner values
@sobolevn sobolevn added question Further information is requested rule request Adding a new rule level:advanced Needs a lot of care labels Mar 6, 2020
@sobolevn sobolevn added this to the Version 0.15 milestone Mar 6, 2020
@sobolevn sobolevn modified the milestones: Version 0.16, Version 0.15 aka New runtime Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level:advanced Needs a lot of care question Further information is requested rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

1 participant