Reading 5: Designing Specifications
In this reading we’ll look at different specs for similar behaviors, and talk about the tradeoffs between them. We’ll look at three dimensions for comparing specs: How deterministic it is. Does the spec define only a single possible output for a given input, or does it permit a set of legal outputs? How declarative it is. Does the spec just characterize what the output should be, or does it explicitly say how to compute the output? How strong it is. Does the spec have a small set of legal implementations, or a large set? Not all specifications we might choose for a module are equally useful, and we’ll explore what makes some specifications better than others. Consider these two implementations of find: The subscripts First and Last are not actual TypeScript syntax. We’re using them here to distinguish the two implementations for the sake of discussion. In the actual code, both implementations should be TypeScript methods called find. Since we’ll be talking about multiple specifications
Reading 5: Designing Specifications > hide Snapdown help Snapdown is a language for drawing snapshot diagrams. Click on the links below to see examples of Snapdown in action! In each example, you'll see a snippet of Snapdown syntax and the corresponding diagram side-by-side. Primitives (click to expand) In this example, we have two variables: i points to the value 5 , and s points to the value "abc" . i -> 5 s -> "abc" Objects (click to expand) In this example, f points to a MyFloat object with the value 5.0 , s points to a MyString object with the value "abc" . f -> (MyFloat 5.0) s -> (MyStri
Explore this link on the map →related reading
- Reading 7: Designing Specificationsweb.mit.edu
- Reading 4: Specificationsweb.mit.edu
- Reading 6: Specificationsweb.mit.edu
- Reading 8: Mutability & Immutabilityweb.mit.edu
- Everything is Fertilenickcammarata.com
- artima - Josh Bloch on Designartima.com
- Problem Set 1: Flashcardsweb.mit.edu
- P2900R13.pdfisocpp.org
- Reading 12: Defining ADTs with Interfaces, Generics, Enums, and Functionsweb.mit.edu
- Galois - Specifications Don't Existgalois.com
- Reading 10: Abstract Data Typesweb.mit.edu
- Reading 11: Abstraction Functions & Rep Invariantsweb.mit.edu