Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Kotlin Delegation and Delegated proprieties  RSS feed

 
Ranch Hand
Posts: 472
8
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are days I am trying to grasp this concept but I cannot understand how/when to bring this in practice when I write some code. Does somebody has an example  of delegated proprieties that is easy to compare with normal Java?
 
Greenhorn
Posts: 17
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this link helps any...

http://www.jguru.com/faq/view.jsp?EID=27916
 
Giovanni Montano
Ranch Hand
Posts: 472
8
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Roundtree wrote:Not sure if this link helps any...

http://www.jguru.com/faq/view.jsp?EID=27916


thanks I studied this and other blogs, I understand now why composition is better than inherithance, still need to get acquainted with delegated proprieties, hopefully will write here in few days
 
Giovanni Montano
Ranch Hand
Posts: 472
8
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Giovanni Montano wrote:

Mike Roundtree wrote:Not sure if this link helps any...

http://www.jguru.com/faq/view.jsp?EID=27916


thanks I studied this and other blogs, I understand now why composition is better than inherithance, still need to get acquainted with delegated proprieties, hopefully will write here in few days


getting clearer but still do not dominate it 100%
 
Marshal
Posts: 5804
401
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you bring us to context please, so we could possibly join?
 
Giovanni Montano
Ranch Hand
Posts: 472
8
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:Could you bring us to context please, so we could possibly join?


You are absolutely right, I apologize if I am abstract but do not want to mix objective lack of documentation issues with my personal lack of composition/inheritance architectural concepts.
I will come back to you in few days, formulating better what exaclty I think everyone is missing, at my advice documentation is missing some chunk
 
Giovanni Montano
Ranch Hand
Posts: 472
8
Android Open BSD Slackware
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Giovanni Montano wrote:

Liutauras Vilda wrote:Could you bring us to context please, so we could possibly join?


You are absolutely right, I apologize if I am abstract but do not want to mix objective lack of documentation issues with my personal lack of composition/inheritance architectural concepts.
I will come back to you in few days, formulating better what exaclty I think everyone is missing, at my advice documentation is missing some chunk


Now I gained more solid insights. Basically the Delegation in Kotlin comes from the Delegation Design Pattern. And is made to make the coding more scalable, and implement new features without going up and down the heritage tree of classes that extend each other. Favoring composition over inheritance is a well known coding principle, and this is the reason why we find delegation in Kotlin, that has some kind of "helper methods" to facilitate real life scenarios where delegation could be used, like the lazy instantiation for instance.

A context as suggested by Liutauras would be an Adapter (a View in Android) that has different layouts( depending by the business logic behind in the presenter in a typical MVP easy scenario) ( MVP is an evolution of MVC for who does not know Android) With the delegate feature one can use in a clean and elegant why different layouts in this case
 
I want my playground back. Here, I'll give you this tiny ad for it:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!