The Ministry of TruthRules for Good Software Design
Principles of good software design arePRINCIPLES OF GOOD OBJECT DESIGN
Waris Peace
Treat all inputsAS ATTACKS
A good interfaceIS NOT BROKEN BY BAD INPUT
throw {   name: ”Bad Input Error”,   message: ”Oh noes!”}
Freedom is Slavery
The more you constrain your code’s behaviour,THE MORE FREEDOM YOU HAVE TO ACT
run();
“There is only one mode,AND IT IS SECURE.”
Ignorance is Strength
Only give objects access to theTHINGS THEY NEED TO DO THEIR JOBS
To write better objects…• Leave your object in a consistent state  regardless of what your clients do.• Prevent clients fr...
To write better programs…• Leave your program in a consistent state  regardless of what your clients do.• Prevent clients ...
ThanksThis lightning talk was originally by Allen Short       and was presented at PyCon 2012
The Ministry of Truth Rules for Good Software Design
Upcoming SlideShare
Loading in …5
×

The Ministry of Truth Rules for Good Software Design

566 views

Published on

A reworking of a lightning talk presentation first made by Allen Short at PyCon 2012.

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

  • Be the first to like this

No Downloads
Views
Total views
566
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Greetings from the Ministry of Truth. We would like to take this opportunity to educate you on some principles of secure software design.
  • object/API/web service/module/plugin/extension/featureAnything with a public interface used by other code.
  • If your code is prepared for war, you can be at peace.
  • Treating all inputs as attacks protects all users.
  • We all remember little Bobby Tables…Don’t let Bobby happen to you.
  • A good object interface doesn't let bad input break it. Raise/throw exceptions.
  • This is how you throw an exception in JavaScript. The object literal is key.
  • Limit what can happen via your interface. The less choice a client has in how it interacts with your program, the more success you will have in securing it.
  • The ideal secure interface looks like this.
  • There should be one—and preferably only one—obvious way to do it.Adding features for convenience can constrain you later on. Lean development is better development.Do you have a requirement for it now? If not, don't code it.
  • The less your code knows about the less it can break.
  • Principle of least authority.Regardless of security, code cannot affect objects it doesn't know about. This means less bugs.This is why global variables are bad.Isolated code is easier to debug.
  • The Ministry of Truth Rules for Good Software Design

    1. 1. The Ministry of TruthRules for Good Software Design
    2. 2. Principles of good software design arePRINCIPLES OF GOOD OBJECT DESIGN
    3. 3. Waris Peace
    4. 4. Treat all inputsAS ATTACKS
    5. 5. A good interfaceIS NOT BROKEN BY BAD INPUT
    6. 6. throw { name: ”Bad Input Error”, message: ”Oh noes!”}
    7. 7. Freedom is Slavery
    8. 8. The more you constrain your code’s behaviour,THE MORE FREEDOM YOU HAVE TO ACT
    9. 9. run();
    10. 10. “There is only one mode,AND IT IS SECURE.”
    11. 11. Ignorance is Strength
    12. 12. Only give objects access to theTHINGS THEY NEED TO DO THEIR JOBS
    13. 13. To write better objects…• Leave your object in a consistent state regardless of what your clients do.• Prevent clients from accessing things they arent supposed to touch.• Only give your objects access to the resources they need to get the job done.
    14. 14. To write better programs…• Leave your program in a consistent state regardless of what your clients do.• Prevent clients from accessing things they arent supposed to touch.• Only give your programs access to the resources they need to get the job done.
    15. 15. ThanksThis lightning talk was originally by Allen Short and was presented at PyCon 2012

    ×