Wednesday, December 03, 2003
Defensive Programming vs Design by Contract
From: DonXML Demsak's All Things Techie
UML for .NET Developers
Model Constraints & The Object Constraint Language
What is the Object Constraint Language? A language for expressing necessary extra information about a model A precise and unambiguous language that can be read and understood by developers and customers A language that is purely declarative – ie, it has no side-effects (in other words it describes what rather than how) . . . Defensive programming is the practice of making the supplier of an operation check the pre-conditions before executing the body of the method, and throwing an exception if a pre-condition is broken. Notice that in this scheme, the constraints are reversed (they are the NOT of the OCL constraints, since we are interested in when they’re NOT satisfied. For this reason – and others - I’m not too keen on the defensive approach…
Comments:
Post a Comment