Questions tagged [design-by-contract]

Design by Contract (DbC) or Programming by Contract is an approach to designing computer software. It prescribes that software designers should define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with preconditions, postconditions and invariants. These specifications are referred to as "contracts", in accordance with a conceptual metaphor with the conditions and

Design by Contract (DbC) or Programming by Contract is an approach to designing computer software. It prescribes that software designers should define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with preconditions, postconditions and invariants. These specifications are referred to as "contracts", in accordance with a conceptual metaphor with the conditions and obligations of business contracts.

Because Design by Contract is a registered trademark of Eiffel Software in the United States, many developers refer to it as Programming by Contract, Contract Programming, or Contract-First development.

216 questions
0
votes
1 answer

What is the current best validation framework for asp.net apps?

To make sure its a DRY approach all validation logic should of course go in the business logic (model). How are validation messages presented to views, should be able to localize error messages Can you generate javascript from the validation…
terjetyl
  • 9,497
  • 4
  • 54
  • 72
0
votes
1 answer

Node.JS service layer design

I have a very simple express js server that accepts a request from a client, performs some business logic and respond back to the client. The request - response pipeline is handled by a controller and the business logic is performed inside the…
0
votes
1 answer

Can design by contract allow me to enforce private methods

I can't do this with language How to enforce private method since interface methods are only public? so can I use design by contract instead ?
user310291
  • 36,946
  • 82
  • 271
  • 487
0
votes
2 answers

Tool/Technique for Automatic Unit Test Generation based on Method Pre-/Post-Conditions

I wonder if there is any tool that automatically generates unit tests based on a method's pre- and post-conditions (and class invariant). To be precise, suppose we are given pre- and post-conditions (and probably class invariant) for a method and we…
0
votes
2 answers

Returning Null vs Exception vs Contract

What would be considered an acceptable way of dealing with returning a record from a DB with the following 3 potential outcomes: Db connection works, finds a user and returns a populated user object Db connection works, doesn't find a user, returns…
Royal Wares
  • 1,192
  • 10
  • 23
0
votes
1 answer

Eiffel: Unknown identifier on attached check into require statement

require valid_item: attached item as l_i and then l_i.valid_for_insert or l_i.valid_for_update why do I have an unknown identifier here with l_i??!!!
Pipo
  • 4,653
  • 38
  • 47
0
votes
1 answer

Eiffel: is there a way to express a double implies clause in eiffel?

Like double bind in psychology, is there a way to tell that one expression implies another and reversely? valid_last_error: attached last_error implies not attached last_success_message valid_last_success_message: attached last_success_message…
Pipo
  • 4,653
  • 38
  • 47
0
votes
1 answer

Dbc - anyone actually dare not to check preconditions in the called routines?

I know that DbC mandates that the caller is responsible for the precondition (parameters or maybe values of member variables) and I have just read, in one of the books, that actually few people are bold enough to really leave all the responsibility…
John V
  • 4,855
  • 15
  • 39
  • 63
0
votes
1 answer

Java Cofoja not working in eclipse

I tried to setup Cofoja in my eclipse project as described here. When I try to run my project with Cofoja I always get an IllegalArgumentException. [com.google.java.contract:agent FATAL ERROR while instrumenting cofoja/Main (stack trace…
user9483860
0
votes
3 answers

Should a Repository throw an exception if no change is to be stored?

During the stipulation of the contracts of my Repositories I started to wonder about an essential contract of any Repository: What happens if Update is called with a an entity on which no change is to be stored? As a client of the Repository I…
0
votes
1 answer

Spring Cloud Contract: Access hostname and port in contract response for URL generation

we are trying to provide a contract with the following characteristics: import org.springframework.cloud.contract.spec.Contract Contract.make { request { method(GET()) url("/v2/entity") headers { …
swinkler
  • 1,703
  • 10
  • 20
0
votes
4 answers

What is the best way to write a contract for CSS usage in Web Development?

Our Dev team had been developing enterprise web page more than 2 years ago. We are curious to know what is the best way to write a contract for CSS usage. For example, if we have a COMP, how we agree on a contract so our developers and our…
Geo
  • 8,663
  • 13
  • 63
  • 93
0
votes
1 answer

Preconditions and postconditions in interfaces and abstract methods

I'm trying to implement my own programming language, and i'm currently doing lexing and parsing. I'm nearly done and want to add native support for class invariants, preconditions and postconditions. public withdraw (d64 amount) : this { …
Thomas
  • 537
  • 1
  • 4
  • 14
0
votes
2 answers

Liskov Substitution Principle (LSP) violated via Design By Contract (DBC)?

I'm writing a framework in PHP, and have run into a pattern which smells bad. It appears that I'm implementing a contract (q.v. Design By Contract) that violates the Liskov Substituion Principle (LSP). Since the original example is heavily…
0
votes
1 answer

How to document/assert when inheritance induces a precondition for some final types only

Consider this simple base class Foo having a function foo calling a pure virtual function foo_, documented with Doxygen : class Foo { public: /** \brief This function logs x and does the job */ void foo(double x); protected: /**…
Caduchon
  • 4,574
  • 4
  • 26
  • 67