I'm working on a model for a simple fishing competition and I have some issues with my design.
The main class for the fishing game is Capture and it looks like this:
public class Capture : Entity {
public virtual int Weight { get; set; }
public virtual int Length { get; set; }
public virtual DateTime DateForCapture { get; set; }
public virtual User CapturedBy { get; set; }
public virtual Species Species { get; set; }
}
So far there´s no problem but I'm not really sure how to model the game.
- Every Species is connected to a reference weight that changes from year to year
- The number of point for a capture is its Weight divided by the current reference weight for the species.
One way to solve the problem is to connect a capture to SpeciesRefer开发者_高级运维enceWeight instead of Species
public class SpeciesReferenceWeight : Entity
{
public virtual Species Species { get; set; }
public virtual int ReferenceWeight { get; set; }
public virtual int Year { get; set; }
}
But in that way that Capture is connected to the implementation details of the game and from my point of view a capture is still a capture even if it's not included in a game.
The result I'm aiming for is like: http://hornalen.net/fishbonkern/2007/ that I wrote a couple of years ago with brute force sql and no domain model.
I would be very happy for all kinds of feeback on this issue.
If you study Fowler's patterns for things that changes with time (i.e. reference weight), I think you'll find a solution.
Sounds like there're some missing entities. You talk about a game and captures that might be part of a game or not. To get you started you could introduce the entity GameCapture.
public class GameCapture : Entity
{
public virtual Capture { get; set; }
public virtual SpeciesReferenceWeight { get; set; }
}
You probably need a Game class as well.
精彩评论