I'm reading a book for the moment where the author creates a class called Person and a corresponding class diagram in UML. The problem is that he does not distinguish between methods and properties in the diagram:
-------------------------------------------------------------------------
nbspnbspnbspnbspnbspPerson-------------------------------------------------------------------------
birthday : DateTime
name : string
phone : string
-------------------------------------------------------------------------
Person(birthday : DateTime, name : string, phone : string)
Phone() : string
Name() : string
Birthday() : DateTime
NextBirthday() : DateTime
-------------------------------------------------------------------------
The code looks like this (with some modifications by me, one of the reasons being that the textbook is written in Swedish):
csharp
class Person
{
private DateTime birthday;
private string name;
private string phone;
public Person(DateTime b, string n, string p)
{
birthday = b;
name = n;
phone = p;
}
public string Phone
{
get { return phone; }
set { phone = value; }
}
public string Name
{
get { return name; }
}
public DateTime Birthday
{
get { return birthday; }
}
public DateTime NextBirthday()
{
DateTime next = new DateTime(DateTime.Today.Year, birthday.Month, birthday.Day);
if (next < DateTime.Today)
{
nästa = new DateTime(DateTime.Today.Year + 1, birthday.Month, birthday.Day);
}
return next;
}
}
Why does he not separate between a method (e.g.
NextBirthday()) and a property (e.g.
Name()) in the UML Class Diagram? Does he mean that a property is recognizable only because it is named after its attribute, with the only difference being the upper-case initial letter? Is this in line with the recommendations of the UML language?
Another thing that annoyes me is that the author does not use + and - for public and private in the UML diagram.
This post has been edited by Zeddicus: 31 Aug, 2008 - 01:33 AM