Note that there are some explanatory texts on larger screens.

plurals
  1. POWhich is the most elegant Design for this simple OOAD problem?
    text
    copied!<p>I am trying to get started with OOAD, this problem came to my mind and I am not sure I can find a good solution: (it is a supersimplfied version of a real world case).</p> <p><em>A fisherman fishes at a pond with a fishing rod. At every launch of the fishing line there is a likelihood of catching a fish equals to 1/10 when there is sunlight and 1/20 at night.</em></p> <p><strong>Which classes to define?</strong> I would answer: Fisherman, FishingRod, Pond, Day(for modeling night and day).</p> <p><strong>Which methods?</strong> I would answer: Fisherman.Launch(FishingRod), FIshingRod.TryToFish(Pond) returns boolean</p> <p><strong>How to model the likelihood?</strong> Who has the responsabiloity of the likelihood? It doesn't belong to the fisherman, or to the pond. In this example there is a relationship only to daylight, in real world it is probably linked also to fisherman, fishingrod and pond.</p> <p><strong>How to model the external factor (daylight)?</strong></p> <p>Any comment is welcome. Also code samples.</p> <p><strong><em>UPDATE:</strong> The first comment to the question and tdammers's answer force me to be more specific. As I wrote above "it is a supersimplfied version of a real world case", anyway let's say I want to increase the complexity later, not super increase it, let's say increase it enough so that it is good to have all the classes I listed above (for example becuase I keep track of how many fishes are there in the pond, how tired is the fisherman, ...). Anyway the most interesting questions for me are "how to model the likelihood" and "external factors". Treat this as a newbie question for people that has not many skills in OOAD.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload