01 logo

MVC - Model View Controller

MVC in iOS Development

By ConficlePublished 2 years ago 4 min read
1

Hello all, we are back with our next article after a long break. In case you would like to refer to our previous articles, you can find them here.

In our this article we are going to talk about a very common architecture MVC(Model View Controller). We will first understand what is MVC and then we will see how it is perceived in modern mobile development. Let’s start.

What is MVC?

We are sure almost every software developer going through this article will be aware of this architecture. However, still let us define what MVC is.

MVC stands for Model, View and Controller. This architecture says that any software application should have these 3 components. Which any of the classes created should fall under one of these components. Let us understand these components in detail.

  1. Model: This component is nothing but a data model class. This class should not contain any code related to UI or logic. Model is a class that describes the characteristics of any entities. For example class called Person, User etc are most common example of a Model class. Model classes are often classified as data layer as well.
  2. View: This component contains classes that contain only UI code. These classes represents UI which is visible to user of the applications.
  3. Controller: This component contains classes that are responsible for communication between classes of above 2 components. The classes in this component also contains the business logic.

Apple’s MVC

Apple’s iOS SDK has bit modified MVC architecture as below

Apple’s UIKit has bound View and Components in UIViewController. This bond between View and Controller components give rise to few problems.

Problem’s with Apple’s MVC

  • Tight coupling between View and Controller binds the UI and logic due to which unit testing of logic becomes difficult due to presence of UI code.
  • This bond also breaks the Single Responsibility principle which is denoted by ‘S’ in SOLID principles.
  • With time as application grows UIViewController class keeps growing which gives MVC a new full form – “Massive View Controller”.

Apart from above problems MVC as a general also has below cons

  • Code complexity increase with growing user interface and features.
  • View could be overburden with updates, if model keeps growing
  • MVC architecture is hard to understand with frequent updates and increase code base.
  • The Controller component, keeps an eye over the events that are triggered by the View component. Further, it aims to provide an appropriate reaction to all these events, which are mostly known as Method. These methods do not have strict access, which in turn becomes one of the major drawbacks of the MVC.

Though MVC has above cons. However this architecture is has got below advantages as well.

Pros

  • Fewer number of classes leads to faster development
  • Simultaneous development – Multiple developers can work simultaneously on model, controller and views.
  • High cohesion – MVC enables logical grouping of related actions on a controller together. The views for specific model are also grouped together.
  • Low coupling – The very nature of the MVC framework is such that there is low coupling among models, views or controllers.
  • Multiple views could be created using the MVC model. With the increasing demand for accessing the application in new ways, MVC architecture aims to provide the best solution for the same. Furthermore, code duplication is limited in it.
  • MVC supports asynchronous techniques which further helps the developers to build quick loading apps.

Conclusion

  • MVC can be used for rapid prototyping.
  • MVC is not an industry standard anymore for modern mobile development.
  • Can be overkill for small application like marketing apps, apps which are definitely not growing and apps that requires faster time to market.

So this was a highlight about MVC architecture in modern mobile development.

That’s it for this article. We hope we are able to explain details, pros and cons of MVC architecture.

Thanks for reading this article. If you have any queries related to this topic or iOS, Objective C and Swift. Please write us at [email protected] or direct message us on instagram at conficle(instagram username).

Also keep watching this space for upcoming articles on iOS development, software development and technology concepts.

tech news
1

About the Creator

Conficle

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.