0.0
No commit activity in last 3 years
No release in over 3 years
TODO
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

dbc¶ ↑

Design By Contract implemented for Ruby.

Philosophy¶ ↑

DBC, among other things, is a staple of the design concept, “Fail early, fail hard.” That is, it is better to catch problems earlier on rather than later. DBC does this by specifying input/output requirements of code, typically functions. When these constraints are broken, the DBC library causes a hard-fail of the system.

A classic example of DBC in actions would be to checking the divisor in a division is non-zero. This would be written as

def division(a, b)
  DBC.require(b != 0, "Divisor must be non-zero")  

  a / b
end

See en.wikipedia.org/wiki/Design_by_contract for more details.

Copyright © 2009 Mat Holroyd. See LICENSE for details.