locked
Architecturely Lost! RRS feed

  • Question

  • I am developing an application that I am using to track workouts.  This has become amazingly difficult for me because of all of the variations that I need to incorporate.

     

    The problem is that every workout can be different.  Even if the person is doing the same thing.  Such as riding a bike.  You can ride a bike for leasure but others will ride for time and traing purposes or warm up for the main excersise!  Same goes with weight lifting.  You can weight lift for X amount of reps or weight lift for a certian amount of time, depending on what the coach orders up.  Also, my coaches have about 1000 different types of weight lifting exercises and many different variations to them. 

     

    So I am at a loss where to start with an OO diagram. 

     

    It seems as if this might fit a decorator pattern?  The base is a workout then the person can plug any number of exercises in the workout object?

     

    How do I instantiate a workout that has 5 different exercises versus a workout that has only one workout (riding a bike)?  Do I have to have 1 Billion Constructors?

     

    What about each of the variations, ie pushups versus one-armed pushups?  Two seperate Objects?

     

    Any articles etc would be very helpful. 

     

    Thanks in advance.

     

    Bryan

    Friday, December 28, 2007 4:51 PM

Answers

  • I'm not sure that a Domain Model is the best pattern for your environment. At first blush - it looks like its data only, the definition of what the trainer wants the trainee to perform. There is no behavior. The closest thing I can see is whether an excercise has been completed or not - the data of which (a bool) seems like the simplest solution. For more information, you can check out my post on Domain Models.

     

    If you do want to perform some OO analysis and design, here's what it might end up looking like:

     

    You'll have an interface IEquipment to represent what is required to perform the excercise (bike, weights, just a mat on the floor). The different kinds of equipment would implement that interface:

     

    public class Bike : IEquipment { }

     

    You'd probably also have an IActivity for what can be done on equipment, for instance you could have a CurlActivity and a PressActivity that are both connected to the FreeWeightsEquipment.

     

    Also, it looks like an IExercise is in order, which is connected to an IActivity. So, riding a bike as warmup would be modeled as a WarmUpExercise connected to a GeneralActivity connected to a BikeEquipment. Curling 10lb weights for 5 minutes would be modeled as a TimedExercise connected to a CurlActivity connected to a TenPoundFreeWeightEquipment.

     

    The question then becomes, given that you have all these classes - besides persisting them and showing them to the user, what are you going to do with them?

    Friday, December 28, 2007 9:12 PM

All replies

  • I'm not sure that a Domain Model is the best pattern for your environment. At first blush - it looks like its data only, the definition of what the trainer wants the trainee to perform. There is no behavior. The closest thing I can see is whether an excercise has been completed or not - the data of which (a bool) seems like the simplest solution. For more information, you can check out my post on Domain Models.

     

    If you do want to perform some OO analysis and design, here's what it might end up looking like:

     

    You'll have an interface IEquipment to represent what is required to perform the excercise (bike, weights, just a mat on the floor). The different kinds of equipment would implement that interface:

     

    public class Bike : IEquipment { }

     

    You'd probably also have an IActivity for what can be done on equipment, for instance you could have a CurlActivity and a PressActivity that are both connected to the FreeWeightsEquipment.

     

    Also, it looks like an IExercise is in order, which is connected to an IActivity. So, riding a bike as warmup would be modeled as a WarmUpExercise connected to a GeneralActivity connected to a BikeEquipment. Curling 10lb weights for 5 minutes would be modeled as a TimedExercise connected to a CurlActivity connected to a TenPoundFreeWeightEquipment.

     

    The question then becomes, given that you have all these classes - besides persisting them and showing them to the user, what are you going to do with them?

    Friday, December 28, 2007 9:12 PM
  •  

    Primarily the information will be used to:

    1) Schedule workouts. Giving an Athlete a List<Workouts> that will be performed.

    2) Track progress.  ie Weight lifted 100lbs 1/1/2008 and 300lbs 5/1/2008 or Ran 20 miles Pace 8:00 on 1/2/2008 - Ran 20 Miles 7:00 Pace on 6/1/2008

     

    So If I have an IActivity would I have an IActivityBiking, IActivityWeights, IActivityRunning etc?  IEquimentBike, IEquimentWeights, IEquipmentRunning?

     

    Thoughts?

     

    Thanks for your reply.

    Friday, December 28, 2007 9:48 PM
  • We also just updated our .NET Architecture and Development Book Recommendations here:

    http://realworldsa.dotnetdevelopersjournal.com/netarchitectureanddevelopmentbookrecommendations.htm

     

    Saturday, January 5, 2008 5:12 AM