Avery Ching commented on GIRAPH-144:

There are basically two approaches we can have here to prevent users from doing 
the wrong thing with GiraphJob: composition or inheritance (extends)

If we use composition, the benefits are that we only expose methods we want and 
users aren't exposed to Job methods directly that they shouldn't be.  The 
downside is that the Job is required sometimes (i.e. 
FileInputFormat#addInputPaths(Job job...)).  In this case, you can access the 
internal Job with GiraphJob#getInternalJob(), but the method is well documented 
that you should try to avoid using this directly.

If we choose inheritance (current approach), then we get to use 
FileInputFormat#addInputPath on GiraphJob directly, but should override every 
method by Job (and its parents) and prevent clients from using it by throwing 
exceptions.  This is a big ugly and depending on the version of Hadoop, is 
likely to have slightly different methods.

In my opinion, I prefer composition (see Joshua Bloch's Effective Java : Item 
16).  Issues will be found at compile time  for composition (i.e. 
GiraphJob#submit() doesn't exist and will be a compile bug) rather than at 
runtime for inheritance (GiraphJob#submit() throws an Exception).  Again, if 
users really need the Job, we do expose it in GiraphJob via the getter method 
and the javadoc should provide a warning to be careful.

> GiraphJob should not extend Job  (users should not be able to call Job 
> methods like waitForCompletion or setMapper..etc)
> ------------------------------------------------------------------------------------------------------------------------
>                 Key: GIRAPH-144
>                 URL: https://issues.apache.org/jira/browse/GIRAPH-144
>             Project: Giraph
>          Issue Type: Bug
>            Reporter: Dave
>            Assignee: Avery Ching
>         Attachments: GIRAPH-144.patch
>   Original Estimate: 24h
>  Remaining Estimate: 24h

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to