News for hackers. Stuff that matters.

swiftaccount1

Re:Swift Protocol Oriented Programming and Testing on Friday July 30, 2021 @05:39PM (#28012692)
I basically agree with you, actually. It feels like a lot of this is breaking down into semantics. I’m not fond of acronyms, I believe it’s important to go to core principles and never do anything blindly, but only when it’s useful.

The fundamental challenge of iOS architecture is picking the right level of abstraction for the complexity of your application.

The trouble that comes in with MVC, as I see it, is how easy it is to shoot yourself in the foot. It’s too easy to do it “wrong”, which is why so many have tried to come up with something different. Of course you can’t escape the MVC-ness of the platform, it’s all about how you manage it.

Re:Swift Protocol Oriented Programming and Testing on Friday July 30, 2021 @03:56PM (#28011726)
Yeah, sorry for the choice of words; I just fired something off with no editing. In my mind, I was thinking of MVC at it's worst (which is unfortunately common).

That being said, would love to learn more about how you structure code. What does a project structure look like for you? I usually conceptually try to separate the view and data starting with the simplest file structure and dividing as needed.

Re:Swift Protocol Oriented Programming and Testing on Friday July 30, 2021 @02:26PM (#28010795)
I'm not sure if I fully agree with that. It's true that you can spaghetti with any pattern, but I think on multi dev teams it helps to have guidelines about what goes where to ensure a clear separation of responsibilities. Someone linked another thought provoking article here about how MVC does not have to equal spaghetti which I found interesting. But I also think we need to take a step back and ask, "why have so many ended up with the same result?"
Re:Swift Protocol Oriented Programming and Testing on Friday July 30, 2021 @02:24PM (#28010776)
That's an interesting article. I find iOS architecture fascinating and spend a lot of time thinking about it. It seems like "MVC" in common usage (based on talking to other iOS devs) means spaghetti, but I guess it doesn't have to be like that.

To me that article proposes a more disciplined MVC than what I've seen in real codebases. I think a lot of the architectures people come up with (like the second one you linked) try to build that discipline in. I try not to be dogmatic and instead go to core principles. Do I know what this class is supposed to be doing? Are my data and view layers reasonably separated with minimal glue code? Can a new dev easily navigate this project?

It's an endless discussion with no right answer. Thanks for sharing!

Re:Swift Protocol Oriented Programming and Testing on Friday July 30, 2021 @01:49PM (#28010478)
I made a new account just to ask this: 'MVC works really well and scales really well" Is this a joke? Do you have any professional iOS experience?

MVC is famous for scaling terribly on iOS and resulting in view controllers with thousands of lines. MVC is great for small apps. No need to overcomplicate things. But if you're building something bigger, you should look into using the right tool for the job. Don't blindly follow a popular pattern, but choose the right pattern to make the code easy to read, easy to test, and easy to modify.