Code Transformer
See legacy code transform into modern applications in real-time
Delphi Form → Angular Component
Input: Delphi
source
procedure TfrmCustomer.btnSaveClick(
Sender: TObject);
var
Query: TADOQuery;
begin
if edtName.Text = '' then
begin
ShowMessage('Name is required');
Exit;
end;
Query := TADOQuery.Create(nil);
try
Query.Connection := dmMain.ADOConn;
Query.SQL.Text :=
'INSERT INTO Customers ' +
'(Name, Email, Phone) VALUES ' +
'(:Name, :Email, :Phone)';
Query.Parameters.ParamByName('Name')
.Value := edtName.Text;
Query.Parameters.ParamByName('Email')
.Value := edtEmail.Text;
Query.ExecSQL;
ShowMessage('Customer saved!');
finally
Query.Free;
end;
end;Output: Backend — .NET 10
generated
public class CreateCustomerHandler
: IRequestHandler<CreateCustomerCmd, Result>
{
private readonly ICustomerRepo _repo;
private readonly IValidator<CreateCustomerCmd> _validator;
public async Task<Result> Handle(
CreateCustomerCmd cmd,
CancellationToken ct)
{
var validation = await _validator
.ValidateAsync(cmd, ct);
if (!validation.IsValid)
return Result.Fail(validation.Errors);
var customer = Customer.Create(
cmd.Name, cmd.Email, cmd.Phone);
await _repo.AddAsync(customer, ct);
return Result.Success(customer.Id);
}
}Output: Frontend — Angular 22
generated
@Component({
selector: 'app-customer-form',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<form [formGroup]="form" (ngSubmit)="save()">
<dx-text-box formControlName="name"
label="Name" [isRequired]="true" />
<dx-text-box formControlName="email"
label="Email" />
<dx-text-box formControlName="phone"
label="Phone" />
<dx-button text="Save" type="default"
[useSubmitBehavior]="true"
[disabled]="form.invalid" />
</form>
`,
})
export class CustomerFormComponent {
private api = inject(CustomerApiService);
form = inject(FormBuilder).group({
name: ['', Validators.required],
email: ['', Validators.email],
phone: [''],
});
save() {
if (this.form.valid)
this.api.create(this.form.value).subscribe();
}
}✅ Error Handling✅ Validation✅ Clean Architecture✅ Async/Await✅ Type Safety✅ Testable
COBOL Procedure → .NET Service
Input: COBOL
source
PERFORM CALCULATE-PREMIUM
IF WS-POLICY-TYPE = 'AUTO'
COMPUTE WS-PREMIUM =
WS-BASE-RATE * WS-RISK-FACTOR
IF WS-AGE < 25
COMPUTE WS-PREMIUM =
WS-PREMIUM * 1.25
END-IF
IF WS-CLAIMS > 2
COMPUTE WS-PREMIUM =
WS-PREMIUM * 1.15
END-IF
ELSE IF WS-POLICY-TYPE = 'HOME'
COMPUTE WS-PREMIUM =
WS-PROPERTY-VALUE * 0.003
* WS-RISK-FACTOR
END-IF
MOVE WS-PREMIUM TO WS-OUTPUT-PREMIUM.Output: Service — .NET 10
generated
public class PremiumCalculationService
: IPremiumCalculationService
{
public decimal Calculate(
PolicyType type,
decimal baseRate,
decimal riskFactor,
int age,
int claims,
decimal propertyValue)
{
return type switch
{
PolicyType.Auto =>
CalculateAuto(baseRate, riskFactor,
age, claims),
PolicyType.Home =>
propertyValue * 0.003m * riskFactor,
_ => throw new DomainException(
$"Unknown policy type: {type}")
};
}
private static decimal CalculateAuto(
decimal baseRate, decimal riskFactor,
int age, int claims)
{
var premium = baseRate * riskFactor;
if (age < 25) premium *= 1.25m;
if (claims > 2) premium *= 1.15m;
return premium;
}
}✅ Error Handling✅ Validation✅ Clean Architecture✅ Async/Await✅ Type Safety✅ Testable
Want to see your code transformed?
Upload your legacy project and get a free assessment with PhoenixCode Lens.