I just finished reading Domain Management Project: Eliminating Complexity at the Software Center by Eric Evans, and I'm trying to write my first domain-oriented application (in C #).
The application will be used by our support team to track the distribution of computers to users.
I sketched a simple class diagram to reflect part of the domain. It looks like this...
Class Diagram showing two classes: Owner and Computer. There is a one-way communication between the computer and the owner named "Select" http://www.freeimagehosting.net/uploads/183dd57031.jpg
I also defined my first function (to allocate a computer for the user) and wrote a test for it ...
[Test]
public void AllocateToUser()
{
var user = new Owner("user1");
var computer = new Computer("computer1");
computer.Allocate(user);
Assert.AreEqual(user.Username, computer.AllocatedTo.Username);
}
Finally, I wrote the code to pass the test.
public class Computer
{
public Computer(string name)
{
Name = name;
}
public string Name
{ get; private set; }
public Owner AllocatedTo
{ get; private set; }
public void Allocate(Owner owner)
{
AllocatedTo = owner;
}
}
public class Owner
{
public Owner(string username)
{
Username = username;
}
public string Username
{ get; private set; }
}
, ( ).
, , . , . - :
public class ComputerRepository
{
public void Store(Computer computer)
{
}
}
.. , , , ?
, :
Allocate Computer, ComputerRepositry Store.
IComputerRepository; , , , IComputerRepository. Allocate Store .
(AllocationService), .
, :
- Computer
- ComputerRepository Store.
:
?