19
DBC Design By Contract Jackson Oliveira Software Architect @cyber_jso

DBC Principles

Embed Size (px)

Citation preview

DBCDesign By Contract

Jackson OliveiraSoftware Architect@cyber_jso

Jackson OliveiraSoftware Architect@cyber_jso

Jackson OliveiraSoftware Architect@cyber_jso

Lets talk about contracts

Would you accept this?

Terms and conditions - Formalism

Contracts - To ensure quality levels

The we can make the right assumptions

To rapid diagnose issues

We want correctness!

So DBC -> Design by Contract

● Define formal, precise, and verifiable interfaces

● Specifications for software components● Connection with automatic software

documentation

The idea isn’t new

Bertrand Meyer

What DBC is not?

● A Programming language● A Framework

How?

Preconditions

● Checks that conditions are satisfied before the execution

Postconditions

● Checks that conditions are satisfied after the execution

Invariants

● Checks the class state during, before and after the execution

Bads

● Some pre and post conditions may be complicated to express

● Tracking Invariants -> Tracking Side effects

Gods

● Enforces requirements analysis accuracy● God for internal APIs/Impl.● Contract rules compliance!

I stay with the principles

● Expressiveness● Explicit constraints● Contract driven● Decouple contracts from its

implementations● TDD and DBC aren’t mutually exclusive

Thanks!

Jackson OliveiraSoftware Architect@cyber_jso