WebForms / MVC 到 Windows 窗体程序员

发布于 2024-08-03 21:38:42 字数 2353 浏览 8 评论 0原文

首先我想澄清一下,我并不是在寻找“我的技术比你的更好”类型的帖子;这是一个真实的案例,我也曾面临过这个决定。考虑到这一点,让我解释一下:

我们有一个 WinForms 应用程序。它始于早期的 .NET 1.0,但第一个发布版本使用 .NET 1.1。有层(如 BusinessLayer.dll、Datalayer.dll、Framework.DLL 等),但在该应用程序的“漫长”开发周期中的某个时刻,“表示”层(Win Forms )感染了某些代码,因此“代码和带有代码的演示文稿之间的分离”是某种神话。 不好的做法或其他什么,事实是应用程序已经存在并且可以工作。

几年过去了,我们有了 .NET 2.0,我们慢慢地迁移,它基本上可以工作,必须在这里或那里更改一些调用。上一个版本做了同样的事情,但适用于 .NET 3.5sp1。我们需要某种 Web 服务,因此决定使用 WCF。效果很好。 但尽管进行了所有这些 .NET 升级,该应用程序的大部分代码库仍然是 5 年前的老样子。我们使用 Gentle.NET(旧的并且现在不再维护)作为我们的数据对象(这在 5 年前是一件幸事!)。

我们的表示层 winform“看起来很漂亮”,因为我们使用了 90% 的完全 gdi+ 自定义控件。 (只要有可能,无需破解 WinAPi)。该应用程序是基于触摸的(即:它使用墨水,但不依赖于此),但按钮、标签等,一切都“设计”为与触觉设备一起使用。 (平板电脑或触摸屏)。当然,有些用户使用键盘/鼠标。

考虑到所有这些,以及所有这些 web2.0 和互联网模糊(加上 Jeff 的帖子;)),我们正在考虑重写应用程序但使用 Web 技术的可能性。 这个想法显然是为我们的客户带来更多的可用性(他们可以随时随地使用系统),并减少维护(我们可以升级,这对他们来说都是即时升级)等。你知道,通常的互联网与 WinApp 之类的东西。

问题是,鉴于这是医疗保健行业,并非所有客户都愿意将他们的数据库“移动”到我们的服务器,这是可以接受的,并且会迫使我们在自己的服务器中安装网络服务器/数据库服务器服务器,以便他们有自己的副本。不是一个大问题(除非我们必须手动更新这些,但这不是问题,因为我们已经更新 win32 应用程序 5 年了!)。

现在,回到主要的“问题”。

该团队几乎没有 Asp.NET 经验,我们在 ASP 2.0 中进行了大量编程(1999/2000 年),但那只是 HTML+VBScript+CSS 的意大利面条,所以我认为这并不重要。在经历了所有这些经历(互联网泡沫!)之后,我们回到了 VB6,然后是 C#.NET 1x,接下来的故事你就知道了。我们是一个由 WinForms 的 C# 开发人员组成的小团队。我们在上次 .NET 3.5 之旅中获得了一些 Linq To SQL 体验,并且我们喜欢它。我们觉得这非常自然,非常“如果我们五年前就有这个……”就像。

鉴于这一切,重写应用程序并不是一个“简单的任务”(即使我们想在已知的 C#.NET 中完成它),它需要时间和计划,但我们可以在 5 年内纠正数十个错误凭借使用该应用程序的经验,我们现在可以说,我们更好地了解了客户希望如何使用该软件以及我们在设计当前应用程序时(我们自己)创建了哪些限制。 应用程序和业务运作方式的所有“知识”都可以用来生成在设计、代码和可用性方面更好的应用程序。请记住,在 .NET 1.1 中我们甚至没有泛型! ;)(你会看到这里有很多 ArrayList)。

作为补充说明,我们使用 Crystal Reports(并且像往常一样,我们讨厌它)。我们也不认为墨水控制是“必须的”。 HTML/CSS 可以按照我们想要的方式进行调整,尽管我们知道 HTML 不是 WinForms(因此有些东西无法重现)。

您是否认为在 MVC(或 WebForms)中计划这个太疯狂了? 我喜欢 MVC(类似 ruby​​ on Rails)的想法(除了本书的基础知识之外,我从未用 ruby​​ 进行过编程),所以我们团队中没有人是专家,但我们总是可以学习和阅读。它一定不是“火箭科学”,不是吗?

我知道整个问题可能有点主观,但是您会用新的 ASP/MVC/XXX Web 应用程序替换老化的 Winforms 应用程序吗?您有经验或尝试过(成功或失败)吗?

任何有助于用户更好地决定做什么的见解都将受到赞赏。

提前致谢!

更新:感谢所有回复的人,我们将评估这是否是一个好的举措,这确实是一项艰巨的工作,但我担心桌面应用程序正在变得越来越旧(使用旧的net 1.1 hacks),虽然它在 Vista 和 W7 中或多或少工作没有问题,但恐怕未来的更新可能会破坏它。 此外,应用程序的许多“或多或少的核心”部分暴露了一些设计糟糕的想法,我们不得不到处破解才能完成某些任务。部分原因是缺乏经验,部分原因是对业务运作方式缺乏 100% 的了解(而且客户不确定他们想要什么)。 新的应用程序(任何形式)将使我们能够创建更好的基础,同时保留所有用户知识。 但是,这是一项繁重的工作:) 因此我们将在这里考虑所有这些选项。 正如你们中的一些人提到的,也许更瘦的客户端和一些(滥用)使用 WCF 可能更合适。

再次感谢大家!

First I'd like to make it clear, I'm not looking for a "my tech is better than yours" type of post; this is a real case scenario and I have been faced with this decision. With this in mind, let me explain:

We have a WinForms application. It started in the early .NET 1.0 but the first shipping version was using .NET 1.1. There are layers (like BusinessLayer.dll, Datalayer.dll, Framework.DLL, etc.) but at some point during the "long" development cycle of this application, the "presentation" layer (Win Forms) got infected with some code, thus the "separation between the code and the presentation with code behind" is some sort of myth.
Bad practices or whatever, the truth is that the application is there and it works.

Years passed and we had .NET 2.0, we slowly migrated and it mostly worked, had to change a few calls here and there. Last version did the same thing, but for .NET 3.5sp1. We needed some sort of Webservices thing, and decided to use WCF instead. It works fine.
But despite all these .NET upgrades, most of the application's codebase is still the same old rock and roll from 5 years ago. We use Gentle.NET (old and unmaintained now) for our dataobjects (it was a blessing 5 years ago!).

Our presentation layer, the winforms, are "nice looking" since we employ 90% of completely gdi+ custom controls. (whenever possible without having to hack the WinAPi). The application is touch based (i.e.: it makes use of the Ink but it doesn't rely on that), but the buttons, labels, etc, everything is "designed" to be used with a tactile device. (TabletPC or Touchscreen). Of course some users use keyboard/mouse.

With all that in mind, and with all this web2.0 and Internet fuzz (plus Jeff's posts ;) ), we are considering the possibility of rewriting the application but using a web technology.
The idea is obviously bringing more availability for our customers (they can use the system whenever/wherever they want), and less maintenance (we can upgrade and it is an instant upgrade for 'em all), etc. You know, the usual Internet vs WinApp thingy.

The problem is that given that this is the healthcare industry, not all of our customers might be willing to "move" their databases to our server/s, which is acceptable, and would force us to install a webserver/database server in their own servers so they have their own copy. Not a big problem (except we would have to update those manually but that's not an issue, given that we've been updating win32 apps for 5 years now!).

Now, back to the main "question".

The team has little Asp.NET experience, we did program a lot in ASP 2.0 (in 1999/2000) but that was a spaghetti of HTML+VBScript+CSS, so I don't think it counts. After all that experience (the Internet bubble!) we went back to VB6 then C#.NET 1x and you know the rest of the story. We're a small team of C# developers for WinForms. We've acquired some Linq To SQL Experience in our last .NET 3.5 ride, and we liked it. We felt it very natural and very "if we would have had this five years ago…" like.

Given all this, rewriting the application is not a "simple task" (not even if we wanted to do it in the already known C#.NET), it would take time and planning, but we could correct dozens of mistakes and with 5 years of experience working with the application, we now can say that we have a better idea of how the customers would like to use the software and what limitations we created (by ourselves) when we designed the current app.
All that "knowledge" of the application and the way the business works, could be applied to produce a much better application in terms of design and code and usability. Remember in .NET 1.1 we didn't even have generics! ;) (you'll see lots of ArrayList's hanging around here).

As an additional note, we use Crystal Reports (and, as usual, we hate it). We don't think the ink control is a "must" either. The HTML/CSS could be shaped to look the way we want it, although we're aware that HTML is not WinForms (and hence some things cannot be reproduced).

Do you think that planning this in MVC (or WebForms) would be too crazy?
I like the MVC (ruby on rails like) idea (I've never programmed in ruby beyond the basics of the book), so no one in our team is an expert, but we can always learn and read. It mustn't be "rocket science", must it?

I know that this whole question might be a little bit subjective, but would you replace an aging Winforms application with a new ASP/MVC/XXX web application? Do you have experience or have tried (and had success or failed) ?

Any insight in helping use better decide what to do will be appreciated.

Thanks in advance!

UPDATE: Thanks to all who responded, we'll evaluate whether this is a good move or not, it sure is a hell of work, but I am afraid the the desktop app is getting older (using old net 1.1 hacks) and tho it has been more or less working without problems in Vista and W7, I'm afraid a future update may break it.
Also, lots of "more or less core" parts of the application are exposing some badly designed ideas and we had to hack here and there to accomplish certain tasks. Part inexperience, part lack of 100% knowledge of how the business worked (and Customers not sure what they wanted).
A new application (in any form) would allow us to create a better foundation while retaining all the user knowledge.
But, it's a L O T of work :) So we'll consider all these options here.
As some of you have mentioned, maybe a thinner client and some (ab)use of WCF here and there might be more appropriate.

Once again, thanks to all!

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

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

发布评论

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

评论(3

甜心 2024-08-10 21:38:42

当您重新创建 Web 应用程序时,最好放弃重用桌面应用程序代码的所有努力。原因如下:

  1. Web 应用程序(尤其是 ASP.NET)使用不同的模型。首先请注意 http 是无状态的。每次浏览器与服务器对话时,您都必须显式发送当前页面上所有控件的当前内容。您不会在 Windows 应用程序中使用这样的模型。

  2. 为了减少网络负载,您需要优化视图状态的大小以及发出 http 请求的频率。同样,您现有的窗口应用程序没有任何此类规定。

  3. 正在更新视图。您可能有不同的事件处理程序、线程以及 Windows 应用程序中没有的内容来在不同场景下更新 GUI。所有这些都需要更换。 Javascript 是一种完全不同的动物。

  4. 安全。当使用浏览器时,您对本地磁盘的访问受到高度限制,而在 Windows 应用程序中您会认为这是理所当然的。如果 Windows 应用程序中有任何代码需要本地资源,那么这将是您的麻烦点。安全

我建议如下:

  • 验证您当前的应用程序是否有任何本地磁盘访问要求(例如读/写本地文件等)。
  • 当您编写不同的 http 模块或处理程序时,您可以尝试利用现有 Windows 应用程序的一些后端/业务逻辑部分。
  • 考虑一下应用程序的哪些部分可以成为 Web 服务。

It would be best to ditch all your efforts of reusing the desktop application code when you recreate the web app. Following are the reasons:

  1. Web apps especially asp.net use a different model. For starters note http is stateless. Each time the browser talks to server you have to explicitly send the current content of all the controls on the current page. You would not have used such a model in your Windows application.

  2. To decrease load on the network you want to optimize the size of viewstate and how frequent you make http requests. Again your existing window app does not have any such provisions.

  3. Updating view. You might have different event handlers, threads and what not in your windows application to update the GUI in different scenarios. All of that will need to be replaced. Javascript is a totally different animal.

  4. Security. When using a browser your access to the local disk is highly limited whereas you will take the same for granted in windows application. If there is any code in the windows app that requires local resources, then that is going to be a trouble spot for you.

I would recommend the following:

  • Verify if your current application has any local disk access requirements (e.g. read/write to local file etc).
  • As you write the different http modules or handlers, you can try leveraging some of the backend/ business logic part of the existing windows application.
  • Give some thought to what part of your application can become a web service.
臻嫒无言 2024-08-10 21:38:42

听起来应用程序需要大量重构来清理它。如果您想迁移到 Web 模型并获得最大程度的重用,您确实需要这样做。在转向 Web 模型之前,我认为您需要了解是否可以在该模型中复制您的用户界面。从客户的角度来看,这是你独特的卖点吗?您希望这样的决策是用户驱动的,而不是纯粹的技术决策。

听起来您的应用程序是胖客户端应用程序的完美候选者,而不是最低公分母 Web 模型。

需要考虑的一些事项:

  • 网络界面将如何影响平板电脑交互?
  • 网页版将为您带来哪些新客户?
  • 现有客户会放弃你的产品吗?
  • 您是否可以联系具有适当技能的顾问或外部资源来指导您进行网络技术?如果您不这样做,您可以依靠 StackOverflow 或其他网络资源来提供帮助。您需要一些良好的实地指导和指导。
  • 如果您开始这项努力并且花费的时间比您预期的要长得多,会发生什么?您了解该应用程序,但听起来不像您了解网络。过去的经验表明,像这样的大规模重写可能会以灾难告终(一开始听起来从来没有这么困难)
  • 您可以在基于网络的版本中编写新功能吗?
  • 您能否迁移到 ClickOnce 部署,以使应用程序更容易部署给客户? Web 的好处之一是更容易(零)部署。你能更接近那个吗?
  • 迁移到 WPF 并用它创建浏览器应用程序会更容易吗?
  • Silverlight 或 Flex 可能是创建丰富体验的更好选择,并且对于 WinForms 开发人员来说可能更容易上手。这有可能吗?

It sounds like the application needs a lot of refactoring to clean it up. If you want to move to a web model, and have maximum reuse you will really need to do that. Before you move to a web model I think you need to understand if it will be possible to replicate your user interface in that model. Is it your unique selling point from a customer perspective? You want decisions like this to be user driven rather than purely technical decisions.

It sounds like your application is the perfect candidate for a thick client application, rather than the lowest common denominator web model.

Some things to consider:

  • How will the web interface impact the Tablet interaction?
  • What new customers will having a web version bring you?
  • Will existing customers abandon your product?
  • Do you have access to consultants or outside resource with the right skills to mentor you in web technology? If you don't you can rely on StackOverflow or other web resources to help. You need some good mentoring and guidance on the ground with you.
  • What happens if you start this effort and it takes much longer than you expect? You know the app but don't sound like you know the web. Past experience shows that massive rewrites like this can end in disaster (it never sounds so difficult at the start)
  • Can you possibly write new features in a web-based version?
  • Could you move to ClickOnce deployment to make the application easier to deploy to customers. One of the benefits of the web is easier (zero) deployment. Can you get closer to that?
  • Would it be easier to migrate to WPF and create a browser application with that?
  • Silverlight or Flex might be better options for creating a rich experience, and may be more approachable for WinForms developers. Is this a possibility?
萌︼了一个春 2024-08-10 21:38:42

这似乎是你的应用程序。是最适合桌面应用程序的应用程序之一。尽管您希望您的用户能够访问您的应用程序。使用浏览器。

我建议尽可能多地重构,以便 GUI 变得更干净并且没有“代码”。
完成此操作后,开始开发 ASP.NET MVC 应用程序,但保留桌面应用程序。你应该能够使用除 UI 层之外的所有层,使其更容易/更快/...既然 mvc 存在,我想说 webforms 更多的是让非 web 开发人员做 web。但你了解 Web,并且想要控制,所以 MVC 是最佳选择。

It seems like your app. is one of those that works best as a desktop app. Though you want your users to be able to access your app. using a browser.

I would suggest refactoring as much as possible so that the GUI gets cleaner and don't have "code".
When you've done this, start developing a asp.net mvc app but keep your desktop app. You should be able to use all layers except the UI layer, making it easier/faster/... Now that mvc exists, I'd say webforms is more about letting non-web devs do web. But you know web, sort of, and you want control so mvc is the way to go.

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