Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider extracting a "actor that play in film" to another class, to decouple film out of actor (actor can also do theathre spectacles, vioce dubbig etc, not specialy movies.)</p> <pre><code>class ActorRole { private Actor actor; private Movie movie; private int dollarsSallary; private int scenesPlayed; // etc. } </code></pre> <p>If you don't want to, I'm almost sure that <strong>better create dependency from Movie to Actor</strong> than from Actor to Movie, because Movies almost surely have actos:</p> <pre><code>class Movie { private List&lt;Actor&gt; actors = new ArrayList&lt;Actor&gt;(); } </code></pre> <p>This makes harder to count actor statistics (you have to iterate over all Movies) but I think this is a better design.</p> <p>To count single actor shows:</p> <pre><code>for ( Movie movie : listOfAllMovies ) { if ( movie.getActors().contains( myActor ) ) { // read about equals() in Java ! timesPlayed++; } } </code></pre> <p>If you want to make a ranking for more actors, you can use <code>Map&lt;Actor,Integer&gt;</code> to map actors to they times played counters.</p> <p>This can be a lengthy operation, so you can think about cashing the results (like in above map) - the solution can be map, ActorStatistics class, simple timesPlayed field in actor etc. etc.</p> <p><strong>Don't be afraid to objects</strong></p> <p>Don't do a hard workaround to mape films to id (like your <code>id</code>, which is propably connected to your film code <code>String</code>, wich add another type-incompatibility issue. Try to use more object references instead of workarounds, and <code>List</code> instead of array.</p> <p>Generally, read about <strong>Collections</strong> in Java, like <code>ArrayList</code> and <code>HashMap</code> and also overriding <code>equals()</code> and <code>hashCode()</code>, and in general OOP <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="nofollow">Single responsibility principle</a> and <a href="http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29" rel="nofollow">Class cohesion</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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