Is there a heuristic to determine if a method or field belongs to a class?

Is there a good rule or test that I can run to determine if a method or field belongs to a class? How to determine when a member does not belong?

I believe that my biggest stumbling block in object-oriented design is trying to figure out what is happening. It seems that there are too many cases where there is an answer: "he can go here or there."

Here is a brief example of the type of thing I'm struggling with:

Public Class ITDepartment

    Private _sysadmins As List(Of Employee)
    Private _developers As List(Of Employee)

    // properties, public stuff...

    Private Sub AddSkillToGroup(ByVal emps As List(Of Employee), ByVal skill As Skill)
        For Each e As Employee In emps
            e.AddSkill(skill)
        Next
    End Sub

End Class

An object ITDepartmentcontrols two groups Employees... but should it know that it Employeeshas skills? Should a method like that be moved AddSkillToGroup?

EDIT:

, , ITDepartment . , , .

ITDepartment . ? AddSkill - Employee. ITDepartment .

+5
2

SOLID. , .


Edit

" [ITDepartment] ?"

"[ ], ITDepartment" " Employee List (Of Employee), (, e.AddSkill )".

.

- , OO-. . , , .

BTW, AddSkillToGroup , . , . . [private . , ; , .]

Employee, AddSkillToGroup .

+3

List(Of Employee) , AddSkill().

, . , ; . , , .

, - .

+4

All Articles