The Chain of Responsibility Pattern Explained & Implemented | Behavioral Design Patterns | Geekific

preview_player
Показать описание

In this video, we break down, define and implement in Java the Chain of Responsibility behavioral design pattern.

Timestamps:
00:00 Introduction
00:07 What is the Chain of Responsibility Pattern?
01:56 Chain of Responsibility Pattern Class Diagram
03:08 Chain of Responsibility Implementation
06:46 Recap
07:26 Thanks for Watching!

If you found this video helpful, check other Geekific uploads:

#Geekific #DesignPatterns #ChainOfResponsibilityPattern #BehavioralPatterns
Рекомендации по теме
Комментарии
Автор

Thanks to @Michal Dudek in the comments below, at around 6:40 the code on the main class should be the below (it is updated on GitHub):
Handler handler = new UserExistsHandler(database);

handler.setNextHandler(new RoleCheckHandler());

AuthService service = new AuthService(handler);

geekific
Автор

you are the greatest man, made a module in university 10x easier, I love you man

Stikmanas
Автор

Thanks for these clear explanations. I'm actually a programmer several years now (mobile game industry), but where I have been working, we haven't had any strict rules so everybody just implemented things as they saw fit. Now that I'm thinking of moving to another company, I realize I lack some fundamental programming skills and your lessons are quite helpful. Clearer than other tutorials I've seen. Thanks!

elyakimlev
Автор

It reminds me of the old Linked List in C++ where you had a serf referencing pointer [Node] that points to the Next->Node.

rvscootin
Автор

Thanks, for the effort creating those well explained videos and for the well choosen examples

waeljawadi
Автор

Great tutorial! But I think there is a little mistake in the main method in 6:40. Since the 'setNextHandler' method returns the handler that we passed in, so when creating an instance of the AuthService, we pass the last handler from the entire Chain (in this case RoleCheckHandler) to its constructor, so the entire authentication flow doesn't work properly, because it executes only RoleCheckHandler. I guess we should assign UserExistsHandler to the variable 'handler'. Then using this variable, we should set the next handlers using the 'setNextHandler' method, and pass the 'handler' variable to the AuthService constructor. Am I correct?

mikooovsky
Автор

How do you insert, remove or reorder handlers dynamically? Each handler only has a reference to the next one

bob_mikhail
Автор

Thank you for the this amazing videos ! you are the best Sir !

alilat.tech.dz.advisor
Автор

I realize that this is outside the scope of the video; however, it's poor security protocol to tell a (possibly malicious) user weather or not the username exists. This gives the adversary extra information to use in the attack. If you send, "wrong password" the adversary now knows that the username exists and they should try more passwords. If you just send, "Invalid login information, " the adversary doesn't know if the username is wrong or the password is wrong. This is particularly an issue when people reuse passwords and/or usernames (or variants thereof).

cparks
Автор

Why chain of responsibility is a behaviour design pattern? Plz ans me.

__ShamimaAkterShimu
Автор

i am sorry but i try to implement your code, i understood everything but this setNextHandler is not right becouse you will always set the last handler in witch case you will have only one handler

prolamaamvs