1

I am working on creating a c# design for following requirement. I am creating this for a fitness website.

I have an article (as Text) and a exercise (as Image or Videos) as the base entity. Now i have workouts, middle entity, (A workout is basically a set of excercises or articles to be performed in a instructed manner, it will have 2 or more than 2 base entities to make the workout) above these two entities.

Next I have routines, top entity, ( A routine is basically two or more workouts taken at a time.) A routine can span for days, weeks, months or year(if provided).

Now i was thinking composite design pattern to implement in my application but not sure.

A little peek at database design to help with the c# design.

My database design would look similar to this one, check the image in answer.

Also a small example would help me.

I am looking for a design that would be helpful in developing the complex application(eventually it will become one sooner or later.) with ease and also is flexible and scalable.

My application work flow is simple first user adds base entity then the middle entity and then it creates top entity.

closed as too broad by svick, Robert Harvey, user22815, Ixrec, gnat Mar 25 '16 at 22:28

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    An example of what? Where's the question? What problem are you trying to solve? – RubberDuck Mar 20 '16 at 12:09
  • 2
    You've described a bunch of entities but nothing about what you actually want your application to do (i.e. its behaviour). Think about the behaviour your program needs - that could be in the form of user stories, or a UI mock/drawing with some workflows, or some interaction diagrams, etc. – Ben Cottrell Mar 20 '16 at 13:06
  • I am looking for a design that would be helpful in developing the complex application(eventually it will become one sooner or later.) with ease and also is flexible and scalable. @RubberDuck – lokopi Mar 20 '16 at 15:58
  • My application work flow is simple first user adds base entity then the middle entity and then it creates top entity. – lokopi Mar 20 '16 at 16:00
0

The composite design pattern seems at first sight a natural choice, because of the hierarchical structure. However, the goal of the composite pattern, is to handle uniformly the leaves and the components. Furthermore, in a composite, leaves (articles and exercises) can be found at any level of the tree whereas in your structure, they should be at the bottom:

enter image description here

So, this idea might not be so good after all ! You'd better use a traditional composition model for your limited hierarchy of fixed depth, and homogeneous classes at one level. No need for special structural patterns here.

A pattern that could help you, I believe, is the visitor pattern. It is behavioural and represents operations performed on a complex structure, handling in appropriate manner every type of object that is encountered. THis can be used for saving the structure, to make reports and accumulate values top-down, etc...

Here an example for composite, in case you'd still want it. And here the visitor example

  • I will check the visitor pattern. I would like to know which UML tool you are using - Thanks – lokopi Mar 22 '16 at 2:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.