design-by-contract

When to use assert in client & common GWT code

陌路散爱 提交于 2019-12-21 04:13:34
问题 There are several questions on StackOverflow discussing the question of when one should use an assert statement versus throwing some exception. (Examples here, here, here, here, and here. However, I have come to suspect that the conventional wisdom of assert-versus-throw is based upon the assumption that you are running within a JVM. In the GWT universe, where your Java gets transliterated to JavaScript and runs in the context of a browser, the set of tradeoffs feels different: asserts are

When to use assert in client & common GWT code

∥☆過路亽.° 提交于 2019-12-21 04:13:32
问题 There are several questions on StackOverflow discussing the question of when one should use an assert statement versus throwing some exception. (Examples here, here, here, here, and here. However, I have come to suspect that the conventional wisdom of assert-versus-throw is based upon the assumption that you are running within a JVM. In the GWT universe, where your Java gets transliterated to JavaScript and runs in the context of a browser, the set of tradeoffs feels different: asserts are

Unit tests - The benefit from unit tests with contract changes?

点点圈 提交于 2019-12-20 08:00:55
问题 Recently I had an interesting discussion with a colleague about unit tests. We were discussing when maintaining unit tests became less productive, when your contracts change. Perhaps anyone can enlight me how to approach this problem. Let me elaborate: So lets say there is a class which does some nifty calculations. The contract says that it should calculate a number, or it returns -1 when it fails for some reason. I have contract tests who test that. And in all my other tests I stub this

Should JSON RESTful web services use data contract

感情迁移 提交于 2019-12-18 09:04:14
问题 This is actually a design question. I'm wondering if Spring3.0 REST web services that carries JSON payload provide some kind of data contract similar to traditional web services which follows contract-first design. I know that JSON has schema similar to XSD but where does it fits in spring ? Background: I consider using json as the payload of a client server architecture project where the client is .NET based application and data contract should provide a way to handle multiple versions of

Ruby and duck typing: design by contract impossible?

。_饼干妹妹 提交于 2019-12-17 23:12:52
问题 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

Design By Contract and Test-Driven Development [closed]

瘦欲@ 提交于 2019-12-17 17:28:57
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 months ago . I'm working on improving our group's development process, and I'm considering how best to implement Design By Contract with Test-Driven Development. It seems the two techniques have a lot of overlap, and I was wondering if anyone had some insight on the following (related)

Can design by contract allow me to enforce private methods

谁都会走 提交于 2019-12-13 04:57:36
问题 I can't do this with language How to enforce private method since interface methods are only public? so can I use design by contract instead ? 回答1: If you are interested in enforcing a particular coding style, naming conventions, or things like that you are better off implementing custom rules for tools like FxCop or StyleCop. There really aren't any features in either the C# language or the .NET environment to help you enforce such things. However, before you go to such lengths, you should

Is it possible to enforce Design by Contract checks at compile time?

冷暖自知 提交于 2019-12-11 17:18:18
问题 Reading Design by Contract tutorial I stumbled upon the following line: Contracts in Eiffel are not just wishful thinking. They can be monitored at run time under the control of compilation options. followed by explanations that they will throw exceptions when fail. It makes me think that all the require ensure invariant all checks can be either performed at runtime or turned off. Is this correct? Or they can be enforced at compile time as well using appropriate compiler options? 回答1: There

Design by Contract: Can you have an Interface with a Protocol?

巧了我就是萌 提交于 2019-12-11 09:51:04
问题 I'm pretty new to the concept of Design by Contract, but so far, I'm loving how easy it makes it to find potential bugs. However, I've been working with the Microsoft.Contracts library (which is pretty great,) and I have run into a road block. Take this simplified example of what I'm trying to do: public enum State { NotReady, Ready } [ContractClass(typeof(IPluginContract))] public interface IPlugin { State State { get; } void Reset(); void Prepare(); void Run(); } [ContractClassFor(typeof

How do I insert a precondition in a java class method or constructor?

蹲街弑〆低调 提交于 2019-12-10 03:59:53
问题 This is for a java class I'm taking. The book mentions preconditions and postconditions but doesn't give any examples how to code them. It goes on to talk about asserts, I have that down, but the assignment I'm doing specifically states to insert preconditions and test the preconditions with asserts. Any help would be great. 回答1: Languages like Eiffel support "preconditions" and "postconditions" as a basic part of the language. One can make a compelling argument that the whole purpose of an