This doesn't have to correspond to a concrete program element, but it helps clarity (and also forces teammates to do the right thing) if you encode contracts like this in interfaces (or pure abstract classes in the case of C++)
Program's contract with subclasses of Command. It exposes:
- read/write variable by name (probably
string& get_var(const string&)
andvoid set_var(const string&, string)
) - read/write program counter (probably
int get_icnt()
andvoid set_icnt(int)
)It's possible to represent the instruction counter as a variable which makes this interface smaller at the cost of some performance due to string comparisons
- read command by index (probably
const Command& get_cmd(int)
)