Abstracting UI elements
We still need to add the image and video content. We could go ahead and add them into our current software design, but we're starting to see a pattern emerge in how we've set things up, and it might make sense to refactor our code, abstracting out some of the common elements.
Note
Refactoring in software development means reworking parts of your code to make it cleaner, more maintainable, and more extendable without modifying the behavior or features.
In this case, we're going to refactor how the controller updates the screen by abstracting out our UI elements. If you noticed, each time we add a new UI element to the view or the model, we need to modify and add it to the controller. It would be cleaner if the controller could just broadcast the fact that there's new data, and the UI elements, listening for such events, could go ahead and update themselves on the screen.
So, we're going to make our own little event system, called InstructionEvent
, using UnityEvent
.