Giter Site home page Giter Site logo

refactor-bootcamp-202002's Introduction

重构线上练功房热身编程题

本项目为ThoughWorks内部【敏捷工程实践系列】之「重构」线上练功房热身编程题,涵盖两个小题目,一道是重点是关于TDD,一道重点关于重构,两道题业务复杂度相对简单,预估花费 0.5 ~ 1小时完成。

目的:1. 热身;2. 摸底

开发环境

  • JDK1.8
  • JUnit 5
  • Gradle 5.2.1

热身题目

1. 斐波那契数求值

业务需求

设计一个程序,用于计算前50位斐波那契数值。

When 位数为1, when 求值, Then 返回1
When 位数为2, when 求值, Then 返回1
When 位数为3, when 求值, Then 返回2
When 位数为4, when 求值, Then 返回3
...

Sample: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ..., 12586269025L(50)

练功要求

  1. 针对上述场景,测试先行的方式,完成需求,测试用例至少覆盖5种场景。
  2. 测试命名采用遵循given,when,then的方式,比如:should_return_3_when_calculate_given_position_is_4
  3. 每通过一个测试做一次Commit,Commit信息需要清晰表达意图
  4. 将测试代码放置在src/test下的cc.xpbootcamp.warmup.fibonacci package中
  5. 将产品代码放置在src/main下的cc.xpbootcamp.warmup.fibonacci package中

2. 超市收银机

背景

老王经营了一家超市,之前找了一个Vendor开发了一款简化版的超市收银机。收银机的功能很简单:在顾客结账时,需要打印订单信息。之前的Vendor已经开发出了可以用的代码。

收银机一直都很难用,收银员经常跟老王抱怨。老王由于勤快,把超市做大了,寻思着找个好的Vendor把软件优化一下,并继续开发一些新功能。他听说TW在软件交付方面很擅长,擅长交付高质量的软件,于是找到了TW。

TW工程师接收后,却发现代码存在神一般的命名和谜一般的逻辑,所以为了更好地继续下去,不得已停下来对已有代码进行重构。

此时,你正好在该项目担当重构大任的骨干,接下来请你完成这一轮重构,让代码从可用简洁可用

练功要求

  1. 重构前运行测试,确保测试是通过的
  2. 每修改一处代码,运行测试,确保测试是通过的,并做一次Commit,Commit信息描述你认为的代码坏味道和重构手法
  3. 产品代码位于src/main下的cc.xpbootcamp.warmup.cashierpackage中
  4. 测试代码位于src/test下的cc.xpbootcamp.warmup.cashierpackage中
  5. 不要修改测试代码
  6. 尽自己所能,尽可能多的找出坏味道,并重构掉

补充

每个小伙伴将该项目fork自己的GitHub账号下

refactor-bootcamp-202002's People

Contributors

reddish-brick avatar yuanshenjian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.