xavierchow 最近的时间轴更新
xavierchow's repos on GitHub
JavaScript · 31 人关注
github-label-template
manage github lable automatically
Shell · 7 人关注
docker-redis-sentinel
Shell · 1 人关注
addStaticRoutes
A script for adding static routes on Mac OS X.
Go · 1 人关注
go-test
JavaScript · 0 人关注
ajv
The fastest JSON Schema Validator. Supports draft-04/06/07
JavaScript · 0 人关注
AppleTVdns
A node.js script for Apple TV DNS hack
0 人关注
asset
JavaScript · 0 人关注
async
Async utilities for node and the browser
JavaScript · 0 人关注
awesome-cn-cafe
A curated list of awesome café places in China.
JavaScript · 0 人关注
backend-test
JavaScript · 0 人关注
bull
A NodeJS persistent job and message queue based on Redis
JavaScript · 0 人关注
clientjade
command line tool to compile your jade templates into client side templates for use in the browser
Clojure · 0 人关注
clj-cb
A Clojure wrapper of java-client for Couchbase for Server 4.x
Clojure · 0 人关注
clojure-couchbase
The clojure sdk for Couchbase7
JavaScript · 0 人关注
delay-repeater
Run your code repeatly with a delay
CoffeeScript · 0 人关注
diffFile
0 人关注
docs.nestjs.com
The official documentation https://docs.nestjs.com 📕
CoffeeScript · 0 人关注
doudizhuPuzzle
JavaScript · 0 人关注
generic-signature
JavaScript · 0 人关注
gh-repo-exp
JavaScript · 0 人关注
gissues
whiteboard for github issues
0 人关注
github-rebase
⏭ Rebase a pull request using the GitHub REST API
CSS · 0 人关注
hexo-theme-apollo
A hexo theme inspired by vuejs.org.
CSS · 0 人关注
hexo-theme-next
Elegant theme for Hexo.
Clojure · 0 人关注
img-crawler
JavaScript · 0 人关注
js-seq-viewer
a command line tool to view the JS Sequence Diagram.
Shell · 0 人关注
jshintblame
Send notification mail to the guy who introduced warn found by jshint
0 人关注
jstest
JavaScript · 0 人关注
kue
Kue is a priority job queue backed by redis, built for node.js.
xavierchow

xavierchow

🏢  https://wiredcraft.com
V2EX 第 109362 号会员,加入于 2015-04-06 09:04:06 +08:00
xavierchow 最近回复了
> 函数逻辑都想好了
> 但名字还没想出来

提供一个思路,我个人比较喜欢 top-down 的方式去写函数,而不是先去想逻辑。
即,先试图用一句话去描述这个函数是干什么的,可以不要管怎么实现( how ),
最好能在概括的时候思考一下函数的输入输出,只要你一句短语说的清楚的话,名字也就容易起了。

如果先去想逻辑和具体实现的话,很容易形成一个局面,就是你最后定义函数是为了包装一堆可能
原本不该在一个维度的逻辑代码,这时候取名字就很难了。

换句话说,发现函数难以起名的时候,可能要思考一下是不是应该转换一下思路,做一下拆解或者合并;
至于命名风格问题,各个语言和框架都有行业上比较成熟的惯例,加上 lint 就可以了。
不容易,国内用函数式做主力编程语言的公司真是屈指可数 👍🏼
350 天前
回复了 hsuyeung 创建的主题 程序员 单元测试问题请教
> 刚想了想,我感觉还是应该把“从 token 中获取用户信息”这一操作放到 api 层去处理,然后将用户信息或者其中某些字段作为参数传递到 service 中,service 只处理业务逻辑这样更好些。

对的,这就是写测试代码的好处,促使你重新思考分层 /解耦有么有做好,测试困难很可能代码设计就有坏味道了。
359 天前
回复了 lerefe 创建的主题 Java 请教关于函数式编程的优势
仅从题主的例子来说,
第 1 点不同是可读性,imperative VS declarative ,
第 2 点关于复杂度的担忧(循环),同样是函数式的写法可以用 fold / reduce, 另外尽量用 transducer ,看上去很多的 transformer 实际上也只是循环一次。(不清楚 java 是否有类似的东西,https://clojure.org/reference/transducers 是 clojure 在性能方面的考量和努力)
> 综上, 这个 store 是会在不同线程中批量或单独读取写入的, 那么, 有什么办法保证批量或单独读写的原子性吗?

不太清楚你这个 store 是什么,如果你有多个 node.js application 需要共享数据,最直接的就是把数据放在 database ( redis 也行)里,由 database 来保证原子性。
2022-09-21 22:45:28 +08:00
回复了 tsingke 创建的主题 程序员 单元测试有落地效果好的团队吗?
我们从源头上抓起, 招聘的代码测试环节就有要求写测试代码,不写测试大概率是招不进来的。
进来后鼓励采用 TDD 方式开发,不写测试代码没人给 review PR ,就 merge 不回去主干分支,然后 CI 也会检查覆盖率。
之所以一直这么做,是团队真的获得了巨大收益(低缺陷率,低耦合模块结构,可以大胆重构 /加功能等等)
https://github.com/Wiredcraft/test-backend#functionality
2022-03-24 23:42:29 +08:00
回复了 alay9999 创建的主题 程序员 [V2EX技巧] 贴图和贴代码的方法(写给像我一样的小白)
这是个很好的问题,
我们定义 new 出来的子类实例 primaryStudent 为 p,
则 p.__proto__ === PrimaryStudent(class).prototype,
PrimaryStudent.prototype.__proto__ = Student(class).prototype.
这个是我们关于原型链的基本理解,不会有问题,题主的困惑在于为什么在 web console 中,p.__proto__ 会显示成 Student?

我在 node.js/chrome/safari 中分别尝试了一下,
1. 在 node.js 和 safari 中 p.__proto__ 为 "PrimaryStudent"
```
Welcome to Node.js v12.18.2.
Type ".help" for more information.
> class Student {
... constructor(name) {
..... this.name = name;
..... }
...
... helloStudent() {
... console.log('student');
... }
... }
undefined
>
> class PrimaryStudent extends Student {
... constructor(name, grade) {
..... super(name);
..... this.grade = grade;
..... }
...
... helloPrimaryStudent() {
... console.log('primarystudent');
... }
... }
undefined
> var p = new PrimaryStudent('john', 5)
undefined
> p.__proto__
PrimaryStudent {}
> PrimaryStudent.prototype
PrimaryStudent {}
>
```

2. 在 chrome 中, 如贴主所截图,p.__proto__为 "Student"
```
var p = new PrimaryStudent('john', 5)
p.__proto__
Student {constructor: ƒ, helloPrimaryStudent: ƒ}
constructor: class PrimaryStudent
helloPrimaryStudent: ƒ helloPrimaryStudent()
```

个人认为,其实在不同环境中,PrimaryStudent.prototype(即 p.__proto)还是同样的 object:{constructor: PrimaryStudent,prototype: Student.prototype}, 只不过在 node.js 和 safari 中,解释器用 constructor 来称呼这个 object,
在 chrome 中,它用 prototype 来称呼这个 object,不知道这个有没有回答到贴主的问题,
当然如有错误请各位指正。
2020-10-19 23:25:10 +08:00
回复了 tiensonqin 创建的主题 酷工作 远程招聘 clojurescript 或者 Javascript 程序员
感觉是个 side project 呀,国内用 Clojurescript 的项目还是少啊
2020-01-04 21:52:53 +08:00
回复了 webcoder 创建的主题 程序员 在作数据库的读写操作时大家有没过一种奇怪的焦虑感?
> 会写上一大堆的校验检查甚至是如果不存在就创建的代码

你需要明确你的模块的接口和职责,我猜测你的焦虑是由于对接口定义的不清晰, 另外不存在就创建很容易掩盖其他地方的错误,造成后期问题定位的更大问题。
可以看一下 [fail fast]( https://en.wikipedia.org/wiki/Fail-fast)。
另外你这些所谓的多余的代码有测试代码吗?能在测试环境跑过吗?不要去写不可测的代码,因为你不知道你所谓的多加的处理是否正确。(尽管你本意是让系统更 robust,但是增加复杂度和降低可读性来换取不知正确性的容错处理得不偿失)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   800 人在线   最高记录 6067   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 20:05 · PVG 04:05 · LAX 13:05 · JFK 16:05
Developed with CodeLauncher
♥ Do have faith in what you're doing.