taksan / skype-java-api

Skype API for Java, based on Skype4Java library
128 stars 60 forks source link

Better support for unit testing #61

Open ncsibra opened 9 years ago

ncsibra commented 9 years ago

Hi,

Thanks for this great API, works really well. My only problem is, that really hard to write unit test in my own program, because the API using static methods, final classes, etc. Almost impossible to mock anything, need to create wrapper classes if I want to do that, map almost every returned object to a wrapped object, which is ugly and takes time.

Using static methods instead of singleton objects and make almost every class final was a good idea? What was the design decisions behind that?

The checked SkypeException is another very bad idea I think, the Java team itself trying to get rid of those kind of exceptions.

taksan commented 9 years ago

The API was originally developed by another developer and I took over, so I can't explain his decisions behind the design. I understand and agree that some of design decisions make it very hard to unit test, but I can't just phase out the way the API works now, since it is already public and it would break anyone who tried to upgrade to a new version.

The only thing that I could help with is changing SkypeException to a RuntimeException, since this won't break anything (I also dislike checked exceptions).

ncsibra commented 9 years ago

Thanks, but I don't think that change alone worth it. I understand your point too, of course, but I always thought, that a major refactor helps a lot in long term, instead of carrying crappy code just because of the compatibility.

In a new major version, like 2.0 it would be acceptable. The code base not that huge, so it won't be hard to do. The only thing which would really break others code, the static method change. But not a big deal to fix that.

If you change your mind and I will have some free time, maybe I could help also.