You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by "Artem Malykh (JIRA)" <ji...@apache.org> on 2018/11/28 12:28:00 UTC

[jira] [Created] (IGNITE-10441) Fluent API refactoring.

Artem Malykh created IGNITE-10441:
-------------------------------------

             Summary: Fluent API refactoring.
                 Key: IGNITE-10441
                 URL: https://issues.apache.org/jira/browse/IGNITE-10441
             Project: Ignite
          Issue Type: Improvement
          Components: ml
            Reporter: Artem Malykh
            Assignee: Artem Malykh


In many classes we have fluent API ("with*" methods). We have following problem: these methods should return exactly instance of it's own class (otherwise we'll have problems with subclasses, more precisely, if with method is declared in class A and we have class B extending A, with method (if we do not override it) will return A). Currently we opted to override "with" methods in subclasses. There is one solution which is probably more elegant, but involves relatively complex generics construction which reduces readability:

 
{code:java}
class A<Self extends A<? super Self>> {
  Self withX(X x) {
    this.x = x;
     
    return (Self)this;
  }

class B<Self extends B<? super Self>> extends A<B> {
   // No need to override "withX" here
   Self withY(Y y) {
     this.y = y;
     
     return(Self)this;
   }

}

class C<Self extends C<? super Self>> extends B<C> {
   // No need to override "withX" and "withY" methods here.
}

//... etc
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Re: [jira] [Created] (IGNITE-10441) Fluent API refactoring.

Posted by Alexey Zinoviev <za...@gmail.com>.
Hi, Artem!

In the first, I don't remember many places (trainers/models) where the
overriding is a big deal. Could you provide any examples, where it can be a
problem?

In the second, 'with' methods are unified way to inject hyperparameters via
Reflection API for Pipeline API.

But, in common, it's interesting idea how to solve the problem if it is the
popular problem. 

It will be interesting to see the results of your thoughts in the
experimental branch and dicsuss later.
If you do that, please reply this email here with link on the branch.



--
Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/