/10@yegor256 1
Need It Robust?
Make It Fragile!
Yegor Bugayenko
/10@yegor256 2
less bugs
/10@yegor256 3
Fail Safe
vs.
Fail Fast
/10@yegor256 4
Fix
Report
Use
Deploy
/10@yegor256 5
int len(File f) {
if (f == null) {
return -1;
}
}
int len(File f) {
if (f == null) {
throw new Exception(
“...
/10@yegor256 6
try {
stream.read();
} catch (IOException ex) {
ex.printStackTrace();
}
try {
stream.read();
} catch (IOExc...
/10@yegor256 7
void push(int x) {
if (pos < array.length) {
array[pos++] = x;
}
}
void push(int x) {
if (pos >= array.leng...
/10@yegor256 8
@Override
void save() {
// not implemented yet
}
@Override
void save() {
throw new Exception(
“not implemen...
/10@yegor256 9
file.delete();
if (!file.delete()) {
throw new Exception(
“failed to delete file”
);
}
/10@yegor256 10
User find(int id) {
if (/* not found */) {
return null;
}
// continue...
}
User find(int id) {
if (/* not ...
/10@yegor256 11
Fix
Report
Use
Deploy
/10@yegor256 12
www.yegor256.com
Upcoming SlideShare
Loading in …5
×

Need It Robust? Make It Fragile!

784 views

Published on

DEVit 2016; Thessaloniki, Greece; 20 May 2016. Video is here: https://www.youtube.com/watch?v=nCGBgI1MNwE

Published in: Software
1 Comment
1 Like
Statistics
Notes
  • Hello Yehor. I didn't understand your last slide? (with the arrow shortcutting the cycle directly from use to fix). In all your slide, you change all the "silent" problems into throwing of Exceptions,which is nice in order to be "informed" of what's going on and where. However, this last slide suggest that you prefer to shortcut the "report" passage of the loop? Could you explain further please?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
784
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
5
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Need It Robust? Make It Fragile!

  1. 1. /10@yegor256 1 Need It Robust? Make It Fragile! Yegor Bugayenko
  2. 2. /10@yegor256 2 less bugs
  3. 3. /10@yegor256 3 Fail Safe vs. Fail Fast
  4. 4. /10@yegor256 4 Fix Report Use Deploy
  5. 5. /10@yegor256 5 int len(File f) { if (f == null) { return -1; } } int len(File f) { if (f == null) { throw new Exception( “file can’t be NULL” ); } }
  6. 6. /10@yegor256 6 try { stream.read(); } catch (IOException ex) { ex.printStackTrace(); } try { stream.read(); } catch (IOException ex) { throw new RuntimeException( “failed to read stream”, ex ); } exception swallowing
  7. 7. /10@yegor256 7 void push(int x) { if (pos < array.length) { array[pos++] = x; } } void push(int x) { if (pos >= array.length) { throw new Exception( “array is full” ); } array[pos++] = x; }
  8. 8. /10@yegor256 8 @Override void save() { // not implemented yet } @Override void save() { throw new Exception( “not implemented yet” ); }
  9. 9. /10@yegor256 9 file.delete(); if (!file.delete()) { throw new Exception( “failed to delete file” ); }
  10. 10. /10@yegor256 10 User find(int id) { if (/* not found */) { return null; } // continue... } User find(int id) { if (/* not found */) { throw new Exception( “user not found” ); } // continue... }
  11. 11. /10@yegor256 11 Fix Report Use Deploy
  12. 12. /10@yegor256 12 www.yegor256.com

×