Feuermagier / autograder

Automatic grading of student's Java code
MIT License
13 stars 7 forks source link

Suggest method parameter should be an attribute #492

Open Luro02 opened 5 months ago

Luro02 commented 5 months ago

What it does

When a sufficiently large class, has a lot of methods that take the same parameter, it would make sense to have this as an attribute.

Potential Problems

Lint Name

PARAMETER_SHOULD_BE_ATTRIBUTE

Category

oop

Example

class A {
    void a(String name) { /* ... */ }
    void b(String name) { /* ... */ }
    void c(String name) { /* ... */ }
    void d(String name) { /* ... */ }
    void e(String name) { /* ... */ }
    void f(String name) { /* ... */ }
}

Could be written as:

class A {
    String name;

    void a() { /* ... */ }
    void b() { /* ... */ }
    void c() { /* ... */ }
    void d() { /* ... */ }
    void e() { /* ... */ }
    void f() { /* ... */ }
}