State Design Pattern

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

ความคิดเห็น • 289

  • @derekbanas
    @derekbanas  12 ปีที่แล้ว +8

    I wish this was my job :) No, I just do this for about 2 hours a day. I'm not very popular on TH-cam. I'm glad you enjoy the videos. Thanks for the kind words. Many more are coming

    • @mikeagten9690
      @mikeagten9690 4 ปีที่แล้ว +2

      Now you are popular! and you earned it! good luck man

  • @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

  • @Codetutor-DemystifyCoding
    @Codetutor-DemystifyCoding 8 ปีที่แล้ว +28

    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 ปีที่แล้ว +2

      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 :)

  • @derekbanas
    @derekbanas  12 ปีที่แล้ว +1

    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

  • @christopherbui7315
    @christopherbui7315 5 ปีที่แล้ว +1

    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!

  • @matt-g-recovers
    @matt-g-recovers 5 ปีที่แล้ว +1

    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 :)

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    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 :)

  • @80amnesia
    @80amnesia 4 ปีที่แล้ว +1

    still one on the best channel for coding 👍

    • @derekbanas
      @derekbanas  4 ปีที่แล้ว

      Thank you for the nice compliment :) I'm happy I could help

  • @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.

  • @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 ปีที่แล้ว +1

      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 ปีที่แล้ว

    Siempre serás un ganador. Usted es siempre bienvenido

  • @derekbanas
    @derekbanas  12 ปีที่แล้ว +2

    You're very welcome :) I can't believe you have watched so many videos. That is impressive

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    Always use what makes the code easier to understand. Many of the patterns do similar things in different ways

  • @Leonustice22
    @Leonustice22 7 ปีที่แล้ว +1

    Dude, you saved my life in coding

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว

      That's great :) I'm happy to be of help

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว +13

    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 ปีที่แล้ว +2

    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.

  • @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

  • @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

  • @anaibrahim4361
    @anaibrahim4361 3 ปีที่แล้ว

    love the way you explains stuff
    now i understood the power of state design pattern thanks

  • @viditadaga3445
    @viditadaga3445 5 ปีที่แล้ว

    Your videos are very helpful and make these patterns a lot simpler to understand. Thank you !

  • @DegenereitionXHHHHBK
    @DegenereitionXHHHHBK 6 ปีที่แล้ว

    Thank you for the video, it has more than 5 years on the web but is still being useful for others :D

    • @derekbanas
      @derekbanas  6 ปีที่แล้ว

      I'm happy to be of help :)

  • @ganeshmankarwtxitu8228
    @ganeshmankarwtxitu8228 3 ปีที่แล้ว

    The best collection for C++ developers!

    • @derekbanas
      @derekbanas  3 ปีที่แล้ว

      Thank you :) I'm happy you enjoyed them

  • @stevoinco
    @stevoinco 10 ปีที่แล้ว +6

    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 ปีที่แล้ว +4

      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!

  • @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 ปีที่แล้ว

    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

  • @ivandrofly
    @ivandrofly 3 ปีที่แล้ว

    the best explanation for state pattern i seen

    • @derekbanas
      @derekbanas  3 ปีที่แล้ว

      Thank you I'm happy I could help :)

  • @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?

  • @ItsHimItsThatGuy
    @ItsHimItsThatGuy 2 ปีที่แล้ว

    I’ve been watching all of these design patterns tutorials and I just found myself saying with you “WUHULO INTERNET”

  • @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  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

  • @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.

  • @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

  • @brucesabu
    @brucesabu 5 ปีที่แล้ว

    Thank. Your video is short and still enough to get how state pattern works
    I just subscribed

  • @kickingpinay
    @kickingpinay 11 ปีที่แล้ว

    Great tutorial! Looks like this pattern prevents a lot of conditional statement. Feels like its similar to the strategy pattern but more understandable.

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    Are you asking why the states have a reference to ATMMachine? Sorry I don't understand the question

  • @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.

  • @rajeshwarkothuri373
    @rajeshwarkothuri373 9 หลายเดือนก่อน

    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😊

  • @NilsMoller
    @NilsMoller 5 ปีที่แล้ว

    this is the best video i've ever seen

    • @derekbanas
      @derekbanas  5 ปีที่แล้ว

      Thank you for the compliment :)

  • @BjrnBrathen
    @BjrnBrathen 11 ปีที่แล้ว

    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 ;)

  • @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

  • @123japanuser
    @123japanuser 12 ปีที่แล้ว

    Sin medallas para mí
    pero sincero agradecimiento a usted
    GOD BLESS

  • @CausticCatastrophe
    @CausticCatastrophe 9 ปีที่แล้ว +2

    This is wonderfully explained! Thanks for the help!

    • @derekbanas
      @derekbanas  9 ปีที่แล้ว

      +Net Thank you :) You're very welcome

  • @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  11 ปีที่แล้ว

    You're very welcome :) Im very happy that I could help.

  • @envvar
    @envvar 11 ปีที่แล้ว

    Thanks Derek, makes learning curve smoother!

  • @lindawisebear
    @lindawisebear 4 ปีที่แล้ว +1

    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 :)

  • @goran181
    @goran181 11 ปีที่แล้ว +1

    Great and easy to follow tutorial. Thank you!

  • @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!!

  • @saicharan4669
    @saicharan4669 2 ปีที่แล้ว

    Sir you nailed it... Absolutely amazing and suitable for any level of learner👌👌👌👌👌

  • @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

  • @ThiagoPereiraDeveloper
    @ThiagoPereiraDeveloper 10 ปีที่แล้ว

    Awesome tutorial. Thank you for that! I would only add lazy instantiation for the states to get even better.

  • @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?

  • @sahilrally4491
    @sahilrally4491 8 ปีที่แล้ว +7

    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 ปีที่แล้ว +1

      I think that is the Difference Between Strategy Design Pattern and State Design Pattern.

  • @MrWatsonrandy
    @MrWatsonrandy 12 ปีที่แล้ว

    Is making TH-cam 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!

  • @raggu1986
    @raggu1986 11 ปีที่แล้ว

    awesome teaching..i clearly understood..worth to bookmark for future refernce

  • @M2dScientist
    @M2dScientist 10 ปีที่แล้ว +1

    Great Videos Derek!
    Thank you for all your hard work!

  • @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?

  • @xiuyanxin4339
    @xiuyanxin4339 7 ปีที่แล้ว

    Thank you so much for making these videos! They help me a looooot!!

    • @derekbanas
      @derekbanas  7 ปีที่แล้ว +1

      I'm very happy to help :)

  • @skfiroz5005
    @skfiroz5005 4 ปีที่แล้ว

    Ohhhh Thanks bro Finally I got this video

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    Thank you very much for sharing :) I really appreciate that! I prefer the TVP veggie burger, but my wife likes the black bean recipe.

  • @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 :)

  • @tied515
    @tied515 3 ปีที่แล้ว

    Very clear and useful thanks

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    Why not use pure virtual functions to implement the interface?

  • @jouiniYosr
    @jouiniYosr 10 ปีที่แล้ว +2

    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 5 ปีที่แล้ว +1

      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 3 ปีที่แล้ว +1

      @@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.

  • @SimmeringPotpourri
    @SimmeringPotpourri 8 ปีที่แล้ว +1

    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.

  • @csalgo7345
    @csalgo7345 3 ปีที่แล้ว

    Great explanation!

  • @BjrnBrathen
    @BjrnBrathen 11 ปีที่แล้ว

    Off topic: which program do you use for making of these tutorials? Looks really neat!

  • @manishbelsare
    @manishbelsare 10 ปีที่แล้ว +1

    After correct pin in entered & then if card is ejected then the correctPinEntered should be set to false. Just in case that might be left true. :)

  • @archidsouza
    @archidsouza 7 ปีที่แล้ว

    Thanks, Derek. It could not have been more easier.... I have one question, though... what is the difference between centralize and decentralize design pattern? Can you give any example ?

  • @Didi-bz6kt
    @Didi-bz6kt 4 ปีที่แล้ว +3

    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 ปีที่แล้ว +2

      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

  • @Bendrnicholson
    @Bendrnicholson 9 ปีที่แล้ว +1

    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

  • @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?

  • @tryingtocorrect
    @tryingtocorrect 9 ปีที่แล้ว +10

    Haha "wrong pin, well then we are going to have to punish them for that" :)

  • @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.

  • @parth_325
    @parth_325 12 ปีที่แล้ว

    Dear derek , Need a word of advice from you , I have moderate experience in c++, I think my concepts are clear. But am very new to design pattern , could you please guide me which study material i should follow for design patterns.
    P.S Big fan of you tutorials . Thanx :)

  • @pkarvorphorm2993
    @pkarvorphorm2993 4 ปีที่แล้ว

    anyone still watching 2020... great explain

    • @derekbanas
      @derekbanas  4 ปีที่แล้ว +1

      Thank you very much :)

  • @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?

  • @BikashShrestha
    @BikashShrestha 8 ปีที่แล้ว +19

    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 6 ปีที่แล้ว

      yes.. i agree..

    • @isidme
      @isidme 6 ปีที่แล้ว +1

      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???

  • @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.

  • @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?

  • @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??

  • @OumSaokosal
    @OumSaokosal 12 ปีที่แล้ว

    correction: an attribute of a table to store a state.

  • @padrexloco
    @padrexloco 7 ปีที่แล้ว

    Thanks Derek! Your tutorials are very important to us...
    I have a question: How would I proceed to extend a new requirement? Le's say, "retain the card"

    • @padrexloco
      @padrexloco 7 ปีที่แล้ว

      ...if the user has withdrawn $xxx for example.

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    That is very good :) I'm happy if I was able to help

  • @lucasterable
    @lucasterable 9 ปีที่แล้ว

    So, Akka Actors' become/unbecome feature is an implementation of the State Design Pattern

  • @wegzawy
    @wegzawy 2 ปีที่แล้ว

    This is very helpful thank you

  • @CLipton1444
    @CLipton1444 7 ปีที่แล้ว +1

    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)

  • @trvajjala
    @trvajjala 9 ปีที่แล้ว

    well explained , what tool /software used to create videos?.

    • @derekbanas
      @derekbanas  9 ปีที่แล้ว

      +THIRUPATHIREDDY VAJJALA Thank you :) Camtasia 2 and iMovie

  • @anshulrouthu
    @anshulrouthu 10 ปีที่แล้ว

    Hi
    I have a question, you have explained the flow to be from
    user action ------ (triggers) ------> current state's action on the machine and state of machine changes to new state
    is it possible to do this opposite direction in a state pattern i.e.
    set the new state of machine -------- (triggers) ---------> some action implemented by machine for that state
    Anshul

  • @awili23
    @awili23 9 ปีที่แล้ว

    great video, very understandable

    • @derekbanas
      @derekbanas  9 ปีที่แล้ว

      awili23 Thank you :)

  • @chinjiaxiong6570
    @chinjiaxiong6570 5 ปีที่แล้ว +1

    Thanks for sharing! I can see how I can play with this wonderful design pattern XD
    Time for the pokemon to mega evolve lol

  • @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 :)

  • @ivanriotogonon6382
    @ivanriotogonon6382 8 ปีที่แล้ว +1

    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!

  • @sherihananver522
    @sherihananver522 11 ปีที่แล้ว

    that's a wonderful explanation. Thanks Derek :)

  • @richystocles
    @richystocles 9 ปีที่แล้ว

    Thank you very much for this tutorial. I like its simplicity, efficiency and fun tone :)
    Being quite new to programming, I would like to know. Is it possible for me to implement this FSM inside my code (by implementing the ATMState interface in my already existing classes...) or Do I have to build the whole structure of my yet-to-be-designed program with every States and then filling all the states with actual code ?
    (pfff my question is already twice as complicated and you whole tutorial ;) )

  • @derekbanas
    @derekbanas  11 ปีที่แล้ว

    You're very welcome :) Thank you

  • @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 ปีที่แล้ว +2

      That seems video cut. But you can do similar by entering block selection by SHFT+ALT+A.

  • @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?