ADT Design

Abstract Data Types

An abstract data type is a user defined type that bundles together

  • the range of values that variables of that type can hold
  • the operations that manipulate variables of that type

They provide tool-assisted safety since the compiler can catch programmers that are silly Type errors, leaving programmers with just having to worry about Logic errors.

Outside In Design

ADTs are interacted with using an Interface.

"Outside In Design" is when one designs ADTs starting with the external interface, and building the implementation around that.

1) Start with client use case + environment
2) Create Interface code and Test Cases
3) Define class functionality (get it working)

Each phase should be tested and refined, and there should remain consistency across interfaces when designing the ADT.

Attribute-based ADT

Attribute-based ADTs are primarily composed of "virtual data members", accessors, and mutators. All other function are non-member. This structure makes it easy to write the contract for the ADT.

What are "virtual data members"? They are members that may not have any actual storage, since they could be computed from other values. Changing a attribute may also cause a (re)computation to other attributes as a side effect.

Summary of why ADTs are rad

  • Safety
    • enforces range of legal values
    • compiler reports type incompatibilities
  • Evolvability
    • ADT is stable
      • i.e: client-code does not have to change if implementation changes -Efficiency
    • the only areas that must check for legal-values are: constructors and mutators (both member and nonmember)

results matching ""

    No results matching ""