[ 
https://issues.apache.org/jira/browse/KAFKA-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14059095#comment-14059095
 ] 

Jay Kreps commented on KAFKA-1040:
----------------------------------

Hey guys, I'm not sure I agree with this principle. The goal of a constructor 
is to construct a valid instance of the object. So validating the constructor 
arguments should totally be done in the constructor. Could you give a concrete 
example of how adding a separate validate() method would make things better?

> ConsumerConfig and ProducerConfig do "work" in the Constructor
> --------------------------------------------------------------
>
>                 Key: KAFKA-1040
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1040
>             Project: Kafka
>          Issue Type: Improvement
>          Components: config, consumer, producer 
>    Affects Versions: 0.8.0
>         Environment: Java 1.7
> Linux Mint 14 (64bit)
>            Reporter: Sharmarke Aden
>            Assignee: Neha Narkhede
>            Priority: Minor
>              Labels: config, newbie
>             Fix For: 0.9.0
>
>
> It appears that validation of configuration properties is performed in the 
> ConsumerConfig and ProducerConfig constructors. This is generally bad 
> practice as it couples object construction and validation. It also makes it 
> difficult to mock these objects in unit tests. 
> Ideally validation of the configuration properties should be separated from 
> object construction and initiated by those that rely/use these config objects.
> http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to