Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephenh/interfacegen
generates interfaces
https://github.com/stephenh/interfacegen
Last synced: 2 days ago
JSON representation
generates interfaces
- Host: GitHub
- URL: https://github.com/stephenh/interfacegen
- Owner: stephenh
- License: other
- Created: 2010-01-21T05:32:41.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2010-04-06T21:43:34.000Z (over 14 years ago)
- Last Synced: 2024-10-12T10:15:22.752Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 336 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.markdown
Awesome Lists containing this project
README
Intro
=====interfacegen is meant to relieve some of the boilerplate crap that happens on Java projects.
Unfortunately, Interfaces Are Nice
==================================When testing Java-based systems, it is often times easier to mock/stub out an interface than a class.
E.g. a constructor of:
public class Foo(ISomeInterface foo) {
}Is more likely to be testable than:
public class Foo(SomeClass foo) {
}Because `SomeClass` will have constructor parameters/etc. that depend on real-world things.
Unfortunately, This Means One Interface Per Class
=================================================Having an interface with only one implementation, just to satisfy mocking/whatever is very annoying.
So, interfacegen is here to help.
If you provide:
@GenInterface
public class SomeClass implements ISomeClass {
public void doFoo() {
// implementation
}
}interfacegen will spit out:
public interface ISomeClass {
void doFoo();
}Any methods you add/remove change to `SomeClass` will automatically get updated in `ISomeClass`.
You are basically driving the definition of the interface from its implementation class.
Backwards? Yes.
But so is the whole one-implementation-per-interface-so-we-can-mock predicament.
This is just a band-aid.