This multidisciplinary thesis is located at the intersection of legal theory and design. It synthesises the practical question of how code regulates (using theories including James Gibson's/Donald Norman's affordance, Don Ihde's postphenomenology, and Madeleine Akrich's inscription) with a legal-theoretical view of what constitutes legitimate regulation (using theories including Lon Fuller's internal morality of law, Luc Wintgens' legisprudence, and Mireille Hildebrandt's legal protection by design). Proceeding from the notion that code is an a-legal normative order, I argue that even (and indeed especially) in the absence of suitable or sufficient legal regulation, the norms of that order ought to be legitimated. This is particularly true given the unique characteristics of code as a regulator, which include its ruleishness, opacity, immediacy, immutability, pervasiveness, and, perhaps most importantly, its production by private enterprise. Having set out how code regulates from the perspective of the design theories mentioned above, I explore these characteristics from a legal-theoretical perspective, developing the concept of computational legalism, a uniquely strong form of the undesirable ideological phenomenon of legalism. This is the first significant contribution of the thesis. Having set up the parallel between legal and technological normativity, I explore the extent to which ex ante mechanisms for ameliorating legalism in the creation of legal norms can be translated into the 'legislature' of the design environment, to be applied in the creation of code-based norms. The motivating idea is that the standards that make legal norms legitimate ought mutatis mutandis to be applicable to other normative orders that enable and constrain individual behaviour. The literature has so far tended to focus on ex post assessments of code's operation, and to that extent it fails to account for computational legalism and the standards that must be met - by definition during the production process, ex ante - in order to mitigate or avoid it. Taking all of this into account, the second significant contribution of the thesis is a 'constitutional' framework of digisprudential affordances that I argue ought to be present in all user-facing code, in order to ensure that certain foundational capabilities are provided by the design. The affordances I identify are: contestability; transparency of provenance, purpose, and operation; choice; oversight; and delay. They act as a formal mechanism for constraining what substantive code can possibly do, imposing 'thin' constitutional design standards that ought to be met regardless of the 'thick' purposes or functionality of the digital artefact. I discuss how these might be implemented in practice through an analysis of two contemporary technologies, the Internet of Things and blockchain applications. This practical element of the thesis connects with the last significant novel contribution, namely an exploration of Cornelia Vismann and Markus Krajewski's concept of the programmer of the programmer, and how this 'constitutional actor' can be used to impose digisprudential limits - analogous to HLA Hart's secondary rules - within the code development process.