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

bibin sebastian commented on KAFKA-8666:
----------------------------------------

[~mjsax][~zafirov] I feel there is still some scope for improvement - to reduce 
confusion here.
When an API can support a construct like this
{code:java}
Materialized.as("MyStoreName").with(keySerde, valueSerde)
{code}
general perception is that "MyStoreName" is set in the first object created is 
never lost in the chain. 
This perception could also be because method name `with` - usually when I see a 
method name `with` in the builder pattern context, I tend to think that we are 
updating an existing object. I think that is what happened with KAFKA-8646 as 
well.
I know, if we use an IDE it will show it as a warning because the static method 
"with(keySerde, valueSerde)" is called on an object instance, but it is quite 
possible that developer never notices as that.

Looking at attributes of "Materialized" class, looks like fields storeName, 
keySerde and valueSerde are all optional. 

So, I think doing these steps will remove the confusion and satisfy our needs.
1 -  deprecate static method `Materialized.as("MyStoreName")` and replace it 
with a non static `Materialized.withStoreName(storeName)`. 
2 - provide static method `Materialized.default()` to return a Materialized 
object instance with storeName as null. 
3 - deprecate static method `with(final Serde<K> keySerde,   final Serde<V> 
valueSerde)` - we wouldn't need this anymore.

Or creating a builder class for "Materialized" class might be a better approach.

> Improve Documentation on usage of Materialized config object
> ------------------------------------------------------------
>
>                 Key: KAFKA-8666
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8666
>             Project: Kafka
>          Issue Type: Improvement
>          Components: documentation, streams
>            Reporter: Bill Bejeck
>            Priority: Major
>              Labels: newbie
>
> When using the Materialized object if the user wants to name the statestore 
> with
> {code:java}
> Materialized.as("MyStoreName"){code}
> then subsequently provide the key and value serde the calls to do so must 
> take the form of 
> {code:java}
> Materialized.as("MyStoreName").withKeySerde(keySerde).withValueSerde(valueSerde)
> {code}
> If users do the following 
> {code:java}
> Materialized.as("MyStoreName").with(keySerde, valueSerde)
> {code}
> the Materialized instance created by the "as(storeName)" call is replaced by 
> a new Materialized instance resulting from the "with(...)" call and any 
> configuration on the first Materialized instance is lost.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to