User:OliverCharles/ServerManual/Facades

From MusicBrainz Wiki

Server Manual > Facades

What are facades, and what's the need?

Facades are wrappers around the already existing entities in MusicBrainz. They take an instance of the object, and then provide methods to access the variables - often along with some helper methods to reduce the amount of logic in templates.

But why do we need them? Firstly, the current server has a somewhat awkward naming scheme, where by methods are named in CamelCase, and prefixed with Get or Set. This is very verbose and makes templates seem more complicated than need be. Secondly, the current entities expose a lot of methods that should not necessarily be callable from templates. The facades expose a read-only interface, so this solves this problem. And due to this read-only interface, it means we can easily throw the object around controllers through chaining.

You probably will not need to explicitly instantiate facades - this is the models job. However, you will probably end up working with them (especially in templates) - so it's worth knowing what methods you can call.

Facades

  • Introduce Class::Accessor briefly
  • Alias
  • Annotation
  • Artist
  • CdToc
  • Label
  • Link
  • Release
  • ReleaseEvent
  • Track
  • Url