Question

I'm learning OOP so I decided to start a new project, a chess tournament manager.

Here you can read about chess tournaments https://en.m.wikipedia.org/wiki/Chess_tournament

Basically the user will be able to add players to the tournament, remove them, register the results of the games, change them, pair new rounds, so on and so forth.

The first thing I did was the objects modeling, so this is the UML diagram

enter image description here Note: Showable is an interface.

My reasoning was this:

A tournament is composed of games and arbiters and games are composed of players. Since players and arbiters are FIDE profiles, both inherit from FideProfile class. Finally the user interact with the tournament (I'm just considering the bussing logic so I didn't designed any login/logout system).

So, my questions are:

  1. Is my reasoning correct?
  2. Is this modeling too complex?
  3. How would you make it simpler and better?

I hope your feedback and advice.

Thanks in advance.

Was it helpful?

Solution

This is fine for a start, but you're pretty data-heavy.

Object-orientation is about cooperation among objects, with each bringing its own specific knowledge and behavior to contribute to the whole. At this point the only behavior is in User, which you describe as some sort of "UI" to interact with the data.

Instead of that, forget about the data for a minute and concentrate on what this model is supposed to do. Then try to distribute and/or decompose that problem in a way that all objects can contribute behavior, instead of data.

Here's a rule of thumb: Each time you're thinking about accessing data from another object, you are trespassing on that object's responsibilities, which means the responsibilities (the design) probably need correcting.

Ideally, if this is a self-contained application and not a library, you shouldn't access data from other objects at all.

OTHER TIPS

There is a general rule of thumb "prefer containment over inheritance". Like all "prefer" rules, this isn't a demand that you must do something, but a suggestion to stop and think about the alternative.

Inheritance is an "is a" relationship. Containment is a "has a" relationship.

In your case, is it true that Player is a FideProfile, or Player has a FideProfile?

Licensed under: CC-BY-SA with attribution
scroll top