Coding Katas for practicing the refactoring of legacy code

前端 未结 3 1462
萌比男神i
萌比男神i 2021-01-29 17:48

I\'ve gotten quite interested in coding katas in recent months. I believe they are a great way to hone my programming skills and improve the quality of the code I write on the j

3条回答
  •  清歌不尽
    2021-01-29 18:09

    I don't know of a site that catalogs them directly, but one strategy that I've used on occasion is this:

    1. Find an old, small, unmaintained open source project on sourceforge
    2. Download it, get it to compile/build/run
    3. Read the documentation, get a feel for the code
    4. Use the techniques in Working Effectively with Legacy Code to get a piece of it under test
    5. Refactor that piece, perhaps fixing bugs and adding features along the way
    6. Repeat steps 4 through 6

    When you find a part that was especially challenging, throw away your work and repeat it a couple times to reinforce your skills.

    This doesn't just practice refactoring, but other skills like code reading, testing, and dealing with build processes.

    The hardest problem is finding a project that you're interested enough in to keep working in. The last one I worked on was a python library for genetic programming, and the current one I'm working on is a IRC library for Java.

提交回复
热议问题