samedi 25 février 2017

Using the MVVM pattern with Unity Engine as front end

I plan to make some applications whom will help me organizing tasks from home or from somewhere else. For this I need a database server (a virtual one running at home), a backend part (the business logic) and the front end (the view). At school we learned the MVVM via WPF, but to be frank I use it only when it is explicitely required. There are a lot of benefits in favour of Unity like

  • Artist friendly
  • Can compile to mobile, web and desktop
  • Fast development (in my case at least)
  • Has a lot of built in features I can harness.

Now, Even as simple as I will make an app like this, sometimes I might want to extend it, improve it or change some components entirely. I know how to use MVVM in WPF but I only have some vague ideas for the Unity implementation which I would like someone skilled to overview.

The front end (Unity) would take care of sound management, fancy animations and the UI itself. But UI button events cannot access directly the database, so I thought of building some Bridge Classes. Say I want to delete a reminder, as an easy example. In an OnButtonClicked() method I would just call a BridgeClass's PleaseDeleteThis(MyReminder) and inside that method there's the backend solution that actually finds that reminder by id and removes from the database, then sends an everything all right flag back to the front end app so I know it was successful. What I thought of is that using these bridge classes I wouldn't have to worry about what happens if I change the database server or the front end, as all they have to know is communicating with the bridge. I know the example was over simplified, but how doable would this one be regarding the component integrity and the MVVM pattern?

Aucun commentaire:

Enregistrer un commentaire