在 MVC 视图中处理临时更改请求的提示

发布于 2024-11-14 17:02:04 字数 414 浏览 2 评论 0原文

我正在开发一个应用程序,该应用程序的某个特定功能收到了临时更改请求。具体来说,该企业目前只想管理给定客户的实际地址,并希望我们删除添加邮寄地址的选项。

将来很可能需要重新引入此功能,因此,我想知道目前处理删除的最佳方法是什么。在 ViewModel 上拥有额外的属性不一定是个问题,但它很混乱。当涉及到视图本身时,问题就更大了。我们需要删除 UI 元素,但是,我们需要方便将来将其恢复。

那么...我是否注释掉不需要的代码位?这是最简单的方法,但是很混乱。

我要创建一个新的 View 和 ViewModel 吗?如果是,那么将原件存放在哪里合适?我们的应用程序处于源代码控制 (SVN) 之下,因此,理论上我们可以回到此修订版,但是,对于如此小的更改来说,这似乎有点矫枉过正。

还有其他人遇到过类似的情况吗?关于如何最好地处理这个问题有什么建议吗?

I am working on an application, for which a temporary change request has come in to a given feature. Specifically, the business currently only wants to manage a Physical address for a given customer, and wants us to remove the option to add a mailing address.

This feature will most likely need to be re-introduced in the future, so, I am wondering what the best way to handle the removal would be for now. Having additional properties on the ViewModel is not necessarily a problem, but, it's messy. And there is even more of a problem when it comes to the View itself. We need to remove the UI elements, but, we need to make it easy to bring it back in the future.

So...do I comment out the unneeded code bits? This is the simplest approach, but, it's messy.

Do I create a new View and ViewModel? If so, where is the appropriate place to store the original for safe-keeping? Our application is under source control (SVN), so, we could theoretically come back to this revision, but, it seems like overkill for such a small change.

Has anyone else run into a similar situation? Any recommendation on how to best handle this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡離愁欲言轉身 2024-11-21 17:02:04

那么...我是否注释掉不需要的代码位?

不,那会非常混乱。这就是版本控制的目的。

我要创建一个新的视图和视图模型吗?

是的,换掉原来的。

如果是,哪里是保存原件的合适位置?

版本控制。

我们的应用程序处于源代码控制 (SVN) 之下,因此,理论上我们可以回到此修订版本,但是,对于如此小的更改来说,这似乎有些过大了。

矫枉过正?不,这就是 VCS 最擅长的 =>他们保留修订历史记录。您也可以考虑创建一个标签,以便稍后可以轻松返回。

So...do I comment out the unneeded code bits?

No, that would be very messy. That's what version control is intended to do.

Do I create a new View and ViewModel?

Yes, replace the original.

If so, where is the appropriate place to store the original for safe-keeping?

Version control.

Our application is under source control (SVN), so, we could theoretically come back to this revision, but, it seems like overkill for such a small change.

overkill? No. That's what VCS do best => they keep revision history. Also you might consider creating a label so that you can easily come back later.

梦与时光遇 2024-11-21 17:02:04

什么视图引擎?事实上,这可能重要也可能不重要。

从“我以后可能需要这个”的角度来看,我会考虑移动暂时消失并可能重新出现在 MVC 用户控件中的 UI 位。与到处注释代码相比,它没有那么“混乱”。然后您可以暂时排除它。

至于视图模型?有几种可能性。短杆肯定会向 ViewModel 添加位,即使没有使用,但这意味着您正在旋转未使用的数据,并且没有明确的使用时间范围。但是,当您需要额外信息时,您始终可以创建派生类,并在开始使用它时让用户控件将视图模型强制转换为派生类(协变和逆变是您的朋友),从而使代码更改相当小当企业“清醒过来”时。

What view engine? Actually, that may or may not matter.

From a standpoint of "I may need this going forward", I would consider moving the UI bits that are going away for now and may reappear in an MVC user control. It is less "messy" than commenting out code all over the place. You can then exclude it for now.

As for the ViewModel? There are a couple of possibilities. The short pole is certainly adding the bits to the ViewModel, even if not used, but that means you are spinning up data that is not in use with no clear timeframe for when it will be used. But you can always create a derived class when you need the extra information and have the user control cast the view model to the derived class (co-variance and contra-variance are your friends) when you start using it, making code changes rather minor when the business "comes to its senses".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文