design-by-contract

Library to facilitate the use of the “design by contract” principle [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 06:57:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Is there any library that aids in implementing the design by contract principle in a C++ application? In particular, I'm looking for a library that facilities the usage of the principle, something like this. 回答1: I followed the teachings of the following articles: An exception or a bug? (Miro Samek, C/C++ Users

Why is design-by-contract not so popular compared to test-driven development?

狂风中的少年 提交于 2019-11-30 06:16:17
问题 You may think this question is like this question asked on StackOverflow earlier. But I am trying to look at things differently. In TDD, we write tests that include different conditions, criteria, verification code. If a class passes all these tests we are good to go. It is a way of making sure that the class actually does what it's supposed to do and nothing else. If you follow Bertrand Meyers ' book Object Oriented Software Construction word by word, the class itself has internal and

Does Design By Contract Work For You? [closed]

不羁的心 提交于 2019-11-30 03:01:27
Do you use Design by Contract professionally? Is it something you have to do from the beginning of a project, or can you change gears and start to incorporate it into your software development lifecycle? What have you found to be the pros/cons of the design approach? I came across the Design by Contract approach in a grad school course. In the academic setting, it seemed to be a pretty useful technique. But I don't currently use Design by Contract professionally, and I don't know any other developers that are using it. It would be good to hear about its actual usage from the SO crowd. I can't

Contract.Requires usage

拥有回忆 提交于 2019-11-29 22:51:09
Here is my problem. I am a very big fan of Design by contract, I am using this concept especially when developing libraries that can be used by other developers. I just found out a new way of doing this which is: Contract.Requires instead of Exception : So instead of having: public void SomeMethod(string name){ if(name==null) throw new NullArgumentException("Null values not supported"); } I now have: public void SomeMethod(string name){ Contract.Requires(name != null); } EDIT : I am working under VS2010 on debug mode. Problem: Contract.Requires does not do anything, even when name is null !

Design by contracts and constructors

青春壹個敷衍的年華 提交于 2019-11-29 06:30:46
I am implementing my own ArrayList for school purposes, but to spice up things a bit I'm trying to use C# 4.0 Code Contracts. All was fine until I needed to add Contracts to the constructors. Should I add Contract.Ensures() in the empty parameter constructor? public ArrayList(int capacity) { Contract.Requires(capacity > 0); Contract.Ensures(Size == capacity); _array = new T[capacity]; } public ArrayList() : this(32) { Contract.Ensures(Size == 32); } I'd say yes, each method should have a well defined contract. On the other hand, why put it if it's just delegating work to the "main" constructor

Is Java assert broken?

荒凉一梦 提交于 2019-11-29 05:26:10
问题 While poking around the questions, I recently discovered the assert keyword in Java. At first, I was excited. Something useful I didn't already know! A more efficient way for me to check the validity of input parameters! Yay learning! But then I took a closer look, and my enthusiasm was not so much "tempered" as "snuffed-out completely" by one simple fact: you can turn assertions off.* This sounds like a nightmare. If I'm asserting that I don't want the code to keep going if the input

Does Design By Contract Work For You? [closed]

扶醉桌前 提交于 2019-11-29 00:39:42
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Do you use Design by Contract professionally? Is it something you have to do from the beginning of a project, or can you change gears

Library to facilitate the use of the “design by contract” principle [closed]

天大地大妈咪最大 提交于 2019-11-28 23:13:58
Is there any library that aids in implementing the design by contract principle in a C++ application? In particular, I'm looking for a library that facilities the usage of the principle, something like this . Daniel Daranas I followed the teachings of the following articles: An exception or a bug? (Miro Samek, C/C++ Users Journal, 2003) Simple Support for Design by Contract in C++ (Pedro Guerreiro, TOOLS, 2001) What I ultimately applied was pretty much Samek's approach. Just creating macros for REQUIRE, ENSURE, CHECK and INVARIANT (based on the existing assert macro) was very useful. Of course

Contract.Requires usage

China☆狼群 提交于 2019-11-28 20:38:42
问题 Here is my problem. I am a very big fan of Design by contract, I am using this concept especially when developing libraries that can be used by other developers. I just found out a new way of doing this which is: Contract.Requires instead of Exception : So instead of having: public void SomeMethod(string name){ if(name==null) throw new NullArgumentException("Null values not supported"); } I now have: public void SomeMethod(string name){ Contract.Requires(name != null); } EDIT : I am working

Ruby and duck typing: design by contract impossible?

孤街醉人 提交于 2019-11-28 20:31:40
Method signature in Java: public List<String> getFilesIn(List<File> directories) similar one in ruby def get_files_in(directories) In the case of Java, the type system gives me information about what the method expects and delivers. In Ruby's case, I have no clue what I'm supposed to pass in, or what I'll expect to receive. In Java, the object must formally implement the interface. In Ruby, the object being passed in must respond to whatever methods are called in the method defined here. This seems highly problematic: Even with 100% accurate, up-to-date documentation, the Ruby code has to