15 Min System.getCurrentMillis()
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

15 Min System.getCurrentMillis()

on

  • 1,530 views

How not to use System.getCurrentMillis()

How not to use System.getCurrentMillis()

Statistics

Views

Total Views
1,530
Views on SlideShare
1,522
Embed Views
8

Actions

Likes
0
Downloads
1
Comments
0

2 Embeds 8

http://www.slideee.com 5
http://www.slideshare.net 3

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

15 Min System.getCurrentMillis() Presentation Transcript

  • 1. 15 min. System. getCurrentMillis()
  • 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. 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. Similar/useful project  AutoBoundary                                HAPPY CODE READING