State Design Pattern

  Рет қаралды 242,484

Derek Banas

Derek Banas

Күн бұрын

Пікірлер: 289
@derekbanas
@derekbanas 12 жыл бұрын
I wish this was my job :) No, I just do this for about 2 hours a day. I'm not very popular on KZbin. I'm glad you enjoy the videos. Thanks for the kind words. Many more are coming
@mikeagten9690
@mikeagten9690 5 жыл бұрын
Now you are popular! and you earned it! good luck man
@Codetutor-DemystifyCoding
@Codetutor-DemystifyCoding 8 жыл бұрын
Thanks Derek... This is how coding concepts need to be taught... I was going through a code base where state machine pattern has been been. I needed a quick overview... this was more than that... Subscribed....
@derekbanas
@derekbanas 8 жыл бұрын
You're very welcome :) Thank you
@Levessonk
@Levessonk 4 жыл бұрын
I'm killing my software development principles class because of your videos. You got the gift of teaching CS. Thank you.
@derekbanas
@derekbanas 4 жыл бұрын
Thank you for the compliment :)
@Battery64121
@Battery64121 7 жыл бұрын
This design pattern seriously changed my life. I use it everwhere now.
@derekbanas
@derekbanas 7 жыл бұрын
That's funny :) I'm glad it is helping
@ilovemydog7100
@ilovemydog7100 9 жыл бұрын
I am taking a design patterns class in college. When I study, I just watch all of your videos. Very helpful. The examples are super simple and help me understand the more complicated examples in the book.
@derekbanas
@derekbanas 9 жыл бұрын
Minda Minda Thank you :) The goal was to make it easier to understand the complex patterns covered by the GOF. I'm glad i could help.
@christopherbui7315
@christopherbui7315 5 жыл бұрын
Hi, I'm new to coding and just began writing a personal project. Asked for some help from fourms and they directed me toward state designs. Thanks for your video. Appreciate the thorough explanation. Subscribed!
@derekbanas
@derekbanas 12 жыл бұрын
Eclipse is the IDE. I use camtasia 2 for screen captures. I edit everything with iMovie. Everything I use is either free or pretty cheap. I made all the videos on a $200 Mac mini up until about a year ago. I'm glad you like them :)
@matt-g-recovers
@matt-g-recovers 5 жыл бұрын
Oh my god this is perfect. Thank you so much once again for being my intermediate developer teacher!!!;) but seriously, I am breaking new ground here and appreciate it. what I'm building has to persist State and give me different states to demo functionality of something that doesn't exist yet. I love how I bounce around your tutorials I always get what I need.
@derekbanas
@derekbanas 5 жыл бұрын
I'm very happy that you are finding value in so many videos :)
@80amnesia
@80amnesia 4 жыл бұрын
still one on the best channel for coding 👍
@derekbanas
@derekbanas 4 жыл бұрын
Thank you for the nice compliment :) I'm happy I could help
@MK-zf6or
@MK-zf6or 3 жыл бұрын
I'm very happy that Derek posts videos on topics that very few videos or websites talk about. Its really helpful and as always extremely well explained. Thanks so much..
@derekbanas
@derekbanas 3 жыл бұрын
Thank you very much! I have found that my niche is to cover numerous topics most people don’t. You may be surprised to know my most popular video for the last few years is my Arduino programming video.
@MK-zf6or
@MK-zf6or 3 жыл бұрын
@@derekbanas I'm going in to my second year of software engineering so the UML helped a lot, and then I'm using the design pattern series of yours to do my assignment right now, and it's going great after your explanation, now I'm studying your code and copying it structure and logic wise. As you said - working with multiple classes is hard when your first introduced to complex programming -- I'd 100% agree on that, especially when you spend your first year mainly just having everything done within 3-5 files maximum and only with basic inheritance. Thanks so much again, Have a great day, and it really means a lot for all the great videos you create for those who need help.
@derekbanas
@derekbanas 12 жыл бұрын
You're very welcome :) I can't believe you have watched so many videos. That is impressive
@matt-g-recovers
@matt-g-recovers 5 жыл бұрын
man I must have really cultivated a bad habit because I couldn't understand this very well until I saw the code portion and then I went back and looked at the uml portion of this video... I have no trouble reading uml documents most of the timethank you so much for those videos by the way because I just poured through a bunch of design documents... but dang I have a hard time creating my own for some reason... sweet, we found a place to grow LOL 😂 cheers man thanks again 👍
@derekbanas
@derekbanas 5 жыл бұрын
It is very nice to know that I have helped :) Keep at it and you'll get it.
@adityasinghrathore3935
@adityasinghrathore3935 5 жыл бұрын
Earned a subscriber. Finally no stupid guy jumping around or giving useless examples. The first slide just showed that you mean business. Thank You :)
@derekbanas
@derekbanas 5 жыл бұрын
Thank you :) I try to do my best
@derekbanas
@derekbanas 12 жыл бұрын
Thank you :) What I'm basically doing with this tutorial is grabbing information from personal experience, my notes and about 7 sources. The definitive book on the core patterns is Design Patterns: Elements of Reusable Object-Oriented Software (The GOF Book). The C++ code related to the patterns can be found in that book. After the core 23 I'll cover UML, OOP Principles of design and refactoring. By the end you should get it completely
@derekbanas
@derekbanas 12 жыл бұрын
Siempre serás un ganador. Usted es siempre bienvenido
@derekbanas
@derekbanas 12 жыл бұрын
Always use what makes the code easier to understand. Many of the patterns do similar things in different ways
@derekbanas
@derekbanas 11 жыл бұрын
I wish you the best of luck on your exam :)
@AlexTimification
@AlexTimification 11 жыл бұрын
My god, I find ur tutorial just over explanatory. I study computer science and it's so helpful for my software development classes^^
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) I do my best to cover everything in the least amount of time possible. I like to make original videos if I can.
@stevoinco
@stevoinco 10 жыл бұрын
Hey man, this is really helpful. I'm already trying to figure out where I can implement this design model in my job. I wish I had known about this at the beginning of my career. Thanks again!
@derekbanas
@derekbanas 10 жыл бұрын
Steve Cox Thank you :) I'm happy I could help. I learned most of this stuff on the job. I don't know why colleges don't teach about patterns, object oriented design, refactoring, etc.
@Inzolity
@Inzolity 9 жыл бұрын
Derek Banas Our college is currently teaching design patterns! This video was super helpful by the way, thanks!
@DegenereitionXHHHHBK
@DegenereitionXHHHHBK 7 жыл бұрын
Thank you for the video, it has more than 5 years on the web but is still being useful for others :D
@derekbanas
@derekbanas 7 жыл бұрын
I'm happy to be of help :)
@anaibrahim4361
@anaibrahim4361 4 жыл бұрын
love the way you explains stuff now i understood the power of state design pattern thanks
@Leonustice22
@Leonustice22 7 жыл бұрын
Dude, you saved my life in coding
@derekbanas
@derekbanas 7 жыл бұрын
That's great :) I'm happy to be of help
@derekbanas
@derekbanas 12 жыл бұрын
Thank you :) It was added on as a boolean that would be needed if the program was expanded upon. I could for example check it later during the withdrawal process to verify that the user should have access. In the program as it is, it isn't needed though. I'm sorry if that caused any problems. I write these programs out of my head
@derekbanas
@derekbanas 12 жыл бұрын
Take a look at my tutorial on the Observer Design pattern. Think of publishers as observables and subscribers as observers. I'll get more into the different forms the main 23 patterns can transform into in the next series of tutorials. Don't worry, I'm just getting started with software engineering tutorials
@ItsHimItsThatGuy
@ItsHimItsThatGuy 3 жыл бұрын
I’ve been watching all of these design patterns tutorials and I just found myself saying with you “WUHULO INTERNET”
@derekbanas
@derekbanas 11 жыл бұрын
As long as you have the capability to set different states you are in essence still using the state pattern. Design patterns are more like guides rather then recipes you must follow exactly.
@derekbanas
@derekbanas 11 жыл бұрын
Are you asking why the states have a reference to ATMMachine? Sorry I don't understand the question
@rajeshwarkothuri373
@rajeshwarkothuri373 10 ай бұрын
Thank you for awesome explanation and implementation of state pattern.I wish I saw this video before one of my recent interviews.Atleast I know it now😊
@saicharan4669
@saicharan4669 2 жыл бұрын
Sir you nailed it... Absolutely amazing and suitable for any level of learner👌👌👌👌👌
@viditadaga3445
@viditadaga3445 5 жыл бұрын
Your videos are very helpful and make these patterns a lot simpler to understand. Thank you !
@derekbanas
@derekbanas 11 жыл бұрын
Why not use pure virtual functions to implement the interface?
@brucesabu
@brucesabu 5 жыл бұрын
Thank. Your video is short and still enough to get how state pattern works I just subscribed
@derekbanas
@derekbanas 5 жыл бұрын
Thank you :)
@ivandrofly
@ivandrofly 4 жыл бұрын
the best explanation for state pattern i seen
@derekbanas
@derekbanas 4 жыл бұрын
Thank you I'm happy I could help :)
@derekbanas
@derekbanas 11 жыл бұрын
Yes the state pattern can grow out of control. Probably worse though are the changes that are required when a new event is needed. It normally is better to use an enumerate type for each event. It is also quite useful to store states and events in a two dimensional array. That keeps them all in one place. Of course simple conditional logic could be used as well to represent the states
@ganeshmankarwtxitu8228
@ganeshmankarwtxitu8228 4 жыл бұрын
The best collection for C++ developers!
@derekbanas
@derekbanas 4 жыл бұрын
Thank you :) I'm happy you enjoyed them
@mcgrathc123
@mcgrathc123 7 жыл бұрын
Worked first time! That's a rarity in the programming world : ) Great Videos, keep em coming!
@derekbanas
@derekbanas 7 жыл бұрын
Thank you :) Many more are coming
@derekbanas
@derekbanas 12 жыл бұрын
Algebra, trig, geometry and a tiny bit of calculus. If you look at my Java tutorial, at the end I make an asteroids game. Most of the math for collision detection, velocity changes, etc is based on trig. I'll review them in some quick tutorials. I at first thought the Kahn academy had math covered, but based on the requests I've been getting I guess not?
@lindawisebear
@lindawisebear 4 жыл бұрын
This is the best Strate Pattern tutorial there is on youtube! Thank you for making this. It is so helpful that you provide your code, too :)
@someguyO2W
@someguyO2W 7 жыл бұрын
This is pretty good. I just observed the code and user experience could be improved by preventing transitions when the state is not valid. E.g. do not allow a user to enter a card when the atm is in a NoCash state. As a tutorial, this is excellent! I really loved the lighthearted sections.
@derekbanas
@derekbanas 7 жыл бұрын
Thank you very much :) Yes there is always room for improvement
@derekbanas
@derekbanas 12 жыл бұрын
I'm working on that tutorial right now. First I want to make a great platformer game since most popular indie games are 2D platformers. After I make a really great 2D game I'll then get into 3D
@derekbanas
@derekbanas 11 жыл бұрын
You're very welcome :) Im very happy that I could help.
@derekbanas
@derekbanas 11 жыл бұрын
Sorry about that. I approach this stuff like a contact sport. I'd love it if people would print everything out and then watch the video while pausing and taking notes. That way there is always something to do. I also hoped that that would teach in numerous different ways at once so that I could increase the odds that everything would sink in. I experiment a great deal when I make these videos in the hope of improving :)
@derekbanas
@derekbanas 12 жыл бұрын
Minecraft is based on LWJGL which helps you use OpenGL in Java. The only issue is that you must understand OpenGL to use it. To learn OpenGL it is easier to learn first the 2D aspects of it. There is a lot of math involved in programming even a 2D game. The math in a 3D game is much more complicated. I'm going to start with Java 2D & 3D. Then I'll move into OpenGL with some math tutorials. Then LWJGL will be covered. Don't try to rush the process, or you'll get mad
@BjrnBrathen
@BjrnBrathen 12 жыл бұрын
Even neater! ;) I'm taking a Software Architecture Course and these videos are really helping me with implementations of patterns from those abstract definitions in my book. I particularly like the speech flow and the good looking design of your videos. I will definitely share your channel to my Software Architecture Class next lecture. Keep up the good work! Tomorrow I will try your veggie Burger ;)
@NilsMoller
@NilsMoller 5 жыл бұрын
this is the best video i've ever seen
@derekbanas
@derekbanas 5 жыл бұрын
Thank you for the compliment :)
@TheANKURQQ
@TheANKURQQ 10 жыл бұрын
Hi Derek, Thanks for these videos. I have learnt a lot from these design pattern videos. These are right up to the point and very easy to understand. Thanks!!
@kickingpinay
@kickingpinay 12 жыл бұрын
Great tutorial! Looks like this pattern prevents a lot of conditional statement. Feels like its similar to the strategy pattern but more understandable.
@delprofundo
@delprofundo 10 жыл бұрын
Very helpful coverage, filled some gaps and now I can implement. Cheers.
@derekbanas
@derekbanas 10 жыл бұрын
Bruno Watt Thank you for the nice compliment :) I'm glad I could help
@derekbanas
@derekbanas 12 жыл бұрын
Thank you very much for sharing :) I really appreciate that! I prefer the TVP veggie burger, but my wife likes the black bean recipe.
@TheDivergable
@TheDivergable 12 жыл бұрын
That's great! I'm currently learning java and I'm planning to try make a game close to the most basics of Minecraft because I think when you know how to make a 3d game and try to make an already made game you will get the hang of it very easily and fast.
@CausticCatastrophe
@CausticCatastrophe 9 жыл бұрын
This is wonderfully explained! Thanks for the help!
@derekbanas
@derekbanas 9 жыл бұрын
+Net Thank you :) You're very welcome
@SimmeringPotpourri
@SimmeringPotpourri 8 жыл бұрын
I watched another State tutorial and they used an Abstract class with Abstract methods instead of an interface. After doing some reading, the Head First Design Patters book used a Interface as well but when looking at Abstract vs Interface, it seemed more appropriate to use an Abstract class. Can you explain why you choose to use an Interface?
@derekbanas
@derekbanas 8 жыл бұрын
+SimmeringPotpourri I have a rule that if I don't need an abstract class I always use an interface.
@MrWatsonrandy
@MrWatsonrandy 12 жыл бұрын
Is making KZbin videos your job? How did you learn java and JavaScript? I'm learning quite a lot from all of your java videos and I am enjoying the learning. Keep em coming!
@xiuyanxin4339
@xiuyanxin4339 7 жыл бұрын
Thank you so much for making these videos! They help me a looooot!!
@derekbanas
@derekbanas 7 жыл бұрын
I'm very happy to help :)
@goran181
@goran181 11 жыл бұрын
Great and easy to follow tutorial. Thank you!
@gobieee1
@gobieee1 3 жыл бұрын
good explanation indeed. have one question, what if the system has 15 states? still we end up creating 15 classes and each class has 15 state methods? Also, if any new state gets added, then all the 15 classes get impacted?
@M2dScientist
@M2dScientist 10 жыл бұрын
Great Videos Derek! Thank you for all your hard work!
@envvar
@envvar 11 жыл бұрын
Thanks Derek, makes learning curve smoother!
@BikashShrestha
@BikashShrestha 8 жыл бұрын
I think, Putting all the state object value inside ATMMachine is not good idea here because whenever we need to add the new state we have to modify ATMMachine class i.e add new state in ATMMachine class
@ankitrathore007
@ankitrathore007 7 жыл бұрын
yes.. i agree..
@isidme
@isidme 6 жыл бұрын
I find it a good idea because here ATMMachine class works as a Facade!
@mesarvagya777
@mesarvagya777 6 жыл бұрын
Create a factory in that case.
@randomite
@randomite 6 жыл бұрын
What is the alternative?
@noahfowler1
@noahfowler1 6 жыл бұрын
1. struct ATMStates { ... } 2. ATMStates m_States; 3. Profit???
@ThiagoPereiraDeveloper
@ThiagoPereiraDeveloper 11 жыл бұрын
Awesome tutorial. Thank you for that! I would only add lazy instantiation for the states to get even better.
@filgab_1984
@filgab_1984 3 жыл бұрын
Correct me if I'm wrong but doesn't the State design pattern not fully respect the Liskov Substitutability Principle? Since I realize that from a given state in which the system is in, not all transitions are really possible (ex.: adding another card while there already exists a card). Is this expected behaviour out of the State design pattern?
@loungeblogger
@loungeblogger 11 жыл бұрын
is there a way to implement all the possible states outside of the context? so that you don't have to alter the context-class when there are state-changes?
@BumblesTheUnicorn
@BumblesTheUnicorn 11 жыл бұрын
Thanks for the videos. Definitely less dry than trying to read the GOF book. It seems like a weakness of this design pattern is that it tries to implement state transitions in a non-sparse way. So like in your NoCard state most of the methods were just stubs since there was only one valid transition. You could imagine for an even bigger state machine where many states didn't have transitions between them you'd end up with a lot of dead code. In that case what would you recommend?
@MrDivad006
@MrDivad006 8 жыл бұрын
5:53 how do you refactor the code like that?
@DerekBaker90
@DerekBaker90 8 жыл бұрын
I think he sometimes uses some custom shortcuts, and sometimes is just a video cut. But I would like to know too!
@haridaniel777
@haridaniel777 8 жыл бұрын
Video cut. But you can do similar by entering block selection with SHFT+ALT+A.
@tarek3735
@tarek3735 7 жыл бұрын
might have used select and replace
@dariusgrant5672
@dariusgrant5672 8 жыл бұрын
Can you get the same effect by using an enumerator for the state?
@derekbanas
@derekbanas 8 жыл бұрын
Yes very similar
@robertodilillo
@robertodilillo 9 жыл бұрын
Hi Derek. First of all my best compliments for this awesome playlist. I have a two questions for you: 1) how do you do the cut text tricks @ 5:55 ? 2)@6:04 you select a part of text @ row 15, and then this is assigned to below variable, but it s not the usual copy paste! Can you tell me the shortcut for this one too?
@derekbanas
@derekbanas 9 жыл бұрын
+roberto di lillo Thank you :) Sorry for the confusion. I edited out part of the video there.
@raggu1986
@raggu1986 11 жыл бұрын
awesome teaching..i clearly understood..worth to bookmark for future refernce
@loungeblogger
@loungeblogger 11 жыл бұрын
I see. I guess there isn't then ;-) thanks for all the great tutorials! they are really helpful as I'm having an exam on these patterns next week xD praise the internet, praise youtube, how did we study before they were invented??
@derekbanas
@derekbanas 12 жыл бұрын
First I don't judge anyone based on their political beliefs and I normally vote simply to remove incumbents irregardless of party. I think if that channel wanted to point out real issues that may win people over to their side I'd bring up the following issues: Indefinite Detention, the ACTA treaty was signed under an executive agreement, the Trans-Pacific Partnership which is being created secretly, the $40 Billion a month the Fed is printing for MBSs, etc. I don't care about politics though :)
@sahilrally4491
@sahilrally4491 9 жыл бұрын
I feel , State change should be Context Responsibility and not the particular state. In fact all the concrete states should not know even that other state exists. All concrete states should return a Result Object and based on that Context should decide whether to move to change state or not and iff to change then which one.
@GolanIsraeli
@GolanIsraeli 6 жыл бұрын
according to the state design pattern,(by the gof.p:307) : "Either Context or the ConcreteState subclass can decided which state succeeds another and under what circumstances". So we can say Context know about Concrete states and Concrete state should know about other concrete state in order to change the current state in the context .
@damilareoyebanji2834
@damilareoyebanji2834 5 жыл бұрын
I think that is the Difference Between Strategy Design Pattern and State Design Pattern.
@dovidsamuels5709
@dovidsamuels5709 4 жыл бұрын
Is it generally a good idea to have every instance of Context instantiate an instance of every state, or would it be better to have each state be a Singleton, with perhaps a state factory for initialization?
@ivanriotogonon6382
@ivanriotogonon6382 8 жыл бұрын
Hi Derek, thank you so much for this tutorial. I am currently learning game development on android and I believe this will come in handy when coding my different game components especially on the player. I will have to watch this a few more times though, since my brain is still hardwired to tons of "ifs" coding style. =)
@derekbanas
@derekbanas 8 жыл бұрын
+Ivan Rio Togonon You're very welcome :) Have fun making games!
@pawanshrivastav55
@pawanshrivastav55 11 жыл бұрын
Hi Derek, I have a question, Can you please explain why you have used ATMState instead of ATMMachine to created these below methods : public ATMState getYesCardState() { return hasCard; } public ATMState getNoCardState() { return noCard; } public ATMState getHasPin() { return hasCorrectPin; } public ATMState getNoCashState() { return atmOutOfMoney; } As in the other codes you are calling these methods using ATMMachine object. Thanks
@derekbanas
@derekbanas 12 жыл бұрын
It is hard to tell sometimes
@RS-so7ke
@RS-so7ke 7 жыл бұрын
Do we have to create object of each state in the ATM machine , can't we just use the reference
@bzsgzs
@bzsgzs 10 жыл бұрын
Hey Derek, at 5:52 ~ 5:58 you were able to delete the variable's type and the semicolons on multiple lines. How did you do that? :c
@haridaniel777
@haridaniel777 8 жыл бұрын
That seems video cut. But you can do similar by entering block selection by SHFT+ALT+A.
@BjrnBrathen
@BjrnBrathen 12 жыл бұрын
Off topic: which program do you use for making of these tutorials? Looks really neat!
@AlexTimification
@AlexTimification 11 жыл бұрын
I have one question: Let's say some functions for some states shouldn't be accessible. I guess, I declare ATMState as an abstract class, and declare must-have methods as abstract, other just protected. If it's correct, would it be still a State Design Pattern?
@Didi-bz6kt
@Didi-bz6kt 4 жыл бұрын
Hey, great explanation - thank you ! Small question - i see you have same methods names within the state concrete classes and the Context class - why won't you implement the state inteface on the atm ?
@PIZZAAAAAAAAAAAAAful
@PIZZAAAAAAAAAAAAAful 4 жыл бұрын
I have the same question
@mahdibouhouch4486
@mahdibouhouch4486 3 жыл бұрын
I think that's how the pattern works, we need that abstraction in the interface so the Context calls the method it gets executed depending on the state of the ATM Machine
@derekbanas
@derekbanas 12 жыл бұрын
You're very welcome :) Thank you
@derekbanas
@derekbanas 11 жыл бұрын
That is very good :) I'm happy if I was able to help
@kylepearce4900
@kylepearce4900 7 жыл бұрын
any one know how i would fix the errors im getting with my constructors in the "context" constructor, as i made the "State" objects pointers(E.g. ATMstate * hasCard) instead of actual objects, for C++.
@Bendrnicholson
@Bendrnicholson 9 жыл бұрын
Hi Derek, Thanks for all your videos... really helping me understand these design patterns for my exam this coming week! Just one question about Java, not the actual design patterns. In my course, we are using C++, so we have references and pointers available. I thought Java is unable to pass by reference, but only passes the value. When you update the atmMachine object in the state classes, it modifies the original one. How is this happening?
@derekbanas
@derekbanas 9 жыл бұрын
Ben Nicholson Your welcome :) Yes everything is pass by value in Java. What line of code is confusing. I'll explain how it works.
@Bendrnicholson
@Bendrnicholson 9 жыл бұрын
Derek Banas For example, the HasCard object gets given an ATMMachine object when it is constructed. If this is just passed by value, then how does changing the state of the ATMMachine that is within the HasCard class actually change the state of the ATMMachine object that owns the HasCard instance? If you pass by value, wouldn't changing the state only change the HasCard's member variable, not the state of the ATMMachine that was provided as a parameter? Not sure if this question makes sense, or if I'm just totally misunderstanding it. I guess I'm too used to pointers!
@mogomotsiseiphemo1681
@mogomotsiseiphemo1681 9 жыл бұрын
Ben Nicholson The HasCard object gets given a pointer to an ATMMachine. It is this pointer that is passed by value. Check this out--> javadude.com/articles/passbyvalue.htm
@derekbanas
@derekbanas 11 жыл бұрын
You're very welcome :)
@jouiniYosr
@jouiniYosr 10 жыл бұрын
Thank you for the explanation :D I have a question: why you declared the different states in the ATMmachine class ? can't we just declare the atmState and then set its value according to the changes?
@derekbanas
@derekbanas 10 жыл бұрын
jouini Yosr You're very welcome :) Yes you could most definitely do that.
@diamondglitter205
@diamondglitter205 6 жыл бұрын
it's faster to assign already defined states, than create new one each time we want to change the state and the older one gets garbage collected. constant creation and deletion will hit on the performance.
@sshawarma
@sshawarma 4 жыл бұрын
@@diamondglitter205 I really don't think assigning existing instances of states is that much faster. Plus, passing a new state helps keep code decoupled and makes unit testing easier.
@jamesrao6783
@jamesrao6783 9 жыл бұрын
Is it a good idea that A is composed of B and B is composed of A at the same time ?
@franciscocorralesmorales7608
@franciscocorralesmorales7608 9 жыл бұрын
why not ?, I don't find that a problem.
@OumSaokosal
@OumSaokosal 12 жыл бұрын
This is an awesome lesson. One question: do we need the state pattern for Database programming? I mean most of the time we use a table to store a "state". Thanks in advance.
@skfiroz5005
@skfiroz5005 4 жыл бұрын
Ohhhh Thanks bro Finally I got this video
@agnichatian
@agnichatian 11 жыл бұрын
How would this be done in C+ where there is no Java-specific 'interface' mechanism ?
@derekbanas
@derekbanas 12 жыл бұрын
I'm pretty disgusted by the actions of the US government in general. That is why I don't vote for either of the 2 parties. I haven't however found that I can do anything to persuade people to look into all of the atrocities that are occurring world wide. I've dabbled with the idea of covering the Iran Contra Affair in detail. Everything was laid bare and I think it may frighten people into asking more questions? I can only say that most people in the US have no idea what its government does
@tryingtocorrect
@tryingtocorrect 9 жыл бұрын
Haha "wrong pin, well then we are going to have to punish them for that" :)
@brianlaudrupchannel
@brianlaudrupchannel 9 жыл бұрын
would this be a good pattern to use for game levels.
@jtcotton63
@jtcotton63 8 жыл бұрын
Quick question ...have you ever heard of the design small called refused bequest? To put it simply, a 'refused bequest' occurs when an object inherits a method (from an interface or from a parent class) and then rejects that method in some way (throwing an exception, voiding it out). Essentially, the refused bequest is an indicator that something is wrong with the current design because objects are implementing methods they don't need or that don't pertain to them. Isn't that exactly what you're doing here? I.e., why would the NoCard state ever have an ejectCard method?
@kim15742
@kim15742 8 жыл бұрын
What if multiple states are active at the same time? Like NoMoney and CardInserted?
@chinjiaxiong6570
@chinjiaxiong6570 5 жыл бұрын
Thanks for sharing! I can see how I can play with this wonderful design pattern XD Time for the pokemon to mega evolve lol
@CLipton1444
@CLipton1444 8 жыл бұрын
Why don't you use one State in the class ATM machine with the Interface(I use an abstract class mostly) so that you can always do: currentState.insertCard(); (or any other method)
@johnlouiscrutchfield5906
@johnlouiscrutchfield5906 9 жыл бұрын
What IDE are you using?
@derekbanas
@derekbanas 9 жыл бұрын
+JohnLouisCrutchfield Eclipse
@michaelgalin7373
@michaelgalin7373 4 жыл бұрын
Is this technically a finite state machine?
@123japanuser
@123japanuser 12 жыл бұрын
Sin medallas para mí pero sincero agradecimiento a usted GOD BLESS
Proxy Design Pattern Tutorial
8:13
Derek Banas
Рет қаралды 167 М.
State Pattern - Design Patterns (ep 17)
1:20:30
Christopher Okhravi
Рет қаралды 155 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Command Design Pattern
23:41
Derek Banas
Рет қаралды 285 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,4 МЛН
This is the Only Right Way to Write React clean-code - SOLID
18:23
Iterator Design Pattern
22:47
Derek Banas
Рет қаралды 174 М.
Do This Instead Of Representing State With Booleans
12:23
Joy of Code
Рет қаралды 116 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 326 М.
Command Pattern - Design Patterns (ep 7)
39:12
Christopher Okhravi
Рет қаралды 276 М.
Strategy Pattern, The Best Software Design Pattern
2:23
Jono Williams
Рет қаралды 81 М.
The Most Important Design Pattern in React
35:04
Cosden Solutions
Рет қаралды 122 М.