如何迁移丑陋和无证维生素B6 code到.NET [英] How to migrate ugly and undocumented VB6 Code to .NET

查看:182
本文介绍了如何迁移丑陋和无证维生素B6 code到.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经有大约VB6的迁移问题,但我的项目的code基地,这里带来了一些新的问题。

I know that there are already Questions about VB6 migration, but the code base of my project brings some new questions here.

我不得不说,code质量,结构和建筑仅仅是一个噩梦。 有2个大项目: Nr.1 40表格,40模块和一些类文件,这个EXE是怎样的一个基本制度。 Nr.2 80表格,20个模块和一些类文件再次,这个EXE调用功能构成了基本系统。 再就是〜等10个项目,由GUI(每1-3表格)和其他90个非GUI项目,其中大多数是EXE文件,某些DLL。这些DLL是用C,C ++和VB6。

I have to say the Code quality, structure and architecture is just a nightmare. There are 2 Big Projects: Nr.1 with 40 Forms, 40 Modules and a few class files, this EXE is kind of a "base system". Nr.2 with 80 Forms, 20 Modules and a few class files again, this EXE calls functions form the "base system". Then there are ~10 other Projects with GUI (1-3 Forms each) and another 90 non-GUI Projects, most of them EXE Files, some DLLs. The DLLs are written in C, C++ and VB6.

在code自10年时间成长进化,并通过1(坏)开发商大多写的。

The Code has grown evolutionary since 10 years, and written mostly by 1 (bad) developer at a time.

  • 在功能与500线(及以上)是很常见的。
  • 90%的GUI组件被命名为文本1,命令2(1),...
  • 复制和粘贴是所有的地方如G。一个EXE项目(不含GUI​​)有5000行code的复制和复制的唯一的变化是每个邮件,而不是FTP发送的文件(有同一项目的2更多副本也可以)。
  • 我曾经有一个小型(15场),在这里我要解决一个小问题(最多一个半小时的事情正常),每次我改变了一些东西的时候,它要么没有工作,或产生新的错误形成。术后第2天,我决定彻底和〜老形式20 SQL语句改写的形式,只有2个幸存在新的一个。
  • 在甚至不问在code评论...

我接手这个项目在几个月前,我是唯一的维护者。有变更请求和错误的恒定,(但低)流,我们从我们的客户维护预算,以保持软件运行和最新的法律规定方面。

I took over the project a few months ago and I'm the only maintainer. There is a constant, (but low) flow of Change Requests and errors and we get a maintenance budget from our customers to keep the software running and "up to date" in terms of legal requirements.

我的选项

1)重写了 - 在这种情况下,我可以把它写在Java中的可移植性。 这里的问题是,除了一些(旧的)用户的帮助,就没有文件,所以丑code是文档。有一个人谁拥有高层次懂得什么软件应该做的。此外,它很难说服管理层这样做了,即使有大量的储蓄在长期成本,还有政治问题。我也不能这样做,一(VB)项目在同一时间,因为数据库结构并不比code即具有更好从头开始做了。所以,我只能一次改变整个软件。

1) Rewrite from scratch - In that case I could write it in Java for portability. The problem here is that besides some (old) user help, there is no documentation, so the ugly code is the "documentation". There is one Person who has the high level know how what the software should do. Also it's hard to convince management about doing it, even if there are huge cost savings in the long term, there are political issues. I also can't do that one (vb) project at a time because the database structure is no better than the code i.e. has to done from scratch too. So I can only change the whole software at once.

2)迁移code到VB.NET / C# 主要项目迁移首先,我测试了一下,已经找来〜2000升级的意见,从项目Nr.1,其中大多数是像Screen.MousePointer改变,变的返回值等功能。 在这里我的想法是在转换后,创建类的数据库抽象,改变code使用这些类并做重构,迁移和变更等项目也和当所有的code使用DB类,改DB结构。

2) Migrate the code to VB.NET / C# Migration of the main Projects first, I tested that already and got ~2000 upgrade comments from Project Nr.1, most of them things like Screen.MousePointer changed, functions with variant return values and so on. My Idea here is after the convert, create classes for DB abstraction, change the code to use these classes and do refactoring, migrate and change the other projects too and when all the code uses the DB classes, change the DB structure.

3)重新构建code在VB6每当我需要改变的东西有反正(我已经部分地这样做),并在某些时候重构也休息。这样它更容易看到原来的功能,因为它是原来的code和时出现错误,很显然,他们无法迁移的结果。 当code为重构(我假定这将是更小的50-75%,那么也)更容易将其迁移到.NET。然后,更改数据库结构(然后做另一轮重构的...)。

3) Refactor the code in VB6 whenever I have to change something there anyway (I'm already doing this partly) and at some point refactor also the rest. That way it's more easy to see the original functionality, because it's original code and when there are errors, it's obvious that they can't be results of the migration. When the code is refactored (I assume it will be 50-75% smaller then also) it's easier to migrate it to .NET. Then change DB structure (and then do another round of refactoring…).

有一些较大的变化在未来做(使之与Win7的兼容,从而影响了code大部件的另一大CR),因此将是一个很好的机会,做这些改变,因为我马上要经过很多的的code反正。

There are some bigger changes to do in the future (make it compatible with Win7, and another big CR which affects big parts of the code), so there would be a good opportunity to do these changes, as I'll have to go through lot's of the code anyway.

我的问题是,谁拥有的经验/提示迁移坏的,丑陋的code?哪个选项,你会建议?

My Question is who has experience / hints for migrating bad, ugly code? Which options would you suggest?

推荐答案

我不得不去经历同样的事情(没有文件和可怕code海量VB6应用程序。)。唯一的安全,合理的路线,你可以采取的一些3.要提高的东西你必须先了解它。如果你走的路线1或2你保证会留下乌七八糟。

I had to go through the same thing (Massive VB6 app with no documentation and horrible code.). The only safe and reasonable route you can take is number 3. To improve something you must first understand it. If you take route 1 or 2 you are guaranteed to be left with a horrible mess.

记住要始终保持的想法,在你的脑海里,你的最终目标是完全迁移到.NET。当你正在重构想想VB6s可怕的面向对象的支持将如何看起来像在VB.NET或C#。如果可能的话周围改变你的code键使迁移更容易。

Remember to always keep the idea in the back of your mind that your end goal is a full migration to .NET. As you are refactoring think about how VB6s awful OO support will look like in VB.NET or C#. If possible shift your code around to make the migration easier.

您可能要考虑转移了大量的核心功能集成到一个.NET的DLL,并揭露它VB6通过COM。这将从VB6中删除的code荒谬的金额,并希望留下大部分的业务逻辑。

You may want to consider shifting a lot of your core functionality into a .NET DLL and exposing it to VB6 through COM. This will remove a ridiculous amount of code from your VB6 and will hopefully leave mostly business logic.

您需要记住的最重要的事情是不要成为一个牛仔。

The most important thing you need to remember is don't be a cowboy.

  1. 在编写测试的模块。
  2. 在重构模块。
  3. 测试模块。
  4. 释放你的应用程序。
  5. GOTO 1

这篇关于如何迁移丑陋和无证维生素B6 code到.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆