15 min. System.
getCurrentMillis()
Problems

 System is static
     hard to mock
  time/duration is unpredictable
     when is now
     how long does it take...
Solution
    Don't use System.getCurrentMillis()
      for Data
          use Data: timestamps, duration (e.g. Joda Time)
...
Similar/useful project
       AutoBoundary 
 
 
 
 
                      HAPPY CODE READING
Upcoming SlideShare
Loading in...5
×

15 Min System.getCurrentMillis()

957

Published on

How not to use System.getCurrentMillis()

Published in: Education, Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
957
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

15 Min System.getCurrentMillis()

  1. 1. 15 min. System. getCurrentMillis()
  2. 2. Problems System is static hard to mock  time/duration is unpredictable when is now how long does it take (to run a test)  we can introduce an error margin is it big enough ...
  3. 3. Solution Don't use System.getCurrentMillis() for Data use Data: timestamps, duration (e.g. Joda Time) objects are better then primitives for Services/Beans IClock injected interface ActiveClock: production (thin wrapper) StoppedClock: test startTimestamp tick()/advance()  
  4. 4. Similar/useful project  AutoBoundary                                HAPPY CODE READING
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×