Questions tagged [contracts]
63 questions
4
votes
2 answers
How to implement a Stack class in C#, with pre/postconditions and invariants?
Does anyone have any examples or ideas on how / what is the best way to implement a Stack class in C#? I understand that there is already a Stack class, but I need to understand how to actually implement a Stack class.
I also need advice on how to…

Cody
- 8,686
- 18
- 71
- 126
4
votes
2 answers
Is all of .NET updated to use Contracts?
Since the introduction of Contracts to .NET 4.0, I am wondering if Microsoft propagated this to all of their classes like in the BCL?
If not, then why? This kind of feature only makes sense if it's supported in the standard library by default,…

Joan Venge
- 315,713
- 212
- 479
- 689
4
votes
1 answer
code contracts build performance
My question is very straight forward: does any one experience increased build time when code contracts are enabled?
user407665
4
votes
1 answer
Scrapy contracts with multiple parse methods
What's the best approach to write contracts for Scrapy spiders that have more than one method to parse the response?
I saw this answer but it didn't sound very clear to me.
My current example: I have a method called parse_product that extracts the…

Gustavo Carvalho
- 178
- 6
4
votes
3 answers
When & how should constructors enforce limits on instance variables?
I'm new to programming and am learning Java as my first oo language, by working through Introduction to Programming Using Java by David J. Eck and reading forum posts when stuck.
My question could be considered a follow-up to Java Class Constructor…

newcoder
- 334
- 2
- 12
4
votes
7 answers
WCF contract for Field level update
I'm developing an application that does some CRUD operations through a WCF service. The read method returns a complete entity, the update is performed through a legacy system, and only the changed values should be updated.
What is the best way to…

Andronicus
- 1,799
- 1
- 14
- 28
4
votes
4 answers
Code Contracts and failure on private static readonly fields
I have a private static readonly field in my class:
public class MyClass
{
// ISSUE #1 -- requires unproven: path != null
private static readonly DirectoryInfo MyDirectory =
new DirectoryInfo(Settings.Default.MyDirectoryPath);
…

myermian
- 31,823
- 24
- 123
- 215
3
votes
4 answers
Why CodeContracts Static Analyzer doesn't make warnings?
I have several user controls, that are subscribed to the event handler in another class.
I'm learning CodeContracts in C#, and I wonder, why does Static Analyzer allows writing code like this:
void MyUserControl_MouseEnter(object sender,…

nevermind
- 2,300
- 1
- 20
- 36
3
votes
1 answer
How do we apply JML (openJML) to Java Code?
How do we apply JML to Java Code? I'm still new in Design by Contracts and quite lost on how to apply it into the program.
http://jmlspecs.sourceforge.net/
Using:
OpenJML
Netbeans 7.3
Java SDK 1.7
I have already added the OpenJML jar files into…

Mark
- 65
- 7
3
votes
1 answer
JML postcondition contains class method call
Can a JML postcondition for a class method contain a call to another method call
For example I have this class:
public class A
{
public int doA(x)
{ ... }
public int doB(int x, int y)
{ ... }
}
For the postcondition of doB can I…

Alina Danila
- 1,683
- 1
- 24
- 60
2
votes
3 answers
Adding custom developed code to software product
In your opinion is it common and ethical to do custom software development for a Customer and then add that software to your base product which is available to your other customers?
My take on it is that:
It's a contractual issue between you
and…

Damo
- 11,410
- 5
- 57
- 74
2
votes
2 answers
contracts in java
I'm trying to find out more about the meaning of contracts in java.
Here's an example of two contracts in java:
*/
* @pre arr != null
* @pre occurrences(4,arr) == occurrences(5, arr)
* @pre arr[arr.length – 1] != 4
* @pre forall 0 <= i <…

Unknown user
- 44,551
- 16
- 38
- 42
2
votes
0 answers
MassTransit: shared contracts
Can you please give your recommendations about sharing contracts between publisher and subsciber in mircroservices oriented architecture when using MassTransit as service bus? Would it be better to have a separate nuget package for this or have a…

Александр Сысоев
- 1,107
- 2
- 12
- 21
2
votes
2 answers
Contracts in C# 4.0
If I have a Vector3.Normalize() method that specifies a post condition where the resultant Vector3 is gonna have a length of 1, how would the compiler check for this at compile time (or before)? Does it just pass a random Vector3 variable to the…

Joan Venge
- 315,713
- 212
- 479
- 689
2
votes
1 answer
SvcUtil and /dconly generates XSD's for data types NOT marked with the DataContract attribute
Has anyone ever encountered a problem with Svcutil and the /dconly option where it generates metadata for EVERY data type in an Assembly, even if it is NOT marked with with the [DataContract()] attribute? It also appears to be generating metadata…

Adam Wilson
- 286
- 2
- 11