This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Defensive design" – news ·newspapers ·books ·scholar ·JSTOR(November 2025) (Learn how and when to remove this message) |

Defensive design is the practice of planning forcontingencies in thedesign stage of a project or undertaking. Essentially, it is the practice of anticipating all possible ways that an end-user could misuse a device, and designing the device so as to make such misuse impossible, or to minimize the negative consequences.[1] For example, if it is important that a plug is inserted into a socket in a particular orientation, the socket and plug should be designed so that it is physically impossible to insert the plug incorrectly.
Defensive design insoftware engineering is calleddefensive programming.Murphy's law is a well-known statement of the need for defensive design, and also of its ultimate limitations.
Implementation decisions andsoftware design approaches can make software safer and catch user errors.Code that implements this is termed asanity check.
Manyelectrical connectors apply this principle by being asymmetric.Alternatively,USB-C plugs are mechanically but not electrically symmetric, but achieve an illusion of symmetry resulting from how devices respond to the cable, and hence can be plugged in either of two ways. Accompanying circuitry makes the plugs and cables behave as though they are symmetric.[citation needed]