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
1
vote
1 answer

Subprogram contracts in Ada

I'm reading a document on Ada programming to be more specific, Ada for C++ Java developer, or I'm in trouble and to understand and be able to use some of the examples given in the document, one of them is on pre- and postconditions But, when I…
Alexandre
  • 1,985
  • 5
  • 30
  • 55
1
vote
3 answers

Is that possible, at compile time, to disable guava's Preconditions like we disable Java 1.4's assert keyword?

I used to insert java1.4's assertion construct in my codes and find it really practical because it allows me to enable the inserted assertions in debug- time and disable them at compile-time. My question is: whether it is possible to do the same…
zell
  • 9,830
  • 10
  • 62
  • 115
1
vote
4 answers

OCL: How can I write pre and postconditions for the operation max to find the maximum value from a collection?

I am trying to write pre and post conditions to find the maximum value of a collection 'col'. I'm not really sure how to go about it, recursively so I was wondering if someone could help! pre: true post: result = ...
mark
  • 2,841
  • 4
  • 25
  • 23
1
vote
1 answer

How to exclude Webresource.axd from firing my custom HttpModules

I've been searching around all day on the web but found nothing. In my web.config I set: And And this is…
Manight
  • 500
  • 5
  • 26
1
vote
4 answers

Do preconditions usually overlap with invariants?

I'm having trouble differentiating the two. If they do not usually overlap, how are they different? What is an example of something that would be a precondition but not an invariant?
dtgee
  • 1,272
  • 2
  • 15
  • 30
1
vote
1 answer

C#: How can I add a precondition to a property while using the 'default' storage?

Imagine a default property: class Positive { public int Value { get; set; } } I would like to add a precondition: that the set value can only be positive. Is it possible to do that without adding the member-variable boilerplate? public int…
xtofl
  • 40,723
  • 12
  • 105
  • 192
1
vote
1 answer

Should required preconditions for a method be verified by the method or the calling code?

To use a made up example, suppose I have a form.submit() method and I want to validate the form before submission. Should the validation go inside the method or outside of it in the calling code? If I put the validation inside the method then I can…
Nick Manley
  • 63
  • 1
  • 3
0
votes
1 answer

Precondition UML?

I'm using Agilian 3.2 to build a small activity diagram. The diagram contains a couple of actions. The problem is: I'd like to display the precondition somewhere in the diagram. Is there any standard way to define preconditions for an action or…
user1154138
  • 193
  • 1
  • 3
  • 9
0
votes
0 answers

Find the diagonal of a linear operator in scipy

I have a function, A(x), that I have turned into a linear operator using scipy.sparse.linalg.LinearOperator: A_operator = scipy.sparse.linalg.LinearOperator((ny, nx), matvec=A). I have an Ax=b problem where I am using the conjugate gradient method…
lrisley
  • 1
  • 2
0
votes
0 answers

Term for statements with vacuous weakest precondition

It seems like the class of statement, postcondition pairs (S, R) such that the weakest precondition wp(S, R) is true is a particularly interesting one (being in some sense “always” true). Is there a term for this set or property?
user2141650
  • 2,827
  • 1
  • 15
  • 23
0
votes
1 answer

Check preconditions in ASP.NET Core service early

In my ASP.NET Core app (currently .NET 7), I have some services with system-specific preconditions. For example, one service might require specific fonts to be installed, another one might require an external tool like Ghostscript to be installed. I…
Andi
  • 3,234
  • 4
  • 32
  • 37
0
votes
1 answer

Terraform - Precondition lifecycle

I want to do the following Update the KMS key resource to include lifecycle precondition If the referenced policy is null, use the constructed local policy Add a validator for the policy that if not set and the key type is direct, then…
doctore
  • 324
  • 1
  • 3
  • 14
0
votes
1 answer

ElasticSearch : how to filter and change an index with an array field to a boolean field?

I am using ElasticSearch 8.6. Here below is my index : 1st Example _source" : { "fieldA" : "M", "fieldB" : "SHOWER PACK", "fieldC" : "false", "fieldD" : "01", "fieldE" : "true", …
toch
  • 67
  • 6
0
votes
1 answer

Asserting a restriction on an associated value in an enum

I have an enum like... enum Analytics { case event(name: String) case other1 case other2 } But I need to make sure that the name value is no longer than 40 characters. Is there a way to have some sort of precondition on the value put into the…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
0
votes
0 answers

Error when calling a function from Preconditions

Preconditions.checkNotNull can only be called from within the same library group prefix (referenced groupId=`androidx.core` with prefix androidx from groupId=`nfc_app`) I am getting the above error when running my app. How do I fix this. I have…
Jgoieu
  • 1