缩小代码-Java [英] Minify Code - Java

查看:46
本文介绍了缩小代码-Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何工具可以优化/最小化我的Java代码.我已经发现了一些混淆器( http://java-source.net/open-source/obfuscators),但是我不确定这是否是我想要的,因为我实际上仍然希望可读" Java文件,但是例如将它最小化为重复的代码创建方法,只是使代码变得更好.

有没有可以做到这一点的工具?

解决方案

有些工具可以重新格式化您的代码,指出不太明显的错误或使用编译时代码生成来使您的代码更具可读性.您应该查看龙目岛.

仍然,重新格式化代码的最佳方法可能是自己完成.创建大量的单元测试,以便您可以跟踪方法的结果,然后可以不时地递增格式重新运行测试的代码.这样,更改代码中的任何内容的工作量就会大大减少-如果您的测试具有良好的质量和覆盖范围,那么重新格式化后的代码看起来可能完全不同(所需的方式),并且方法的结果将保持令人满意./p>

I was wondering if there is any tool to optimize/minify my Java Code. I already found out about some Obfuscators (http://java-source.net/open-source/obfuscators), but I'm not sure if this is what I want, because I actually want still "readable" Java FIles, but having it minified in sence of e.g. creating methods for code thats duplicated, just make the code better.

Is there any tool that can do that?

解决方案

There are toools that reformat your code, point out not-so-obvious mistakes or use compile-time code generation to make your code more readable. You should check out Lombok.

Still, probably the best way to reformat your code is doing it by yourself. Create a fair amount of unit tests so you can keep track of your methods' results and then you can reformat the code incrementally running the tests every now and then. This way it takes much less effort to change anything in your code - if your tests have good quality and coverage, after all the reformatting your code might look entirely different (the way you want it) and the methods' results will stay satisfactory.

这篇关于缩小代码-Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆