Questions tagged [contract]

424 questions
55
votes
4 answers

Should a HashSet be allowed to be added to itself in Java?

According to the contract for a Set in Java, "it is not permissible for a set to contain itself as an element" (source). However, this is possible in the case of a HashSet of Objects, as demonstrated here: Set mySet = new…
davidmerrick
  • 1,027
  • 1
  • 10
  • 17
41
votes
5 answers

Are there null like thing in solidity

struct buyer { uint amount; Status status; } mapping(address=>buyer) public buyers; mapping(uint=>address) buyerIndex; uint public buyerNum; // Order a product. function() { uint doubleValue=value*2; uint…
Hao WU
  • 521
  • 1
  • 4
  • 5
28
votes
9 answers

The value is invalid according to its datatype 'clientcontracttype'

I am getting an error message saying: The contract attribute is invalid. the value is invalid according to its datatype 'clientcontracttype' Following is the endpoint configuration in web.config of this WCF application. I am using .NET…
Nirman
  • 6,715
  • 19
  • 72
  • 139
26
votes
2 answers

Where do smart contracts reside in blockchain (Ethereum or Hyperledger)

So, let us consider a typical trade finance process flow. Exporter deploys a contract that has conditions of the shipment and a hash is generated once the deployment is finished. Questions: 1) Where is the contract stored? 2) How other…
Saurabh
  • 1,249
  • 2
  • 13
  • 14
24
votes
3 answers

In WCF, can data contract classes inherit from one another?

In a WCF service, I have two classes with the [DataContract] attribute. One of these classes has an "is-a" relationship with the other - so class B can inherit from class A. However, when I configure inheritance between these two classes, both…
Jordan Parmer
  • 36,042
  • 30
  • 97
  • 119
23
votes
6 answers

In Ruby, what is the equivalent to an interface in C#?

I'm currently trying to learn Ruby and I'm trying to understand more about what it offers in terms of encapsulation and contracts. In C# a contract can be defined using an interface. A class which implements the interface must fulfil the terms…
fletcher
  • 13,380
  • 9
  • 52
  • 69
22
votes
6 answers

Interface Contract, Class Object?

Is contract to interface as object is to class? What is the need to differentiate identical things like this, from the code to the executing code? I sort of get the idea behind naming a class a class and the instantiated executing class an object,…
Adron
  • 2,371
  • 7
  • 25
  • 30
17
votes
2 answers

Meaning of @Flow annotation

In Intellij IDEA 14 there is a feature called Automatic Contract inference [1]. What exactly does the inferred @Flow annotation mean? For example for Collection's boolean addAll(Collection c)the inferred contract is boolean…
lukstei
  • 844
  • 2
  • 8
  • 20
15
votes
2 answers

How to force client code to initialize all required builder fields in Kotlin with contracts?

On JetBrains open day 2019 it was said that the Kotlin team researched contracts and tried to implement context contracts which allow calling a function only in some context, for example, a function build is allowed to be called only if setName…
IlyaMuravjov
  • 2,352
  • 1
  • 9
  • 27
15
votes
12 answers

Should an interface that is inherited from base-class be implemented explicitly in subclass?

My question is, if an interface that is implemented implicitly by extending a class that already implements it, should be explicitly implemented by the class, if the class wants to advertise the fact, that it fulfills the contract of that interface.…
Mnementh
  • 50,487
  • 48
  • 148
  • 202
14
votes
7 answers

why does my compare method throw exception -- Comparison method violates its general contract!

Why does this code public class SponsoredComparator implements Comparator { public boolean equals(SRE arg0, SRE arg1){ return arg0.getSponsored()==arg1.getSponsored(); } public int compare(SRE object1, SRE object2) { …
lost baby
  • 3,178
  • 4
  • 32
  • 53
13
votes
8 answers

Is there an beautiful way to assert pre-conditions in Java methods?

A lot of my functions have a whole load of validation code just below the declarations: if ( ! (start < end) ) { throw new IllegalStateException( "Start must be before end." ); } I'd like to precisly specify the valid ranges of certain…
Salim Fadhley
  • 22,020
  • 23
  • 75
  • 102
13
votes
3 answers

In the WCF web programming model, how can one write an operation contract with an array of query string parameters (i.e. with the same name)?

Using the WCF web programming model one can specify an operation contract like so: [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "SomeRequest?qs1={qs1}&qs2={qs2}")] XElement SomeRequest1(string qs1, string…
Dilip Krishnan
  • 5,417
  • 3
  • 37
  • 53
12
votes
1 answer

What is main use of "Add method contract to ..." Android Studio

I am getting following option like "Add method contract to 'setDisplayHomeAsUpEnabled'", I know that inspection is because of NPE can throw by getSupportActionBar() but I want to know actual use of Method Contract If I Press Enter on that…
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
11
votes
1 answer

How to write interface (contract) for object property (attribute) existence in python?

I'd like to have a contract on a parameter of some function to enforce the parameter object must have specific property. I understand python isn't a strictly typed language, but having contracts and interfaces is very useful sometimes. Python now…
goteguru
  • 443
  • 3
  • 14
1
2 3
28 29