TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A short introduction to the MVVM-C design pattern

56 点作者 andygrunwald超过 8 年前

7 条评论

w0utert超过 8 年前
This article addresses some interesting, real-world problems with the MVC pattern, problems I&#x27;ve run into myself. When writing iOS applications I also usually end up with something that is better described as M-VC than MVC, where the view and the controller are tightly coupled and usually implemented by the same class. This is not how the MVC pattern was intended.<p>From a cursory read I like the architecture improvements they propose to &#x27;fix&#x27; this situations. That said, I can&#x27;t escape the feeling that for the majority of applications, this is way over-designed&#x2F;over-engineered, and putting the cart before the horse. Your application should not be written to better suit the MVC (or MVVM-C) pattern, it should be the other way around. Often a merged VC class gets the job done just fine and keeps things simple and concise.<p>In my experience, my own applications end up with a single class that&#x27;s both the view and the controller, for the simple fact that there is no reason to decouple them. I&#x27;m usually not interested in having multiple user-interfaces on top of the same model, so there is no incentive to re-use the controller. Note that IMO there is a clear distinction between decoupling the model from the view and&#x2F;or controller (which is almost always desirable to separate data and presentation), and decoupling the view from the controller (which have a lot of overlapping resposibilities)<p>To be fair, I haven&#x27;t written any applications that hat different UI for e.g. iPhone and iPad, and I haven&#x27;t written any applications that also have a desktop counterpart. But even in those situations, I&#x27;m wondering how much there is to be gained from re-using controllers for different user interfaces...
评论 #12366123 未加载
评论 #12365793 未加载
评论 #12366753 未加载
bsaul超过 8 年前
This whole debate about mvc vs mvvm vs i don&#x27;t know what really start to read like a joke.<p>Here&#x27;s the truth : your app probably has more than three major components, and the GUI isn&#x27;t the most important aspect of it. Build your app as if it was to be accessed through a command line or a repl, then add a GUI on top in the end.<p>You&#x27;ll have reusable, business centric components, and your controllers ( or whatever you call it) won&#x27;t be bloated.
评论 #12366353 未加载
评论 #12367351 未加载
评论 #12369542 未加载
评论 #12365880 未加载
afro88超过 8 年前
If you&#x27;re using storyboards, another way of solving this is to let your segues set up the view models of the source and destination view controllers. You just need to create some segue subclasses for each source&#x2F;destination combo you need.<p>Better than polluting prepareForSegue, and it totally decouples your UIViewControllers from each other. The coupling is in the segue, which is where it should be.
currywurst超过 8 年前
A relevant previous HN discussion on Martin Fowler&#x27;s &quot;GUI Architectures&quot; article (<a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9770362" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9770362</a>)
achr2超过 8 年前
I work in an MVVM mode daily. The best MVVM frameworks help bootstrap the app shell, but require zero interfacing with the view afterwards, with the &#x27;controller&#x27; just being a parent ViewModel. It&#x27;s turtles all the way down.
omn1超过 8 年前
trivago standing by to answer your questions :-)
评论 #12366323 未加载
HelloNurse超过 8 年前
s&#x2F;Coordinator&#x2F;Controller&#x2F;g