Here’s a Pop Star Analogy To Deduce MVVM Architectures | by Ricardo Montemayor | Jul, 2022

Defined via illustrations

Photograph by Jason Leung on Unsplash

Coming from an MVC (Mannequin View Controller) background, I’ve struggled to know the architectural sample of MVVM (Mannequin View View-Mannequin). What tasks ought to every View have? What’s the objective of the View-Mannequin? The place does all of the enterprise logic go?

I’m going to point out you the analogy that helped me higher apply the MVVM sample to my initiatives.

This analogy takes place within the leisure world.

The Pop Star (View)

Her duty is to get herself on the market. She is the face of the entire operation. She must look the prettiest, she must work together along with her followers and she or he must placed on an ideal present.

Tasks:

  • Placed on an ideal present and look the prettiest for her followers
  • Sing songs
  • Work together with followers (Deal with person enter)

Her Followers (Consumer enter)

From their standpoint, the Pop Star is the one factor that exists; they don’t know or care what goes on behind the operation. They scream when she sings an ideal track and a few even write her fan letters.

Tasks:

  • Scream after they hear an ideal track and write the Pop Star fan letters.

Her Supervisor (View-Mannequin)

He has quite a bit on his plate, even when he’s barely seen, he has to always inform the Pop Star the place and when the subsequent tour is, what she’ll put on, how she ought to reply to sure interview questions, and what Tune to sing.

A whole lot of this info is just not supplied by the Supervisor itself, he delegates it by speaking with the surface (Advertising Company, PR Company, Report Producer, and many others.), and when receiving the knowledge again, talks to the Pop Star so she will be notified with the most recent info.

The supervisor could be very attentive to any suggestions from the followers. If the followers should not glad, he all the time is aware of precisely how the Pop Star ought to reply.

Tasks:

  • Present the Pop Star with all the knowledge wanted (what to put on, what track to sing, how to reply to interviews)
  • Obtain fan’s suggestions and inform the Pop Star tips on how to reply
  • Delegate tasks which are out of his capabilities (Advertising Company, PR Company, Report Producing, and many others.)

Tune (Mannequin)

The Pop Star receives the songs to sing from her Supervisor, who will get the songs from the Report Producer.

Tasks:

  • Be a track (which features a title, lyrics, notes, and many others.)

Report Producer (Companies)

They produce songs. They include all of the enterprise logic the Supervisor doesn’t have to have.

They don’t write songs completely for the Pop Star, they will produce songs for anybody. They simply want sure parameters to know precisely beneath which context the track must be produced.

The Supervisor goes to those guys and asks them for an upbeat pop track.

Tasks:

  • A Supervisor (View-Mannequin) can handle a number of Pop Stars (Views)
  • A Pop Star (View) has just one Supervisor (View-Mannequin)
  • A Report Producer (Service) is totally unbiased.

Thanks for studying. I hope this analogy was considerably useful.

More Posts