4

In our company we develop and sell a VB6 application and we think it's about time to migrate it to .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.
  • There is just 1 1/2 VB6 developers left. 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. 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 architectural decisions made over last 15 years have been horribly 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. 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. It uses about 15 external DLLs, some of them third party ActiveX controls, some of them are our own .NET assemblies.

Adding new features to the application is still possible and being done, but takes ages compared to our other .NET applications. 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.

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
  1. Converting that code to .NET without major refactoring feels like: Garbage in, garbage out. Even though I hate calling the old application garbage because somehow it works and has proven itself useful.
  2. Our management has a habit of explicitly 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 canceled and the application will be shipped to some customers.

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?

R.J. Dunnill
  • 2,049
  • 3
  • 10
  • 21
Gooo
  • 239
  • 1
  • 8
  • 2
    Given that VB6 is very old and clunky (as you've more-or-less stated as the motivation in the first place), and that VB.NET is really just C# .NET with different syntax, I think the answer is the one you don't want; which is that it isn't. I think the best you could do is go on a file-by-file basis and "re-write" each `sub` and `module` one-by-one with a C# equivalent. – Martin Costello Apr 16 '14 at 16:34
  • What's the difference to using conversion tools? Going file by file and sub by sub, I think we'd end up copying the old monsterous structure. – Gooo Apr 16 '14 at 16:37
  • 1
    @martin_costello I would strongly advise against a blind copy; even without existing organic design, a lot of metaphors and paradigms are different between VB6 and .NET. I hate to say it, but I'd actually want to end up with a decent manageable codebase at the end, not just migrated cruft that nobody really understood in the first place. That means: doing it properly. – Marc Gravell Apr 16 '14 at 16:38
  • I think I'd rather take the old application as a reference for identifying features, creating use cases and verifying the behaviour of the new application. – Gooo Apr 16 '14 at 16:39
  • I'm not suggesting a *totally* blind copy, as like the OP says "garbage-in, garbage-out". I'm saying go one-by-one and rewrite. The overall *architecture* will be the same, but re-done in C#. Unless it was a fully supported enterprise product that was *very* robust and tried-and-tested, I wouldn't trust a "conversion tool" to do it. You'd end up having to re-test everything anyway. – Martin Costello Apr 16 '14 at 16:40
  • 3
    @Gooo I would suggest trying to identify units of functionality that you could take from the old code to make a minimum viable product, and see if you can basically port piece by piece to .NET. Note that it is possible to use com-interop in both directions as a transitional device, but: it is a bit flakey and painful – Marc Gravell Apr 16 '14 at 16:40
  • `How to avoid rewriting a VB6 from scratch when migrating to .Net` - I won't read your long post. I'll simply state that you can't. VB6 and .Net are fundamentally different in that .Net is OOP and VB6 is basically procedural stuff with some sugar on top. – Federico Berasategui Apr 16 '14 at 16:41
  • BTW, if you will move to .Net you basically have 2 options: 1 - create a Web application using ASP.Net (which is fundamentally different from the classic VB6 approach), or use XAML-based technologies (such as WPF) and create a Windows client application (which is fundamentally different from the classic VB6 approach). Either way, you will have to completely redo the UI, and there's not much you can do about that. – Federico Berasategui Apr 16 '14 at 16:42
  • We're in the process of rewriting a C/C++/MFC app which was started in 1993 completely in C# and WPF/XAML/MVVM. It doesn't "feel wrong" at all because the amount of convenience and richness we're adding to the UI is unparalleled. – Federico Berasategui Apr 16 '14 at 16:44
  • @MarcGravell I tried that, but like I said, it is one big executable and so far I have not been able to extract a reusable portion of code. I'm not saying that it's impossible but it's probably just as difficult as cleaning the application in VB6. I'll probably keep on trying for a while. – Gooo Apr 16 '14 at 16:44
  • 2
    I had a 15 yr old system (started as a VB3 -> 4 -> 6) which also evolved into something huge but was not all that hard. Dont copy convert, but design HOW the old functionality is to be re/implemented (ie inheritance and such) along with any intial new stuff (cloud etc). Upgrade outdated stuff, but keep the good parts. For example dont waste time trying to do control arrays. Ditto for things like dropping arrays in favor of Lists. Part of the goal has to be to develop a new codebase with conceptual integrity for the longer haul. – Ňɏssa Pøngjǣrdenlarp Apr 16 '14 at 16:50
  • @Plutonix: How many VB6 SLOC did you have in the end? I mean how big is huge? – wqw Apr 17 '14 at 12:00
  • @wqw I dont recall SLOC but it was over 7MB of code. It was mainly intricate with internal classes, C DLL and blackboxes to change how it looked, calculated and acted depending on the cust's state and type of product, including VB 3 "tricks" for running on a 386 (1995). It only took about 4 man-months to convert BUT OTOH it wasnt just VB3 code compiled by VB6, it had been updated over time to use classes and such (to handle new req which is where the blackboxes and report scripts came from). IMO you want to end up with something which is viable for the future, not just will compile under NET. – Ňɏssa Pøngjǣrdenlarp Apr 17 '14 at 13:43
  • Check out M. Feathers' book "Working Effectively with Legacy Code" -- it discusses the pitfalls of enhancing, refactoring and migrating an untested code, including retrospectively adding tests. – MarkJ Apr 19 '14 at 20:54
  • Sorry for digging up an old thread! I am curious about what happened to your codebasse @Gooo in the end? Did you rewrite? Found a way to convert then refactor it step by step? Something else? – Ian Letourneau Dec 11 '20 at 16:33

2 Answers2

1

I suggest that you take a step back and read this paper by Brian Foote & Joseph Yoder (University of Illinois). 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. A BIG BALL OF MUD is a casually, even haphazardly, structured system. 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. 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. 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.

Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29
  • Nice paper! It adresses many of the issues which I described and suggests methods which we are using on other projects. We have done so by taking a few pieces of XP, a little bit of Scrum and a whole lot of talking to each other to evolve our applications in small steps, always keeping things working. – Gooo Apr 16 '14 at 17:07
  • @wdosanjos: (Thumbs up on Big Ball of Mud). Not so keen on your advice. Is this the voice of experience? How many systems have you successfully written from scratch? http://www.joelonsoftware.com/articles/fog0000000069.html – Ira Baxter Jul 02 '15 at 00:01
1

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.
  • 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. There are also tools that can take your C# code all the way to the web using a modern architecture.

Of course, I work for Mobilize.Net (previously Artinsoft) and this is my biased perspective. 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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
willvv
  • 8,439
  • 16
  • 66
  • 101
  • FWIW, Artinsoft (or whoever they are now) have been around a long time doing this. I don't have any direct experience with their tools or services, but I respect what they have achieved. – Ira Baxter Jul 02 '15 at 00:04