简体   繁体   English

如何避免在迁移到.Net时从头开始重写VB6

[英]How to avoid rewriting a VB6 from scratch when migrating to .Net

in our company we develop and sell a VB6 application and we think it's about time to migrate it to .Net. 在我们公司,我们开发和销售VB6应用程序,我们认为现在是时候将其迁移到.Net了。

The main reasons are: 主要原因是:

  • We expect VB6 runtime support to end at some point in time, and we do not want to start the migration just then since it's probably gonna be a lengthy process. 我们希望VB6运行时支持在某个时间点结束,我们不想在那时开始迁移,因为它可能会是一个漫长的过程。
  • There is just 1 1/2 VB6 developers left. 只剩下1 1/2的VB6开发人员。 The half one being me. 半个是我。
  • More and more customers asking for features like cloud and mobile device support. 越来越多的客户要求提供云和移动设备支持等功能。

I know that rewriting an application from scratch is the least recommended way for migrating to .Net. 我知道从头开始重写应用程序是迁移到.Net的最不推荐的方法。 I totally aggree with that! 我完全赞同这一点! Throwing away over a decade of code feels just wrong and would be such a waste of money spent, that I have a hard time recommending and justifying it towards our management. 抛弃十多年的代码感觉是错误的,浪费金钱,我很难向我们的管理层推荐和证明它。

But right now I don't see another way to do it. 但是现在我没有看到另一种方法。

Let me tell you a little bit about the application: 让我告诉你一些关于应用程序的信息:

Like I said it has been developed for over a decade. 就像我说它已经发展了十多年。 There have been numerous developers working on it, most of them rather unexperienced at that time. 已经有很多开发人员在开展这项工作,其中大多数都是当时没有经验的。 We have one developer left from the initial team. 我们从最初的团队中留下了一名开发人员。 That application has been his first and biggest software project and by now he realizes that many of the archtectural decisions made over last 15 years have been horrobly wrong, others were right at that time but have not been refactored to meet changes made in other parts of the application and so have become wrong at some point in time. 该应用程序是他的第一个也是最大的软件项目,到目前为止,他意识到过去15年中做出的许多架构决策都是错误的,其他人当时是正确的,但没有进行重构以满足其他部分的变更。应用程序等在某个时间点变得错误。 This application seems to be a showcase example of code rot. 此应用程序似乎是代码腐烂的展示示例。

We are talking about an application of about 150 KSLOC, all in one single executable. 我们正在谈论大约150个KSLOC的应用程序,所有这些都在一个可执行文件中。 It uses about 15 external DLLs, some of them third party ActiveX controls, some of them are our own .Net assemblies. 它使用大约15个外部DLL,其中一些是第三方ActiveX控件,其中一些是我们自己的.Net程序集。

Adding new features to the application is still possible and being done, but takes ages compared to our other .Net applications. 向应用程序添加新功能仍然可以完成,但与我们的其他.Net应用程序相比需要很长时间。 The reason is that every little change in the codebase requires changes all over the place. 原因是代码库中的每一个小变化都需要在整个地方进行更改。 The only reason why changes are possible at all is because that one developer simply knows most the dependencies and quirks of the application. 改变是可能的唯一原因是因为一个开发人员只知道应用程序的大部分依赖性和怪癖。 As you might have guessed the rate of unexpected side effects and bugs is quite high. 您可能已经猜到了意外副作用和错误率非常高。

My first thought about migrating that application was to first clean up and refactor, then migrate/convert possibly using tools from Artinsoft/Microsoft/WhoEver and then refactor again to get a nice and clean .Net application. 我首先考虑迁移该应用程序是首先清理和重构,然后使用Artinsoft / Microsoft / WhoEver中的工具进行迁移/转换,然后再次重构以获得一个漂亮而干净的.Net应用程序。

But I see some problems: 但我看到一些问题:

  1. There seems to be no way of refactoring the old application. 似乎没有办法重构旧的应用程序。 There is no automated testing whatsoever, not even a formal method for manual testing. 没有任何自动化测试,甚至没有正式的手动测试方法。 Every little change requires manual testing by experienced users who just know where defects might hide. 每一个小小的变化都需要经验丰富的用户进行手动测
    • on the other hand I have established a process and set of tools for testing of our .Net applications which gives us a solid base for making refactorings 另一方面,我已经建立了一个用于测试.Net应用程序的过程和工具集,这为我们提供了重构的坚实基础。
  2. Converting that code to .Net without major refacting feels like: Garbage in, garbage out. 将该代码转换为.Net而不进行重大修改感觉就像:垃圾进入,垃​​圾进出。 Eventhough I hate calling the old application garbage because somehow it works and has proven itself useful. 虽然我讨厌调用旧的应用程序垃圾,因为它以某种方式工作并证明它本身很有用。
  3. Our management has a habit of explicitely demanding quick and dirty solutions, disregarding the effects it has on the productivity and against all recommendations from the development team which has at some point started to deny the existence of quick and dirty solutions in order to be able to do things right. 我们的管理层习惯明确要求​​快速和肮脏的解决方案,无视其对生产力的影响,并反对开发团队的所有建议,这些建议在某些时候开始否认存在快速和肮脏的解决方案,以便能够做正确的事。 That does not mean that we polish features, but we do include the time to write tests and do refactoring in our estimates. 这并不意味着我们改进功能,但我们确实包括编写测试的时间并在我们的估算中进行重构。 So knowing this, I suspect that once the code is converted to .Net and fixed to the point where the application starts and seems to work, the refactoring-phase will be canceld and the application will be shipped to some customers. 所以知道这一点,我怀疑一旦代码转换为.Net并修复到应用程序启动并且似乎正常工作的点,重构阶段将被取消,应用程序将被运送给一些客户。

So. 所以。 What I think is that, despite the fact that rewriting from scratch will take a lot of time and resources, it might still be our only option. 我认为,尽管从头开始重写需要花费大量的时间和资源,但它仍然是我们唯一的选择。

Am I missing an option? 我错过了一个选项吗? Do you see possibilities of not having to rewrite that application? 您是否看到不必重写该应用程序的可能性?

I suggest that you take a step back and read this paper by Brian Foote & Joseph Yoder (University of Illinois). 我建议你退后一步,阅读Brian Foote和Joseph Yoder(伊利诺伊大学)的这篇论文 It provides some architectural insight into the problem you have and options to solve it. 它提供了一些建筑洞察力,可以解决您遇到的问题以及解决问题的方法。 It's titled 'Big Ball of Mud' (please don't laugh, it is a serious paper). 它的标题是“泥球大球”(请不要笑,这是一篇严肃的论文)。 Here is the abstract: 这是摘要:

While much attention has been focused on high-level software architectural patterns, what is, in effect, the de-facto standard software architecture is seldom discussed. 虽然很多注意力都集中在高级软件架构模式上,但事实上,很少讨论事实上的标准软件架构。 This paper examines the most frequently deployed architecture: the BIG BALL OF MUD. 本文探讨了最常部署的架构:MIG BALL OF MUD。 A BIG BALL OF MUD is a casually, even haphazardly, structured system. MUD BALL是一个随意的,甚至是偶然的结构化系统。 Its organization, if one can call it that, is dictated more by expediency than design. 如果人们可以称之为组织,那么它的组织更多地取决于权宜而不是设计。 Yet, its enduring popularity cannot merely be indicative of a general disregard for architecture. 然而,它的持久受欢迎程度不仅仅表明对建筑的普遍漠视。

These patterns explore the forces that encourage the emergence of a BIG BALL OF MUD, and the undeniable effectiveness of this approach to software architecture. 这些模式探索了鼓励出现BIG BALL OF MUD的力量,以及这种方法对软件架构的无可否认的有效性。 In order to become so popular, it must be doing something right. 为了变得如此受欢迎,它必须做正确的事情。 If more high-minded architectural approaches are to compete, we must understand what the forces that lead to a BIG BALL OF MUD are, and examine alternative ways to resolve them. 如果要有更高尚的建筑方法进行竞争,我们必须了解导致大量泥浆的力量是什么,并研究解决它们的其他方法。

A number of additional patterns emerge out of the BIG BALL OF MUD. MIG BALL OF MUD出现了许多其他模式。 We discuss them in turn. 我们依次讨论它们。 Two principal questions underlie these patterns: Why are so many existing systems architecturally undistinguished, and what can we do to improve them? 这些模式背后有两个主要问题:为什么这么多现有系统在架构上没有区别,我们可以做些什么来改进它们?

BTW, I think your best option is to use the current application as your Requirements and rewrite everything in VB.NET or C# using a proper design. 顺便说一句,我认为您最好的选择是使用当前的应用程序作为您的要求,并使用适当的设计重写VB.NET或C#中的所有内容。

There are four main options when you have an application like this: 当您拥有这样的应用程序时,有四个主要选项:

  • Do nothing: this is always an option, as everybody knows, if it ain't broke don't fix it. 什么都不做:这总是一个选择,因为每个人都知道,如果没有破坏,就不要修理它。 However this might not be an option for several reasons such as needing to comply with some security requirements at the company, or simply because one of the components doesn't work in new platforms. 但是,由于某些原因(例如需要遵守公司的某些安全要求,或仅仅因为其中一个组件在新平台中不起作用),这可能不是一种选择。
  • Rewrite: This would be the dream, right? 重写:这将是梦想,对吧? being able to get rid of all the bad practices and duplicated code and so on? 能够摆脱所有不良做法和重复代码等等? Well, it might be that way, however you have to think all the risks involved in developing a new application from scratch. 好吧,可能就是这样,但是你必须考虑从头开始开发新应用程序所涉及的所有风险。 Do you have all the formal requirements? 你有所有的正式要求吗? what about test cases? 测试用例怎么样? do your team know every little detail in the code or would you need to go line by line trying to figure out how why that if is there? 你的团队是否知道代码中的每一个细节,或者你需要一行一行地试图弄清楚为什么会这样? Also, how many bugs do 此外,有多少错误
  • Buy something off-the-shelf: Since you are an ISV this won't be an option. 购买现成的东西:既然你是一个ISV,这将不是一个选择。
  • Migrate: Of course you'll be bound by the programming practices you used for the original development but you'll get to a new platform faster, all your business logic will be automatically migrated, you can actually hire developers for the new platform and you can get rid of the legacy elements. 迁移:当然,您将受到用于原始开发的编程实践的约束,但您将更快地进入新平台,所有业务逻辑将自动迁移,您实际上可以为新平台雇用开发人员并且您可以摆脱遗留元素。 From here you can also take advantage of all the tools available to refactor code, continuous integration, unit testing, etc. 从这里您还可以利用所有可用的工具来重构代码,持续集成,单元​​测试等。

Also, with an automatic migration you can actually go further than just WinForms. 此外,通过自动迁移,您实际上可以比WinForms更进一步。 There are also tools that can take your C# code all the way to the web using a modern architecture. 还有一些工具可以使用现代架构将您的C#代码一直带到Web。

Of course, I work for Mobilize.Net (previously Artinsoft) and this is my biased perspective. 当然,我为Mobilize.Net(以前的Artinsoft)工作,这是我的偏见。 We've been working on this for around 15 years and have seen dozens of clients who come to us after trying to re-write their application and fail after months or even years of struggling without being able to deliver a working application. 我们已经在这方面工作了大约15年,并且已经看到了几十个客户在尝试重新编写他们的应用程序之后来找我们,并且经过数月甚至数年的努力而无法提供有效的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM