mardi 11 décembre 2018

Design pattern name: Object of ClassA acts like a "class" for objects of ClassB

I have two Classes* and I'm not sure what to call the relationship between them. Objects of ClassA are kind of like Classes ("archetypes" or "patterns") for Objects of ClassB.

  • A Song has a title and artist.
  • A SongDimension (ClassA) has a label (e. g. "Genre"; "Loudness") and a Set of AcceptableValue's (e. g. "Classic Rock", "Classical", "Reggae"; "9", "10", "11").
  • A Song has a Set of SongDimensions, and for each SongDimension, it has exactly one SongDimensionValue (ClassB), that tells which of the AcceptableValue's for that SongDimension applies to this Song.

I'm trying to search for best practices using this pattern (or alternatives, if this isn't a good pattern to use), but I don't know what to call it. To me, it seems like Objects of SongDimension are almost like a Class for Objects of SongDimensionValue. However, when I search the Internet using terms like that, I just get basic articles about what Classes and Objects are.

Is there a name for this pattern?

* I'm using Java terms (Class, Object), but this pattern could be applied in any OOP language.

Aucun commentaire:

Enregistrer un commentaire