UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Architecture

Forums > Swift

Ok fellow HWS members,

I have been trying to decide which architecture is best, MVVM, MVC etc. It seems everyone has there own opinion and don't mind sharing it with you or telling you that your wrong for using that particular architecture. So I want to know everyones opinion. Please give me your honest thoughts.

Does MVVM work well with SwiftUI or is there a better architecture?

Some of my thoughts on MVVM are this: (keep in mind I'm new to MVVM and have never worked with it, I've followed several tutorials that use it. So thats my current exposure to it)

  • I think it makes the project easier to read and understand.
  • I like how it seperates out the logic of the view from the view itself which makes your view code smaller and easier to maintain.

So Im wondering what you all think? Which architecture do you prefer and why.

Would really love to hear you alls thoughts on the subject.

2      

hi,

(i have already talked to @appledad05 off line about this, but i thought i would put it out there for everyone.)

  • i think MVVM works really well when the VM (View Model) vends structs to its client views. SwiftUI loves structs. no view can change the data it was given on its own because it is all a copy of something. so the View really has to go through a VM to make changes to the back-end model. (one phrase i like to use is that a VM is in the business of handling "user intents," and i would refer you the the Stanford videos with Paul Hegarty on this notion of intent.)

  • design gets complicated when the data handled by a view are objects (classes), which is the case in apps that use Core Data. in that case, it seems common practice that Views will make changes directly on an object; and the View then hopes that you have enough @FetchRequest and @ObservedObject constructs in your code to back-end the changes it has made.

i think MVVM is somewhat the future because of the first point; it's hard to think that Apple thinks otherwise, based on the WWDC videos of the last two years.

hope that helps move the discussion,

DMG

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.