triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.35k stars 399 forks source link

New developer jar libraries - guava, hamcrest-all, mockito #12

Closed DanVanAtta closed 9 years ago

DanVanAtta commented 9 years ago

The following three libraries I think will need to be added very soon:

Down the road I think we'll be adding the jars for:

And of course eventually maven/gradle will be getting this stuff for us, so we won't have the jar file checked in. Till then, wanted to raise this issue, see if there was any objection.

veqryn commented 9 years ago

What specific functionality do each of these make possible?

DanVanAtta commented 9 years ago

guava - google's version of apache commons. Contains a dozen one-liner utilities, immutable collections, lots of useful stuff.

mockito - mocking library, triplatest had a discussion about alternatives. Seems like nobody minds too much and wished me a lot of luck to use mocks at all in this code

hamcrest-all - adds additional hamcrest matchers, makes hamcrest unit assertions useful (the matchers are pretty key to hamcrest)

dagger2 - dependency injection. Spring but lighter weight, smaller scope, and no XML

spock - behavioral testing library

veqryn commented 9 years ago

mockito, hamcrest, and spock, would not make it into our production releases because they are only for testing, correct?

DanVanAtta commented 9 years ago

Assuming we bundle things well, correct. To boot, dagger and spock will be a bit more time and discussion before they are added in. Guava, mockito and hamcrest I would expect to be added in pretty soon. Major points are probably more if those are the right libraries. Moving from Junit3 to Junit4+Hamcrest+Mockito are not terribly controversial as far as library picks. Some people I know really hate guava, but guava is very useful and generally a person should either be using guava or apache commons, or both : )

veqryn commented 9 years ago

Do any of these libraries require a certain version of java (7/8)? Would you still use guava if we upgraded to java 8? I'm fine with junit4/hamcrest/mockito.

DanVanAtta commented 9 years ago

In short, no version of java required. Going to java 8 I would still keep guava around for certain.

Longer answer: That library stack is effectively what I had at my last employer (couple months ago), so I've experience with them running with Java 6. So they can run in Java 6 with a version that will give us what we want (mostly the API).

Guava is an interesting one, and yes it would still be used going to java 8. It has some features that try to replicate Java 7 but in Java 6. For example: List myList = Lists.newArrayList(); (guava) Compare that to: List myList = new ArrayList<>(); (java 7) vs: List myList = new ArrayList<String>(); (pre java7)

The three examples show three different degrees of coupling, the top is the least coupled to the types "List" and the type "String" and the bottom is the most coupled.

The guava version is arguably better than Java7 in some respects since you don't invoke new. A colleague of mine once said that guava helps you actually stay on Java 6 because it takes some of the benefit of java 7 away.

If you are not familiar with guava, I very much recommend this: https://code.google.com/p/guava-libraries/wiki/GuavaExplained The above link describes a lot of features and even reasoning behind guava. A lot of it are useful day-to-day one liner type of things (these types of tool I regard as very important for being productive)

DanVanAtta commented 9 years ago

Closing, sounds like if we have some new Jars appear there won't be any surprise. Hamcrest and mockito likely will be very soon, guava same time or shortly later I would expect, and Dagger and Spock are more down the road type of items for the moment.