Would like some modelling tips for dependent values

Posted by orjan on Stack Overflow See other posts from Stack Overflow or by orjan
Published on 2009-10-18T11:59:48Z Indexed on 2010/03/19 7:01 UTC
Read the original article Hit count: 145

Filed under:
|
|

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 SpeciesReferenceWeight 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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ddd