Changes between Version 15 and Version 16 of CodingStandards


Ignore:
Timestamp:
2011-09-26T22:41:20Z (13 years ago)
Author:
davidsarah
Comment:

s/_assert_consistency/_assert_invariants/

Legend:

Unmodified
Added
Removed
Modified
  • CodingStandards

    v15 v16  
    8282
    8383{{{
    84 def _assert_consistency(self):
     84def _assert_invariants(self):
    8585    # All of the keys in all of these dicts are required to be ids.
    8686    for d in (self.bId2chunkobj, self.bId2peers, self.Idsofwantedblocks, self.Idsoflocatedblocks,):
     
    9595}}}     
    9696
    97 Now you can put {{{assert self._assert_consistency()}}} everywhere in your class where the class ought to be in an internally consistent state. For example, at the beginning of every externally-callable method. This technique can be very valuable in developing a complex class -- it catches bugs early, it isolates bugs into specific code paths, and it clarifies the internal structure of the class so that other developers can hack on it without subtle misunderstandings.
     97Now you can put {{{assert self._assert_invariants()}}} everywhere in your class where the class ought to be in an internally consistent state. For example, at the beginning of every externally-callable method. This technique can be very valuable in developing a complex class -- it catches bugs early, it isolates bugs into specific code paths, and it clarifies the internal structure of the class so that other developers can hack on it without subtle misunderstandings.
     98
     99* we actually appear to only have one instance of this pattern in Tahoe at time of writing, in {{{allmydata.util.dictutil}}}. It has the disadvantage of cluttering up the logic with calls to {{{_assert_invariants}}}, and should probably be used sparingly. -- DavidSarah
    98100
    99101=== configuration ===