Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between precondition, postcondition and invariant constraints?

Tags:

uml

I am new to programming and this site and I am studying about some of the terminology for UML design and I am looking for a basic response. I looked up the definition of each of the terms but I am still trying to grasp the concept.

like image 911
Ryan Rammell Avatar asked Mar 05 '15 18:03

Ryan Rammell


1 Answers

A pre condition is something that must be true before the use case is invoked. e.g. a precondition for a use case "Buy Book on WebSite" might be "The user has accessed the website and wants to buy a book".

A post condition is something that must be true after the use case is finished. e.g. The user has successfully purchased a book.

An invariant is something that must always be true throughout the use case. e.g. The user's ID matches an ID from the Users table in the database.

like image 148
Dermot Blair Avatar answered Sep 27 '22 19:09

Dermot Blair