Skip to content

Latest commit

 

History

History
116 lines (59 loc) · 3.67 KB

unassorted.adoc

File metadata and controls

116 lines (59 loc) · 3.67 KB

refactor

Driving agile development with test-driven development

why refactor?
  • Refactoring makes your organization’s code simpler, which means fewer bugs and easier maintenance.

  • If you have fewer code lines, you will have fewer potential bugs

  • Simpler code enables technical agility,Technical agility enables business agility

how to refactor?
  • TDD TDD is an iterative process or a three-step dance—red, green, refactor

  • instead of doing a single large refactoring, doing a series of smaller microrefactorings

  • DRY-Don‘t Repeat Yourself

TDD three-step—red, green, refactor
  • Write a new test for that new feature; of course, the code will fail the test because the feature doesn’t work yet. TDD says the test has gone red.

  • Write Java code to implement the new feature until the new test passes. All the other tests must continue passing as well. This means the tests have gone green.

  • Clean up and improve the production code by refactoring the code, which results in better code. All the tests must continue to pass.

TDD
code kata
  • kata is a series of movements that you do regularly. You repeat your actions so many times that the body builds muscle memory. Without thinking about them, you will execute the moves.


Stabilizing your legacy code and technical debt

what’s technical debt?
  • Technical debt is code with problems that can be improved with refactoring or code without automated tests

the interest payments
  • the biggest cost is lost of technecal agility,and then lose the business technecal

why is technical debt a problem?
  • taking the time to fix the code to improve technical and business agility

how to do?
  • using test-refactor-add methodology for working with legacy code

step
  • Add pin-down tests. They will help you understand the legacy code’s external behavior, and they will also pin down the code’s behavior so that if something breaks, you’ll know it.

  • Discover more behaviors with code coverage tools

  • Testing if/else statements by branch coverage

  • Refactor

  • Add the new feature

CodeKata

what is the goal?
  • the point of the kata is not arriving at a correct answer. The point is the stuff you learn along the way. The goal is the practice, not the solution.

other

what’s crud?
  • create,read,update,delete

判断null/empty的偷懒方法

org.springframework.util.ObjectUtils.isEmpty

支持Optional、Array、CharSequence、Collection、Map

JSON

spring 序列化json,会去掉is字段 isDailyRule → dailyRule

es

200+条数据 文档也很简单,但是存储占用空间很大 一个分片300M,原因是频繁写入,es删除有延迟

idea

快捷键

AsciidocFx

AsciidocFx 导出pdf

AsciidocFx的默认字体不支持导出pdf中的中文字体,解决方法是在导出pdf时选择一种支持中文的字体。

修改/conf/docbook-config/fo-pdf.xsl

  1. Add some font that can display Chinese into <xsl:template name="pickfont-symbol">. Some supported fonts are Arial Unicode MS, SimSun, SimHei, KaiTi. It seems bold font does not work for SimSun, SimHei, KaiTi.

  2. Uncomment <xsl:param name="symbol.font.family">.