Sunday, October 25, 2015

Study notes - "The clean code talks - 'Global State and Singletons' "

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.




No comments:

Post a Comment