标签: contracts

你如何在Eclipse中使用CodePro的合同?

我以为我理解了CodePro的合同,但它们似乎没有任何效果.例如:

public class ContractTest {

    private int number;

    /**
     * @pre inputNumber > 0
     * 
     * Alternatively:
     * @post number > 0
     */
    public void setNumber(int inputNumber) {
        number = inputNumber;
    }

    public int getNumber() {
        return number;
    } 

    public static void main(String args[]) {
        ConditionsTest conditionsTest = new ConditionsTest();
        conditionsTest.setNumber(-5);
        System.out.println("Number: " + conditionsTest.getNumber());
    }
}
Run Code Online (Sandbox Code Playgroud)

运行main(String [])方法会导致:

number: -5
Run Code Online (Sandbox Code Playgroud)

打印.没有编译警告(预期),也没有抛出异常.此外,CodePro生成的junit测试方法不受合同的影响.

那么你如何使用CodePro的合同?

java eclipse contracts codepro

5
推荐指数
1
解决办法
1053
查看次数

如何在D接口中有意义地使用前提条件契约?

当我使用"in"合约覆盖D中的函数时,将检查继承的"in"合约.如果它们失败,则检查被覆盖的"in"合同.如果我没有在合同中指定任何合同,那么它被解释为好像有一个空的"in"合同.因此,以下代码编译并成功运行.

module main;
import std.stdio;

interface I
{
    void write( int i )
    in
    {
        assert( i > 0 );
    }
}

class C : I
{
    void write( int i )
    {
        writeln( i );
    }
}

int main()
{
    I i = new C;

    i.write( -5 );
    getchar();

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我只想在I.write()调用时检查前提条件,i.write()因为这是静态已知的足以I.write()使编译器正确运行的内容.动态调度之后检查所有前提条件从OO角度来看是奇怪的,因为封装丢失了.

我可以重复前提条件或写入in { assert( false ); }实现接口的所有类,但这很痛苦.这是D语言中的设计错误吗?或者有没有适当的可扩展方式来做到这一点?

contracts d interface

5
推荐指数
1
解决办法
274
查看次数

只有绝对URI可以用作基址

using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService)))在下面的代码中帮助获得例外

例外:只有绝对URI可用作基址

WCF主机应用程序

    class Program
    {
        static void Main()
        {
            using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService)))
            {
                host.Open();
                Console.WriteLine("Service Started");
                Console.ReadLine();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

合同执行

    public class HelloService : IHelloService
    {
        public string GetMessage(string Name)
        {
            return "Hello" + Name;
        }
    }
Run Code Online (Sandbox Code Playgroud)

合同

[ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        string GetMessage(string Name);
    }
Run Code Online (Sandbox Code Playgroud)

App.Config中

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
        <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
        </endpoint>
        <endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService"> …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net wcf contracts

5
推荐指数
1
解决办法
3733
查看次数

Laravel 5 错误 - Illuminate\Container\Container::make() 的声明必须与 Illuminate\Contracts\Container\Container::make 兼容

作曲家更新并安装合同后,我收到此错误:

Fatal error: Declaration of Illuminate\Container\Container::make() must be compatible with Illuminate\Contracts\Container\Container::make($abstract, array $parameters = Array) in C:\xampp\htdocs\app\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 12
Run Code Online (Sandbox Code Playgroud)

找不到解决办法,请问有人知道如何解决吗?

compiled.phpvendor文件夹中丢失了文件。所以当我把它拉回来时,一切都像以前一样。

好吧,现在我想登录或注册时得到这个:

类 App\User 包含 1 个抽象方法,因此必须声明为抽象方法或实现其余方法 (Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifierName)

contracts declaration composer-php illuminate-container laravel-5

5
推荐指数
0
解决办法
3141
查看次数

构造函数何时以及如何对实例变量实施限制?

我是编程新手,正在学习 Java 作为我的第一门 oo 语言,通过阅读 David J. Eck 的 Java 编程简介并在遇到问题时阅读论坛帖子。

我的问题可以被认为是Java 类构造函数参数的后续,其范围限制处理将 Hour 类的构造函数的 int 参数限制为 0 到 23。

上述问题的答案提到抛出 Instantiation Exception 或 IllegalArgumentException,但不清楚哪种风格更好。

此外,何时(如果有的话)与验证代码相关的开销是否合理?

java oop methods contracts

4
推荐指数
1
解决办法
305
查看次数

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 information on a page but I have more data that I need to extract for the same product in another page, so I yield a new request at the end of this method to make a …

python unit-testing contracts web-crawler scrapy

3
推荐指数
1
解决办法
1353
查看次数

WCF代理中的Action和ReplyAction

OperationContract属性中Action和ReplyAction的用途是什么?

wcf contracts

1
推荐指数
1
解决办法
6565
查看次数