bowling_game's People
bowling_game's Issues
Code Review Issues - 03
文件代码行 | Comments |
---|---|
测试问题 | 测试中没有完整的集成测试,和 main.js 中一样流程的的使用了setFrames 方法的集成测试;同样也没有对方法 setFrames 本身的测试,这无法保证你给定的字符串输入是否能正确转换成frame得分的数组。 |
calculator-spec.js | Line 9 测试用例的描述中“is fixed ” 的意思是什么,没看懂,是想说 “is mixed ” 吗。Line 68 测试用例的描述中 “all number” 是什么意思,前面几个用例都是 all number啊,没看到区别。 |
calculator-spec.js | Line 83 中 beforeEach 的声明 不会因为你放在 83行,Line 9 的测试用例就无法使用。思考它的作用域,要么将其放在最前,要么做其他方式的移动。 |
封装性问题 | 在Calculator 类中对于 game.frames 以及 frame.firstBall 等属性的直接访问破坏了类的封装行,如果可以直接获取属性的值,那也可以修改属性的值。建议通过方法来获得相应属性的值。 |
类的定义和划分依然需要细化
1,需要更多和业务相关的实体类,比如line,ball等
Code Review Issues - 01
文件代码行 | Comments |
---|---|
spec/score-spec.js | 测试覆盖率问题,测试的边界值和特殊值还是不够完整。比如全部 strike,全部 spare, 全部 miss 之类的。 |
src/score.js | 思考方法 eachFrame 的参数 index 是否有必要 |
src/score.js | 字符串变成数字的操作可以提出来,直接减去0的做法看起来有点奇怪。可以提出来作为函数,也可以采用其他方法,比如parseInt() |
src/score.js | 多个 if/else 在根级别是少不了,也就是分数计算最小能分成几类,我现在想到的是三类: 一是frame加上后两个球的分数,二是frame加上后一个球的分数,三是frame自己的分数。这些不同分别对应frame 为 strike spare 普通的情况。miss 的可以算作第三种,miss 可以直接变为分数 0 。分别提成函数分别处理。 |
Code Review Issues - 02
文件代码行 | Comments |
---|---|
src/conversion.js | 单词问题,方法 converToFrames 中的单词 conver 不是一个合适的动词。 |
src/calculator.js | 命名问题,方法 eachGame 的名字不遵循动词开头的方式。 |
src/*.js | 类的设计问题,从需求的角度来看,保龄球比赛计分中 首先是 计分的概念,然后计分的对象是保龄球比赛,可以看做 game 的概念,一个 game 中又包含多局,也就是 frame 的概念,而每个 frame 中就包含 strike/spare/miss 以及 其他普通的情况。可以参考这样的思路来设计类和类中的属性,以及类的接口。面向接口编程,从使用者的角度来设计接口。提供一种思路仅供参考,比如计分,就需要参数 game ,而这里其实是表示一个 game 中10局的字符串。类似于 Calculator.calculate(game); 而game 就是 new Game('X |
src/calculator.js | 依赖问题,在方法 eachGame 中初始化另一个 Conversion,这其实也就是说 Calculator 是要依赖于 Conversion 的,一般来说这些外部依赖放在构造函数或参数中传进来相比较好。你可以关注下依赖注入的一些知识,自己写写例子。 |
src/calculator.js | 代码设计或着代码重复问题,在方法 strikeFrame、spareFrame、normalFrame 中都会有类似 frame.firstBall === '-' 然后 parseInt 的操作,如何消除这样的重复可以演化到设计的问题,为什么不能一开始就把这些转化成得分,然后只需要计算就好了,而且一开始转化成得分也比较简单。 |
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.