Design Patterns in Kotlin Episode #2 | Kotlin Tutorial

preview_player
Показать описание
Alexey Soshin is back to discuss some more design patterns with Sebastian! The author of “Kotlin Design Patterns and Best Practices” presents the decorator and proxy pattern – a structural pattern also popularized in the “Gang of Four” book “Design Patterns: Elements of Reusable Object-Oriented Software.”

Together, Alexey and Sebastian work through a typical example case that shows where these patterns shine, which also illustrates why Alexey would rather have them be called the ‘wrapper’ pattern.

Get Alexey’s book at a 25% discount:
Code: SOSHINDECORATOR
End date: 7th Sep
Discount on: Print and eBook.

Рекомендации по теме
Комментарии
Автор

nice video and nice book, thanks for sharing!

hj
Автор

@19:12 wanted to probably say the reverse. You converted proxy to decorator. Great video 🎉

RatkaOdalovic-Radusinovic
Автор

Not a big deal, but there's a small bit of audio missing at the 16 Minute mark :)

rodneymkay
Автор

thanks!
this is cool series, with live code and more real implementation example

bboydarknesz
Автор

유익한 내용 감사합니다. 구현하면서 생각을 따라가게 되어서 정말 좋았네요. 마지막 내용을 보니 책으로 한 번 보고 다시 또 보면 더 좋을 것 같네요

zhoon-kim
Автор

Decorator is a good example of OCP: open for extension, closed for modification. Looking forward to reading this book. The Head First Design Patterns book has a good chapter that covers Decorator, although it's in Java.

scottloewke
Автор

Very interesting lesseon,
Also enjoyed the educational atmosphere of you guys interacting with the code.
Cheers!

sarpedonmontecarlo
Автор

great video, would love to see more episodes from this series and maybe some functional refactoring

markonovakovic
Автор

Actually interesting to know: What parts of the book did you bookmark? I think sharing your tabs can be a fun thing to do and it would also help promote the book!

ArthurKhazbs
Автор

Great video but there is more fundamental difference between proxy and decorator than described in video:
Proxy is intended to provide a surrogate or placeholder for another object to control access to it
Decorator is intended to add some functionality for another object without controlling access to it

According to this, there is a difference in implementation: proxy controls creation of delegate (creates by itself or obtains from dependency injection container) while constructor of decorator takes delegate as a parameter.

So both LoggingProcessor and CachingProcessor are actually deocrators rather than proxies.

gorttar
Автор

Thank you so much buddy i digg whole youtube for this but you are the only one ❤️🔥

hamzaproho
Автор

very much your efforts to help us noobs out.

camilocepedadanies
Автор

Now for the functional version! A processor is just a `(Request) -> Response` function and decorating is just map chaining functions.

robchr
Автор

sometimes when people have problems figuring out what the decorator pattern is about, I tell them: "think about BufferedInputStream" and they are like "oh yes of course" :) (because indeed, a proxy and a decorator are so similar there's a little point to differentiate between them)

jakubgwozdz
Автор

So can we say that the Filter "Pattern" or at least how FilterChains are implemented is somewhat a mix of Proxy and Decorator? Because in a Filter there is a condition that decides if the next in line will be process/called?

xetra
Автор

I implemented similar kind of pattern for Kafka consumer processing event, We had requirement where we need to check in inbox table for eventId before processing the event basically for duplicate check so what i did i created HOF and wrapped processEvent function in that. I hope Kotlin will have pattern matching like OCaml that this language will be rock :)

amol_
Автор

Would you say that Kotlin Flow and it's processing/transformation functions are a kind of a Wrapper pattern for a Type that is already implemented but for reactive programming?

PedroBarbosaRoman
Автор

Packtpub redirects print purchases to Amazon ☹️

_caioiglesias_
Автор

Decorator/Proxy often introduce a lost of unnecessary wrappings - we can achieve the same effect without introducing these wrappers/types by simply using extension functions

IsuruKusumal
Автор

How I wish I can write code they way you people do

scienceschool
visit shbcf.ru