Questions tagged [preconditions]

A precondition is some condition which must be satisfied before running a given section of code. It may be specified in code via assertions, or in the documentation.

If a precondition is violated, errors or security issues may occur. A precondition states what is required for the section of code to run correctly.

Links

Related tags

166 questions
2
votes
1 answer

Custom condition failure messages in Ada 2012

Is there a way to specify a custom error/on failure message for pre- and postconditions, by analogy with Predicate_Failure for predicates? I can't seem to be able to find anything in the official documentation. TIA.
2
votes
1 answer

ADA - pre and post conditions not working?

I am trying to learn on my own pre and post conditions in ada.
catrev
  • 85
  • 7
2
votes
1 answer

Liquibase formatted sql precondition tableExists

Liquibase xml based changeset block: How it should be in "liquibase formatted sql"? Official documentation of Liquibase give only xml based
ykembayev
  • 108
  • 1
  • 8
2
votes
1 answer

forcing preconditions with empty constructor

I have a couple of objects that I need to be able to parse with, among other things, jersey. This forces me to explicitly add an empty constructor since the frameworks are instanciating using reflection and the empty constructor. The problem I am…
munHunger
  • 2,572
  • 5
  • 34
  • 63
2
votes
1 answer

General Minimum RESidual (GMRES) with ILU preconditioner

I'm trying to implement the ILU preconditioner in this GMRES code I wrote (in order to solve the linear sistem Ax = b. I'm trying with an easy tridiagonal SPD matrix of dimension 25x25. As you can see I'm calculating the preconditioner with spilu…
2
votes
0 answers

Nemerle - How do I write a method signature with a generic constraint and "requires" condition?

Using Nemerle, I want to create a method that has a generic type constraint and a 'requires' pre-condition. What is the proper order/syntax for these, with respect to the return type of the method? Here is a C# example of what I want: //Count the…
JamesFaix
  • 8,050
  • 9
  • 37
  • 73
2
votes
1 answer

How to interpret string as a negative number or zero and throw IAE accordingly?

I have a method in which I am accepting a String and that can be number as a string or a normal string. public Builder setClientId(String clientId) { checkNotNull(clientId, "clientId cannot be null"); checkArgument(clientId.length() > 0,…
user1950349
  • 4,738
  • 19
  • 67
  • 119
2
votes
3 answers

validate date in a particular format using preconditions

I have a date in string format YYYY/MM/DD HH:MM:SS which I need to validate using preconditions google guava class. I am using checkArgument method in lot of other places. How can I use checkArgument method to validate startDate to make sure it is…
user1950349
  • 4,738
  • 19
  • 67
  • 119
2
votes
2 answers

Share same method precondition logic between controllers and services?

I have a Service and a Controller . Each method in the service its preconditions , for example : public void doSomething(Parameter para1 , Parameter para2 ...) { if ( something wrong ) { throw new RuntimeException1(); } if (…
smallufo
  • 11,516
  • 20
  • 73
  • 111
2
votes
1 answer

Preconditioned Conjugate Gradient and LinearOperator in python

[Homework] I am going to solve the linear system Ax=b by the Preconditioned Conjugate Gradient method, and I use spilu function from scipy.sparse.linalg for the preconditioner. A is a sparse symmetric 162*162 matrix. Since the spilu gives an…
Bob
  • 217
  • 1
  • 3
  • 9
2
votes
1 answer

multiples dbms in precondition of liquibase using yaml

In precondition documentation of liquibase we can see the example below: When try to recreate the same rule using yaml, it not works. preConditions: dbms: …
josivan
  • 1,963
  • 1
  • 15
  • 26
2
votes
2 answers

Debugging in Java with preconditions

Working with Chromium codebase I got used to macros like CHECK(condition);, DCHECK(contidtion) and NOTREACHED;. They introduce assertions (usually preconditions) to the code and allow to terminate program with some info in a log, an in debug build…
Mateusz Kubuszok
  • 24,995
  • 4
  • 42
  • 64
2
votes
2 answers

PHPDoc preconditions

How to tag preconditions with PHPDoc? I have an object, and before calling a function another function must have been called: $myObject = new MyClass(); $myObject->mustDoThis(); $myObject->beforeThis(); So the documentation for beforeThis() would…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
2
votes
1 answer

Clojure precondition with local variable

Is there any way to store the result of a computation performed in a precondition so that it can be used in the actual function body. This is awful (costly-computation runs twice): (defn bar [x] …
4ZM
  • 1,463
  • 1
  • 11
  • 21
2
votes
5 answers

Pre-condition vs Post-condition in java?

For example I have the following code: public class Calc(){ final int PI = 3.14; //is this an invariant? private int calc(int a, int b){ return a + b; //would the parameters be pre-conditions and the return value be a…
user2708074