Hi Greg,

The point is that the approach proposed here introduces complexity forever.
Each new user of this interface that needs access to the parameters not
exposed originally needs to implement the abstract method with an empty
implementation and it needs to override whichever additional default they
care about (this KIP introduces a second method, but future KIPs would
introduce additional methods for new parameters). One would never design
the interface like this from the start.

With the DTO approach, you don't create a new DTO, you simply add a new
overloaded constructor and accessor to the DTO. The implementers of the
interface still have a single method (two here since we made a mistake
originally) and they can decide which of the values from the DTO they would
like to access. This approach has been the recommended approach for years
and it's how the Admin apis work (they're the most recent client). An
example:

createTopics(Collection<NewTopic> newTopics, CreateTopicsOptions options);

This makes it easy to add new fields to `NewTopic` or `CreateTopicsOptions`.

Ismael

On Wed, Aug 23, 2023 at 11:48 AM Greg Harris <greg.har...@aiven.io.invalid>
wrote:

> Hey Jack,
>
> The design of this KIP is also consistent with the way header support
> was added to Connect:
>
> https://cwiki.apache.org/confluence/display/KAFKA/KIP-440%3A+Extend+Connect+Converter+to+support+headers
> I think making argument for precedent here is reasonable.
>
> Hi Ismael,
>
> Can you expand what you mean by "without breaking compatibility"? I
> think the approach proposed here (a default method) would be backwards
> compatible. If an implementation wishes to make use of the new
> signature, they can override the new method and the version of Kafka
> will determine which implementation is used without instance checking,
> reflection, or exceptions.
>
> I believe that when you pass a DTO, that some sort of instance
> checking, reflection, or exceptions would be required for the
> Partitioner to determine whether additional information is present.
> For example, if we wished to add some information X to the partitioner
> in the future, the caller could pass either a `PartitionInfo` or
> `PartitionInfoWithX` DTO instance, and the callee could use an
> `instanceof` check and a cast before accessing the X information. That
> seems to be more machinery for the Partitioner implementation to
> manage as compared to maintaining multiple methods, which may just be
> one-line calls to other methods.
>
> Please let me know if I've misunderstood your DTO design.
>
> Thanks!
> Greg
>
> On Tue, Aug 22, 2023 at 9:33 PM Jack Tomy <jacktomy...@gmail.com> wrote:
> >
> > Hi Ismael,
> >
> > That would be totally different from the pattern currently being followed
> > in all the interfaces, for example serializer.
> > I personally don't favour that either. Let's see if the community has any
> > opinions on the same.
> >
> > Hey everyone, please share your thoughts on using a DTO instead of
> separate
> > params for the interface.
> >
> > Thanks.
> >
> > On Mon, Aug 21, 2023 at 8:06 PM Ismael Juma <m...@ismaeljuma.com> wrote:
> >
> > > Hi Jack,
> > >
> > > I mean a DTO. That means you can add additional parameters later
> without
> > > breaking compatibility. The current proposal would result in yet
> another
> > > method each time we need to add parameters.
> > >
> > > Ismael
> > >
> > > On Sun, Aug 20, 2023 at 4:53 AM Jack Tomy <jacktomy...@gmail.com>
> wrote:
> > >
> > > > Hey Ismael,
> > > >
> > > > Are you suggesting to pass a param like a DTO or you are suggesting
> to
> > > pass
> > > > the record object?
> > > >
> > > > I would also like to hear other devs' opinions on this as I
> personally
> > > > favour what is done currently.
> > > >
> > > > On Thu, Aug 17, 2023 at 9:34 AM Ismael Juma <m...@ismaeljuma.com>
> wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Thanks for the KIP. The problem outlined here is a great example
> why we
> > > > > should be using a record-like structure to pass the parameters to a
> > > > method
> > > > > like this. Then we can add more parameters without having to
> introduce
> > > > new
> > > > > methods. Have we considered this option?
> > > > >
> > > > > Ismael
> > > > >
> > > > > On Mon, Aug 7, 2023 at 5:26 AM Jack Tomy <jacktomy...@gmail.com>
> > > wrote:
> > > > >
> > > > > > Hey everyone.
> > > > > >
> > > > > > I would like to call for a vote on KIP-953: partition method to
> be
> > > > > > overloaded to accept headers as well.
> > > > > >
> > > > > > KIP :
> > > > > >
> > > > >
> > > >
> > >
> https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=263424937
> > > > > > Discussion thread :
> > > > > > https://lists.apache.org/thread/0f20kvfqkmhdqrwcb8vqgqn80szcrcdd
> > > > > >
> > > > > > Thanks
> > > > > > --
> > > > > > Best Regards
> > > > > > *Jack*
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Best Regards
> > > > *Jack*
> > > >
> > >
> >
> >
> > --
> > Best Regards
> > *Jack*
>

Reply via email to