简体   繁体   中英

How to port from C++ Builder?

I have this large program written in C++ Builder, relying heavily on the VCL graphics library. For many reasons, I want to abandon this tool. There are a couple of alternative compilers to move to, I'm open for any of them.

What I wonder is how one would do the actual porting, step by step? Has anyone done this and could share their experience?

I would imagine that step 1 is to separate the GUI/VCL from the application. The program should have been designed like that anyhow, but sadly it isn't. That alone is a major project, but where do I go after that? Should I link up the VCL GUI in .dll files, include them in the new compiler, but maintain them from Builder if needed?

I agree you should separate the presentation layer from the business logic.

If you're looking for an alternative GUI framework to the VCL, you could consider Qt . It also comes with an IDE that has a UI designer (so is comparable to C++ Builder), but with the advantages of being both cross platform and open source.

I had the same situation with MFC once. my advice is start from scratch and reuse whatever you can from old code, and don't mess presentation with logic this time! ;)

I would start -- as you say -- by separating the presentation layer from the business logic. Start by doing this in the familiar C++ Builder environment: remove the business logic from the application and recreate it as one or more separate modules (DLLs, on Windows), and change the presentation layer so that the program still runs but accesses these modules for all business logic operations.

Then you can rewrite the application without using VCL. You might stick with C++ and use another GUI library (Qt is certainly one of the options, wxWidgets is also worth a look) or you might want to change language (depending on your own skills and preferences) for the presentation layer.

Another attraction to moving the business logic out of the presentation is that it then becomes much more easily testable.

I'd recommend taking a look at Michael Feathers's book Working Effectively with Legacy Code before you start. He gives a good (and very test-based) approach to this sort of refactoring.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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