Help in understanding cohesion vs coupling
I understand that - Cohesion refers to the concept where each component in a suite of entities has only one responsibility; and that coupling describes the relationship between components. Now here we have three classes... how would you categorize them?
Code Java:
class Name // Handles the name of an individual
{
}
class Address // Handles address only
{
}
By definition these classes are each cohesive. In a business environment a customer would have name and address.
Code Java:
class Customer
{
Name nm;
Address addr;
String account_number;
Customer(Name n, Address ad, String acc)
{
nm = n;
addr = ad;
account_number = acc;
}
// .... and methods related only to an account actions
}
Now for this class Customer, its sole purpose create and manipulate account objects.
My question is, how would we describe the class Customer? Would we desribe it as being cohesive; or, would we describe it as a coupled relationship with Name and Address?
Thanks for your help