Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think that its a good idea to mix concerns in one method. One method should do one thing (e.g. createImagePack, createArtist, associateImagePack, deleteArtist etc). However what you can do it combine the calls to logically related methods into one method call to create composite functionality using the Façade pattern.</p> <p>In your façade class you will have a method defined as follows:</p> <pre><code> public Artist createImagePackAndArtist(String artist_name, String artist_desc){ ImagePack imagePack = new ImagePack(); Artist artist = new Artist(artist_name, artist_desc); artist.associateImagePack(imagePack); return artist; } </code></pre> <p>Here you are combining functionality/method calls into one single method.</p> <p>From the returned object Artist you can call methods to return the ImagePack object for the artist, then the imagePack_id, the artist_id from the Artist object etc.</p> <p>The object of the façade is to provide convenient methods. You could create another method that adds a new image pack to an artist that already exists.</p> <pre><code> public void createImagePackForArtist(Artist artist){ ImagePack imagePack = new ImagePack(); if (artist != null) { artist.associateImagePack(imagePack); } else { // throw ArtistIsNullException } } </code></pre> <p>Ideally you would check to see if the artist exists before attempting to associate the image pack. This would happen outside the façade.</p> <p>Also have a look at the Factory pattern. You could implement this instead of creating the objects yourself. Also take a look at the singleton pattern. Façades and factories are often singletons.</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.
 

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