際際滷

際際滷Share a Scribd company logo
The Ministry of Truth
Rules for Good Software Design
Principles of good software design are

PRINCIPLES OF GOOD OBJECT DESIGN
War
is Peace
Treat all inputs

AS ATTACKS
The Ministry of Truth Rules for Good Software Design
A good interface

IS NOT BROKEN BY BAD INPUT
throw {
   name: Bad Input Error,
   message: Oh noes!
}
Freedom
 is Slavery
The more you constrain your codes 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 the

THINGS 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 from accessing things they
  aren't supposed to touch.

 Only give your objects access to the
  resources they need to get the job done.
To write better programs
 Leave your program in a consistent state
  regardless of what your clients do.

 Prevent clients from accessing things they
  aren't supposed to touch.

 Only give your programs access to the
  resources they need to get the job done.
Thanks
This lightning talk was originally by Allen Short
       and was presented at PyCon 2012

More Related Content

The Ministry of Truth Rules for Good Software Design

Editor's Notes

  • #2: Greetings from the Ministry of Truth. We would like to take this opportunity to educate you on some principles of secure software design.
  • #3: object/API/web service/module/plugin/extension/featureAnything with a public interface used by other code.
  • #4: If your code is prepared for war, you can be at peace.
  • #5: Treating all inputs as attacks protects all users.
  • #6: We all remember little Bobby TablesDont let Bobby happen to you.
  • #7: A good object interface doesn't let bad input break it. Raise/throw exceptions.
  • #8: This is how you throw an exception in JavaScript. The object literal is key.
  • #10: 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.
  • #11: The ideal secure interface looks like this.
  • #12: There should be oneand preferably only oneobvious 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.
  • #13: The less your code knows about the less it can break.
  • #14: 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.