The document provides principles for good software design, including treating all inputs as potential attacks, ensuring interfaces are robust to bad input, constraining code's behavior to increase freedom, and only giving objects access to what they need to perform their job. It also recommends leaving programs and objects in a consistent state regardless of client actions and preventing unauthorized access. The document concludes by thanking Allen Short for originally presenting these principles at PyCon 2012.
1 of 16
Download to read offline
More Related Content
The Ministry of Truth Rules for Good Software Design
14. 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.
15. 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.
#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.
#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.