In the code sample below. Would UserId, Email, and UserType be considered "dependencies" with respect to the ChangeEmail method? would they be considered "collaborators"? Is it a condition for a member to be of a complex type for it to be considered either?

public class User
    public int UserId { get; private set; }
    public string Email { get; private set; }
    public UserType Type { get; private set; }
    public void ChangeEmail(int userId, string newEmail)
        object[] data = Database.GetUserById(userId);
        UserId = userId;
        Email = (string)data[1];
        Type = (UserType)data[2];
        if (Email == newEmail)

        object[] companyData = Database.GetCompany();
        string companyDomainName = (string)companyData[0];
        int numberOfEmployees = (int)companyData[1];
        string emailDomain = newEmail.Split('@')[1];
        bool isEmailCorporate = emailDomain == companyDomainName;
        UserType newType = isEmailCorporate ? UserType.Employee : UserType.Customer;
        if (Type != newType)
            int delta = newType == UserType.Employee ? 1 : -1;
            int newNumber = numberOfEmployees + delta;
        Email = newEmail;
        Type = newType;
        MessageBus.SendEmailChangedMessage(UserId, newEmail);
public enum UserType
    Customer = 1,
    Employee = 2
  • 2
    Curiously, the snippet doesn't show any of the two cases. ChangeEmail is setting up attributes, but it's not operating through or with them. The method could be rewritten so it doesn't make any reference to the members and it would still compile and work. Basically, the method doesn't depend on any of the members to actually do its job. The only it needs is Database
    – Laiv
    Commented Aug 16, 2021 at 16:58
  • This code was copied from text. I assume that the properties would be used by clients of the class at some point, thus the public modifier.
    – 3m3sd1
    Commented Aug 16, 2021 at 20:16
  • Well, the question is in relation to ChangeEmail, not consumers. Anyways, it doesn't change the observation. The method will work with or without these members because it doesn't use them. Not sure if we can tag instance attributes as "dependencies". I guess it depends on the kind of object. If it's a service, then yes, dependencies are likely collaborators. If it's a POJO ... I don't see it so clear.
    – Laiv
    Commented Aug 16, 2021 at 20:25

1 Answer 1


This heart of this question is the definition of these terms. So lets dig up some definitions.

Dependency (computer science) or coupling,
a state in which one object uses a function of another object

wikipedia.org - Dependency

(other classes) with which this class interacts to fulfill its responsibilities

wikipedia.org - Class Responsibility Collaboration Card

Given that the usual way classes interact is through methods (which is a fancy name for a particular kind of function) it's easy to see these terms as meaning the same thing. However, they are not typically mixed together in the same literature. When I hear one mentioned vs the other it mostly tells me which books the speaker has been reading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.