Monday, October 1, 2012

Is designing bug free software possible? A look into "Design By Contract" (DBC)

Design by Contract (DbC) is an approach for designing software. According to Eiffel Software, the originators of this method, DbC can be explained as follows:

"DbC is a metaphor on how elements of a software system collaborate with each other, on the basis of mutual obligations andbenefits. The metaphor comes from business life, where a "client" and a "supplier" agree on a "contract" which documents that:
    • The supplier must provide a certain product (obligation) and is entitled to expect that the client has paid its fee (benefit).
    • The client must pay the fee (obligation) and is entitled to get the product (benefit).
    • Both parties must satisfy certain obligations, such as laws and regulations, applying to all contracts."
It is said that utilizing this method guarantees that bugs will be prevented by implementing a system of checks and balances. This method also promotes coding to exacting specifications, providing no more or no less that is necessary. This implies that developers should not try to add more features or functionality into their code than is necessary to accomplish it's original task. In this way, the behavior of all code can be guaranteed, predictable, and consistent. 

Here are the benefits of DbC in a nutshell:
  • reliability
  • maintainability
  • well-documented
  • simpler and consistent code
Some drawbacks of DbC:
  • requires more diligence on the part of the programmer (= more work)
  • may result in performance issues - due to checking conditions at runtime

This all sounds great to me! 

However, while the theory of DbC sounds like an incredible idea, how likely is it that people will adopt and adhere to these concepts. 

1 comment: