将25k行C#转换为Java的经验教训

本文分享了将复杂财务应用从C#转换到Java的项目经验,包括使用语言中立的测试(如Cucumber)、自动化翻译工具、不要急于求成、利用Java 8的Stream API等关键步骤,并提醒注意不同语言的意外行为和避免过早重构。
摘要由CSDN通过智能技术生成

由于各种原因,我最近完成了一个将复杂的财务应用程序从C#转换为Java的项目。 港口的原因大部分是非技术性的,相反,这是有关企业的一项战略举措。

这是一次有趣的经历,我在此过程中吸取了一些经验教训,可以分享这些经验。

1.在现有系统上构建语言中立的测试。

我将从最重要的一课开始。 移植系统时,由于任何原因它可能是任何端口,因此必须具有确定该端口是否成功的标准。 最好的方法是围绕原始系统构建一整套测试,这些测试可以“ 无需更改导出”到新系统。 因此,例如,如果要将系统从Java迁移到不支持JUnit的其他语言,则没有一套JUnit测试是不好的。 我不能过分强调测试的更改从字面上可以从旧系统复制到新系统而无需干预的重要性,这是多么重要。

JUnit测试的另一个问题是它们通常与现有的实现紧密地联系在一起。 由于将要重写实现,因此测试无法在实现之间移植。

我们选择的并且非常有效的策略是使用Cucumber测试。 几乎所有语言都有Cucumber的绑定,IDE(至少是IntelliJ和Visual Studio都)很好地支持了Cucumber,此外,该测试是人类可读的。 这样,您可以让非技术用户参与测试的准备工作,以准备端口。 (顺便说一句,我们试图通过记录

一个很强大的工具, 能将c#代码片段、文件甚至工程直接转换java代码,并能彻底解决外部引用的DLL问题,最强的是支持c#工程的直接转换,生成的Java代码质量也很不错。软件已破解,去除了未注册版最多只能转换1000的限制,亲测可用!压缩包内含帮助文档,不过由于软件的使用很简单,帮助文档基本可以忽略。(小提示:如无法运,请确认是否安装了.NET framework) 下面是一些英文介绍: C# to Java Converter features include: 1. Folder conversion: Entire folders of C# code files are converted to Java code files.(文件夹转换) 2. Code snippet and file conversion: Our snippet conversion accuracy is outstanding and does not require you to insert entire methods or classes. Heuristics are used to convert code fragments wit h missing declarations. (代码片段和文件转换) 3. Full support for the latest .NET code syntax: Generics and other newer C# features are converted where possible to the Java equivalent.(全面支持最新版的.NET语法) 4. Conversion options: You can specify numerous conversion options via our Options dialog. Code formatting options, custom type & member replacements, custom string replacements, and miscellaneous options. (可以指定转换规则) 5. File comparison feature: After converting a project or folder, you can compare original and converted files side-by-side. Comparing converted code to original code.(原代码转换代码的比较) 6. Running from the command line: C# to Java Converter can be launched directly for a specific project, folder, or file conversion from the command line. Command line.(命令) 其他一些特点: 1. Converts all versions of C# code (2002, 2003, 2005, 2008, and 2010) (可以转换所有版本的C#代码) 2. Evaluates all referenced assemblies and .NET projects in order to resolve external references more completely.(能彻底解决外部引用的dll类库) 3. Converts C# ref parameters using Java generics 4. Superb conversions of all types of arrays 5. Handles the numerous coding alternatives and ambiguities of C# code 6. Flawless conversion of all aspects of inheritance and interfaces 7. Allows custom replacement of strings in the final converted code 8. Accurate even with poorly formatted C# code
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值