Monday, October 7, 2019

MVVM for legacy Apps?

The most developer would not do this step. But what kind of refactoring you want to do?


Well, if your app is still pre-Unicode, you probably have more to think about than implementing an MVVM Pattern, isn't it? Let me take a look into my crystal ball:

One problem of your migration is: If you change one thing at one end, you break something at the other end. I assume you have no or only a few unit-tests. Your app is not testable, because all of your business logic's are in your forms and everything is using nearly every other unit? You have referenced all over the place and have not used one interface?

Welcome to the club.

Perhaps it is even worse and you're using (typed) Short-Strings as Var-Parameters everywhere?

So your migration is not a "one-shot changes everything for good". It's more like change a little bit here and there and hope for the best. I hate to say it, but I'm doing the same for many years. Starting with old components!

I have the source, but it is really to complicate to migrate every old stuff. (And why it is working) so the best way is to do an interface wrapper and if everything is still working, I can put this in a DLL compiled with the old Delphi and uses this DLL from Rio. Perhaps some time replace this with a new implementation.

So far so good. One problem is still in place, I'm not sure if really everything is still working, because I can only do some "human application tests". Wouldn't it be great if I had at least 10% unit-tests coverage of the main core stuff? How to accomplish that?

Here is the deal: Convert your app step by step to MVVM. Normally it's not so complicated, because in 99,9% every Form is one View, every Frame is one View and normally you would end up only with a 1:1 relation. Do you need a Model? In a best-case scenario, yes!

A part of my #DMVVM framework would be related to doing this kind of "easy" migration. But there are still some problems: No real RTTI and generics in D2007. If the framework can be compiled with D2007 - possible not, but perhaps the D2007 stuff could be in a DLL.

Stay tuned...

No comments:

Post a Comment