Top Banner
DBC Design By Contract Jackson Oliveira Software Architect @cyber_jso
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DBC Principles

DBCDesign By Contract

Jackson OliveiraSoftware Architect@cyber_jso

Jackson OliveiraSoftware Architect@cyber_jso

Jackson OliveiraSoftware Architect@cyber_jso

Page 2: DBC Principles

Lets talk about contracts

Page 3: DBC Principles

Would you accept this?

Page 4: DBC Principles

Terms and conditions - Formalism

Page 5: DBC Principles

Contracts - To ensure quality levels

Page 6: DBC Principles

The we can make the right assumptions

Page 7: DBC Principles

To rapid diagnose issues

Page 8: DBC Principles

We want correctness!

Page 9: DBC Principles

So DBC -> Design by Contract

● Define formal, precise, and verifiable interfaces

● Specifications for software components● Connection with automatic software

documentation

Page 10: DBC Principles

The idea isn’t new

Bertrand Meyer

Page 11: DBC Principles

What DBC is not?

● A Programming language● A Framework

Page 12: DBC Principles

How?

Page 13: DBC Principles

Preconditions

● Checks that conditions are satisfied before the execution

Page 14: DBC Principles

Postconditions

● Checks that conditions are satisfied after the execution

Page 15: DBC Principles

Invariants

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

Page 16: DBC Principles

Bads

● Some pre and post conditions may be complicated to express

● Tracking Invariants -> Tracking Side effects

Page 17: DBC Principles

Gods

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

Page 18: DBC Principles

I stay with the principles

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

implementations● TDD and DBC aren’t mutually exclusive

Page 19: DBC Principles

Thanks!

Jackson OliveiraSoftware Architect@cyber_jso