10/25/2015
Google talks:
The clean code talks - "Global State and Singletons"
https://www.youtube.com/watch?v=-FRm3VPhseI
Global state:
Julia tries to understand global state in this talk:
Run same thing a multiple time, will get different test results;
5:40/54:08
A. Multiple Executions can product different results
1. Flakiness
2. Order of tests matters
3. Can not run test in parallel
B. Unbounded location of state
C. Hidden Global State in JVM
1. System.currentTime()
2. new Date()
3. Math.random()
D. Testing above code is hard
1. Therefore inject in doubles
8:49/54:08
Singleton: Good vs Bad
1. Application Global vs. JVM Global
2. Usually we have one application per JVM
A. Hence we incorreclty assume that:
Application Global state = JVM Global
3. Each test is a different configuration of a portion of our application
19:01/54:08
Deceptive API
1. API that lies about what it needs
2. Spooky action at a distance
Julia's comment, the talk is interesting and worth time to watch again later.
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Sunday, October 25, 2015
Study notes - "The clean code talks - 'Global State and Singletons' "
Labels:
global state,
test,
unit test
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment