2. Strategy Design Pattern explanation (Hindi) | LLD System Design | Design pattern in Java

preview_player
Показать описание
Hi, in this video we have covered #strategy #designPattern out of many design pattern which is asked in Low level system design interview.

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

Thank you for this tutorial. Just to add, The fundamental of every design pattern is to separate out what changes over period of time from what remains constant. As you see in Strategy pattern, we are trying to separate out dependency of drive from the main class as much as possible by making various strategies to inject it dynamically based on client requirement so that in future if new requirement for drive comes, there will be minimal/no changes in existing code(Open closed Principle).

tastaslim
Автор

In laymen terms, In Startegy Design pattern we create an interface and it's different implementation based on strategy !! And inject appropriate startegy in client class by creating constructor or any injection of your choice

сойка-ий
Автор

If you are looking for C++ code :

using namespace std;
#include <iostream>
#include<string>
using namespace std;


class drivestratergy{
public:
virtual void drive()=0;

};

class normalDrive : public drivestratergy{

public:
void drive(){
cout<<"Normal drive"<<endl;
}
} ;

class SpecialDrive : public drivestratergy{

public:
void drive(){
cout<<"fast drive"<<endl;
}
} ;



class vehicle{

private:
drivestratergy *ds;
public:
vehicle(drivestratergy *ds){
this->ds=ds;
}

void drive(){
ds->drive();
}

};

class sports : public vehicle{

public:
sports():vehicle( new SpecialDrive () ) {

}
};

class offroad : public vehicle {

public:
offroad():vehicle(new SpecialDrive() ) {

}

};


class passenger : public vehicle{

public:
passenger():vehicle(new normalDrive ()) {

}

};

int main(void) {


offroad off;
off.drive();

passenger pass;
pass.drive();

return 0;
}


NOTE: Pls correct me if something is wrong.

adityarout
Автор

Best Explanation ever... You simplified 1 design pattern in just 15mins..Worth it Content!!

swarajshelavale
Автор

00:00 Design patterns are principles for object-oriented programming that help design manageable, scalable, and reusable software.
02:11 Passenger Vehicle does not have its own drive method, it uses the base class method.
04:22 Child using parent's capability is okay
06:33 Defining the capability of different drive strategies
08:44 Constructor injection allows flexibility in defining capabilities for a child object
10:55 Implemented strategy pattern for drive capability
13:06 The main point is to assign different drive strategies to different types of vehicles.
15:17 Understanding the strategy pattern in low-level design.

kunalwadhwa
Автор

Bhai the best thing I like about your video is breadth you cover and the language hindi. Please keep these 2 things intact

kalpeshsaubhri
Автор

You are correct. My interview got scheduled for 3 hrs(F2F) but got finished in 15mins. I felt very bad at that moment. Many times I tried but was not able to catch concepts of design patterns. I always use to think in C with classes. Your Design pattern tutorial is helping me a lot to understand. Converting your code from java to C++ to and understanding the concepts of design patterns. Started learning now. Thanks for explanations.

connectarunkumar
Автор

I got rejected in an interview because of the lack of knowledge of design pattern. Going to learn from you next time will make a stronger comeback . 💥💥

noobCoder
Автор

this guy deserves a lot of respect please continue it ...a legend

garvitsingh
Автор

litreally, amazing content, from monday there will be my interviews, if i will get selected than i will defenatly return to this video and comment over this one

ugempireninjaaaaaahatori
Автор

That's what we call the way to teach the Patterns. Awesome way to teach with Amazing content. Hats off..

deepanshukumar
Автор

Note for my future reference
5:51 -> at the same level children are using same code, code is not reusable
solution -> make the common part as interface type

namanjain
Автор

I heard about design pattern now came to know just because of you. Thanks

SreeTest-be
Автор

Kya gazab channel hai ye. love his explanation.

siddharthtripathy
Автор

It took me more than an hour to understand this while going through the Head First Book for the same design principle. Should have gone through the video first. Now I am going to use this "strategy", in which I will refer to your video first and then will go through the book

shubhamrajput
Автор

Great Explanation... Thanks for Sharing 🙂

mukulkopulwar
Автор

Thank You for detailed explanation in a simple effective and efficient way,

travelnlearn
Автор

Thank you for making us understand concepts in the best way!

incredibleone
Автор

I wish I had this available during my last semester. Design patterns would have been a breeze. Looking forward for more content :)

anuragparla
Автор

Just day 2 in your playlist and seriously brother hats off!!! Great work....

mannusharma