Artem
Posted on June 21, 2020
Quick warning- I tend to use framework and design pattern interchangeably.
Back in 2016 I remember seeing a lot of job openings seeking Unity developers with working knowledge of MVC framework. At the time it didn't make too much sense to me considering Unity primarily supports the Component framework. Thus I set out on a mission to create a project using the MVC framework exclusively.
TL;DR - it didn't end too well.
Here's what I learned along the way!
What actually is MVC?
MVC stands for Model-View-Controller.
Each of these are specific functionalities for working with data.
The model stores your data and manipulates it.
The view displays your data, generally you want to keep your view dumb (that is to day, it shouldn't store or manipulate any data).
The controller will fire off commands to your model to do stuff with your data.
Don't try to use one framework for your entire project
Much like how you'll often hear people telling you to not over use Singletons you shouldn't try to over use MVC. All frameworks have their specific functions and support specific features.
A good time to use MVC
I found that in instances of storing, manipulating, and displaying data (like keeping track of score, multiple choice answers, instructions, etc.) MVC is super useful.
I was able to decouple the logic behind multiple choice questions, which is super helpful when it's a last minute add from the UX team and nobody knows how it will look, or how the user will input the data, or what any of the questions or answers are.
A not so good time to use MVC
When you're trying to manipulate game elements like tiles in a match 3, or like 3D objects in a VR application, or storing state in your experience.
However, MVC is really good for manipulating chess or checker pieces on a game board.
Conclusion
MVC is a tool first and foremost, like all other frameworks and design patterns you should pick and choose which works best with what you are trying to do. If you find that using a specific style of coding is making your application harder to maintain, debug, and update then maybe consider not using it as much (or at all).
Are there any frameworks or design patterns you enjoy using?
Posted on June 21, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.