search

Home  >  Q&A  >  body text

java - 如何很好的对代码进行重构?

在写代码实现业务场景的过程中,要不断对代码进行重构,有什么原则啊?还有,在核心代码处要加日志,一般要怎么组织关键字,对于有性能损耗的地方,需要不需要刚开始就日志记录执行时间呢?日志打太多会影响程序的性能的,所以日志也应该不要太多为好的吧。

PHP中文网PHP中文网2766 days ago526

reply all(4)I'll reply

  • 迷茫

    迷茫2017-04-18 09:44:24

    Looking at some design patterns will help

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:44:24

    There is a good book about refactoring, step by step,

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:44:24

    The principle is: Refactoring should be considered only when development efficiency or operating efficiency encounters a bottleneck

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:44:24

    1. Please learn the setting mode for reconstruction issues

    2. For log issues, it is generally recommended to log in key places. As for too many logs affecting performance, a very simple way is to set a switch:

    if (ENABLE_LOG){
        log(TAG, something);
    }

    ENABLE_LOG is set to true in the development version and to false in the release version, so that the log can be used without affecting performance in the official version.

    reply
    0
  • Cancelreply