[ 
https://issues.apache.org/jira/browse/DROIDS-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12974929#action_12974929
 ] 

Eugen Paraschiv commented on DROIDS-106:
----------------------------------------

Well, having a consistent way of handling precondition checking and exceptions 
in general provides a few advantages: 
- one improvement it brings is code readability - Preconditions.checkState 
communicates intent more clearly than manual checking (you can now 
differentiate cleanly between checking state, checking argument, checking 
something is non-null, etc)
- then, it ensures consistency - you make sure that the underlying code will 
always throw the same kind of exception, as opposed to deciding what to throw 
on a case by case basis. 
- then, manual checking means that a method that handles some logic has to 
change it's level of abstraction and throw exceptions by hand, thus going 
against a good practice of keeping a method at the same level of abstraction; 
Preconditions.check___ allows the code to be at a higher level of abstraction, 
allowing the method to focus on the logic rather than throwing some 
IllegalStateException by hand. 
And finally, while I submitted this patch with precondition checking as a 
simple first example of the Guava functionality, this is just one of the 
features it has. Guava is the former Google Collections, designed by the Joshua 
Bloch who created the standard Java Collection API, which makes Guava very 
collection focused and a natural extension to the standard collection API, and 
seeing how Droids makes and will make use of collections in many areas, it 
looks like a natural fit here as well. 
Hope this has helped. 
Thanks for the feedback, it's good to see activity on Droids. 
Eugen. 


> Introduce Guava (the former google collections) into the droids project
> -----------------------------------------------------------------------
>
>                 Key: DROIDS-106
>                 URL: https://issues.apache.org/jira/browse/DROIDS-106
>             Project: Droids
>          Issue Type: Wish
>          Components: core
>    Affects Versions: 0.0.1
>            Reporter: Eugen Paraschiv
>             Fix For: 0.0.1
>
>         Attachments: DROIDS-106.patch
>
>
> Google Guava is becoming a standard extension to the collection framework and 
> provides some very useful features (besides the obvious collection work which 
> is extensive), such as Preconditions (which would standardize the way 
> argument checking is done). 
> As far as I know, many other Apache projects use Guava (Mahout is one). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to