Abstract Factory Design Pattern

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024

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

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

    Learn in One Videos for Every Programming Language
    Subscribe to Bookmark them: bit.ly/2FWQZTx
    C++ : th-cam.com/video/Rub-JsjMhWY/w-d-xo.html
    Python : th-cam.com/video/N4mEzFDjqtA/w-d-xo.html
    Java : th-cam.com/video/n-xAqcBCws4/w-d-xo.html
    PHP : th-cam.com/video/7TF00hJI78Y/w-d-xo.html
    MySQL : th-cam.com/video/yPu6qV5byu4/w-d-xo.html
    JavaScript : th-cam.com/video/fju9ii8YsGs/w-d-xo.html
    C# : th-cam.com/video/lisiwUZJXqQ/w-d-xo.html
    HTML5 : th-cam.com/video/kDyJN7qQETA/w-d-xo.html
    CSS3 : th-cam.com/video/CUxH_rWSI1k/w-d-xo.html
    JQuery : th-cam.com/video/BWXggB-T1jQ/w-d-xo.html
    TypeScript : th-cam.com/video/-PR_XqW9JJU/w-d-xo.html
    ECMAScript : th-cam.com/video/Jakoi0G8lBg/w-d-xo.html
    Swift : th-cam.com/video/dKaojOZ-az8/w-d-xo.html
    R : th-cam.com/video/s3FozVfd7q4/w-d-xo.html
    Haskell : th-cam.com/video/02_H3LjqMr8/w-d-xo.html
    Handlebars : th-cam.com/video/4HuAnM6b2d8/w-d-xo.html
    Bootstrap : th-cam.com/video/gqOEoUR5RHg/w-d-xo.html
    Rust : th-cam.com/video/U1EFgCNLDB8/w-d-xo.html
    Matlab : th-cam.com/video/NSSTkkKRabI/w-d-xo.html
    Arduino : th-cam.com/video/QO_Jlz1qpDw/w-d-xo.html
    Crystal : th-cam.com/video/DxFP-Wjqtsc/w-d-xo.html
    Emacs : th-cam.com/video/Iagbv974GlQ/w-d-xo.html
    Clojure : th-cam.com/video/ciGyHkDuPAE/w-d-xo.html
    Shell : th-cam.com/video/hwrnmQumtPw/w-d-xo.html
    Perl : th-cam.com/video/WEghIXs8F6c/w-d-xo.html
    Perl6 : th-cam.com/video/l0zPwhgWTgM/w-d-xo.html
    Elixir : th-cam.com/video/pBNOavRoNL0/w-d-xo.html
    D : th-cam.com/video/rwZFTnf9bDU/w-d-xo.html
    Fortran : th-cam.com/video/__2UgFNYgf8/w-d-xo.html
    LaTeX : th-cam.com/video/VhmkLrOjLsw/w-d-xo.html
    F# : th-cam.com/video/c7eNDJN758U/w-d-xo.html
    Kotlin : th-cam.com/video/H_oGi8uuDpA/w-d-xo.html
    Erlang : th-cam.com/video/IEhwc2q1zG4/w-d-xo.html
    Groovy : th-cam.com/video/B98jc8hdu9g/w-d-xo.html
    Scala : th-cam.com/video/DzFt0YkZo8M/w-d-xo.html
    Lua : th-cam.com/video/iMacxZQMPXs/w-d-xo.html
    Ruby : th-cam.com/video/Dji9ALCgfpM/w-d-xo.html
    Go : th-cam.com/video/CF9S4QZuV30/w-d-xo.html
    Objective C : th-cam.com/video/5esQqZIJ83g/w-d-xo.html
    Prolog : th-cam.com/video/SykxWpFwMGs/w-d-xo.html
    LISP : th-cam.com/video/ymSq4wHrqyU/w-d-xo.html
    Express : th-cam.com/video/xDCKcNBFsuI/w-d-xo.html
    Jade : th-cam.com/video/l5AXcXAP4r8/w-d-xo.html
    Sass : th-cam.com/video/wz3kElLbEHE/w-d-xo.html

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

      Derek It's very much confusing .

    • @utopian201
      @utopian201 3 ปีที่แล้ว +1

      I hate the term 'rockstar developer', 'code ninja', but I think given your mastery of so many topics (and you need to have mastered something in order to teach it, although teaching can also be considered part of the learning process), you're probably one of the few people whom I would term a 'rockstar developer', 'code ninja'. But its not even just code, its adobe, intruments, cooking - you're like a one man udemy! Incredible!

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

    All that I require is a thank you :) I have no need for money. I'm just happy that you enjoy the videos and that they help. Please dont ever donate

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

    The hardest part about the Abstract Factory is the number of classes involved. It has been said the human brain can only focus on 5 to 9 ideas at a time. If you can break them down into smaller pieces it should make sense. Don't worry, most programmers I come across can't explain how to use the Abstract factory. It was hard for me in the beginning but it opens up a whole new world for creating simulations

  • @dave_by_day7632
    @dave_by_day7632 9 ปีที่แล้ว +389

    I understood your other videos. This one confused me.

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

      David Wells Sorry about that. Feel free to ask questions. This pattern can be quite confusing.

    • @danishbangash
      @danishbangash 7 ปีที่แล้ว +4

      This is the best video I've seen so far. I'm actually shocked that you got confused here.

    • @gurug1161
      @gurug1161 7 ปีที่แล้ว +83

      +Danish Khan, not everybody brain works the same. If so there will be no economic inequality in this world. There would not be wars. I am really shocked to see your comment here.
      A person who understand design patterns cannot understand brain patterns. :)

    • @danishbangash
      @danishbangash 7 ปีที่แล้ว +5

      Guru G Ahahahahaha. Yeah, that's true! 😁

    • @bluejanis5317
      @bluejanis5317 7 ปีที่แล้ว +3

      +Derek Banas
      In what situations would you use the abstract factory pattern?
      Are there situations where the regular factory pattern is better than the abstract factory pattern?
      Why did you use abstract classes and not interfaces?

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

    Some things that may help : Take a look at the code on my site. I also have the diagram there. I also covered the Abstract Factory again in this tutorial newthinktank. com/2013/02/code-refactoring-18-2/
    This is considered the most complex of design patterns. You don't use it all that much

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

    Many more patterns are coming. New patterns and refactoring will be a major part of my next month of videos. Don't worry I'll cover everything :)

  • @true_podejrzany
    @true_podejrzany 8 ปีที่แล้ว +24

    this is so deep in layers of abstraction that I can almost see Adele rolling in it

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

    I actually have 2 design pattern tutorials. This one and another titled refactoring which is packed with patterns among other things. Stick with it and you'll get them. Make sure you completely understand OOP and design patterns will make a great deal more sense. I wish you the best and feel free to ask questions

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

    I provide heavily commented code in the description. I also revisit this pattern in the last video in my refactoring tutorials playlist. I hope that helps :)

  • @MrAndor982
    @MrAndor982 5 ปีที่แล้ว +231

    Guess I'm gonna go work at McDonalds instead.

    • @subramanianchenniappan4059
      @subramanianchenniappan4059 5 ปีที่แล้ว +2

      Haaa haa

    • @murionutz
      @murionutz 4 ปีที่แล้ว +7

      I want a bug ufo burger, please

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

      Why are you running @PrimeTime? Come back and make me a Big UFO burger.

    • @amirgamil
      @amirgamil ปีที่แล้ว

      Never give up! Didn't get it? Try again!

  • @samtux762
    @samtux762 8 ปีที่แล้ว +26

    Thank you for great tutorials. When watching them I recall this:
    Every programmer occasionally, when nobody's home, opens up a file on their computer. It's a different file for every programmer. Sometimes they wrote it, sometimes they found it and knew they had to save it. They read over the lines, and weep at their beauty, then the tears turn bitter as they remember the rest of the files and the inevitable collapse of all that is good and true in the world. This file is Good Code. It has sensible and consistent names for functions and variables. It's concise. It doesn't do anything obviously stupid. It has never had to live in the wild, or answer to a sales team. It does exactly one, mundane, specific thing, and it does it well. It was written by a single person, and never touched by another. It reads like poetry.

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

      You definitely have a way with words :) I agree through design patterns and refactoring we can create truly beautiful code.

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

      You are a programmer in poet's body.

    • @groadybones
      @groadybones 5 ปีที่แล้ว +4

      and it is Hello World

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

      @@groadybones LOL! you nailed it! XD

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

    It is another layer of abstraction that is commonly used. The design patterns can come in different forms though. This is an example of the GOF pattern. I provide another example on the Abstract Factory at the end of my refactoring tutorial (Last Video). It may help to see it in a few ways

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

    I'm going to be covering UML next. Then I'll review everything in a very non language centric way. Then I'll make a c / c++ tutorial when I get into graphics because Java doesn't provide the speed I need to make games. So, Yes :)

  • @ANoleJoke
    @ANoleJoke 5 ปีที่แล้ว +10

    3:22 I think it is worth mentioning that in Java, when a method returns an abstract or interface type, it actually returns the subclass object that extends the abstract class or the object of a class that implements the interface respectively.

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

    Thank you :) I used to really mix up the tutorials, but lately I have just been getting programming requests. I'm glad you like them

  • @heytbekankasin
    @heytbekankasin 7 ปีที่แล้ว +95

    I understand clearly nothing!

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

      Zor amk ya :D

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

      same just wasted 26 minutes by watching the video twice

    • @eliranmichaeli1580
      @eliranmichaeli1580 4 ปีที่แล้ว +3

      It feels complicated indeed, but It's actually mot much diffrent than the normal factory, just that this time not only the Ships are abstracted, but also the Factories. So you now have another layer that chooses which Factory are you going to use, and only then you refer to the making of the Ship with that factory.
      The idea is that u might have several factories that each of them make ships diffrently so you therefore abstract this layer too.
      So In this video we have 2 factories: one that creates BossShip components, and one that creates NormalShip components. Notice that the ship constructor now recieves a factory argument which tells it which factory to use for the making of it's parts.
      Hope this made it alittle clearer.

    • @TehPobo
      @TehPobo 3 ปีที่แล้ว +3

      @@eliranmichaeli1580 thank you
      :D

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

    If I ever say stuff that you don't understand I feel that I've failed as a teacher :( Feel free to point out what I can explain further. It will help me improve as well as those who are having the same problems as you that aren't speaking up. I'll do better to improve. Thanks a bunch :)

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

    You are very welcome :) I'm extremely happy that you found the videos useful

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

    You're very welcome :) I did my best to make the gof patterns easy to understand both here and then again in the refactoring tutorial. I'm glad you like them

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

    I'm just trying to demonstrate the pattern while trying to keep everything as easy to understand as possible. At the end of my refactoring tutorial I provide another better version of this pattern

  • @WangTmg
    @WangTmg 8 ปีที่แล้ว +20

    wow, after jumping straight from factory method pattern, it got to a whole new level. I am in "repeat mode" till i master this pattern . XD

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

      +GNAW GMT Yes the patterns get much more complicated. I did my best to make them understandable so you can then move on to the GOF book.

  • @figloalds
    @figloalds 8 ปีที่แล้ว

    Came here to learn more for the programming I do for a living.
    Got an universe of insights for the programming I do for a passion.

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

      Thank you :) I'm very happy that I could help

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

    Thank you very much for the referrals :) I looked at all the books available on patterns so that the series would hopefully help everyone regardless of the book they use. I'm very happy that it has helped as a supplement

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

    Many people are confused by this video. I can understand why. The simplified way to view the Abstract Factory Pattern is that an Abstract Factory is a factory that creates other factories.
    In the previous video (Factory Pattern) it was illustrated a factory of enemy ships. So the business had (initially) one product of different varieties. Later on, the business grew to the point where different types (families) of products are provided. Modifying the EnemyShipFactory to create Weapons will be incorrect because a Weapon and an EnemyShip are two different things. Therefore, you would 1) Create the WeaponsFactory with the different flavors of weapons, and 2) you would create Factory that can create dynamically either the EnemyShipFactory or the WeaponsFactory depending of the kind of order that was placed.

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

      It was very helpful clarifying the connection to the previous video.. thank you very much!

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

      Really well explained

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

    I understand why a lot of people are complaining about the UML diagram but i found the analogy to be very helpful, thank you.

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

    I just started watching your playlist on design patterns and I'm loving it. I'm taking Design Patterns class in school and your videos really help solidify the material. Thank you very much and keep doing what you're doing because you're good at it!

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

      ***** Thank you for the nice compliments :) I did my best to clear up this complicated topic.

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

    Always feel free to ask questions. I'm here to help the best I can. Thanks :)

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

    Thank you :) I'm very happy that I seem to be helping people with this topic

  • @ShaheelGani
    @ShaheelGani 8 ปีที่แล้ว

    I am a novice in the world of software engineering working with java and php was having hard time getting hold of concept of design patterns. After watching this videos atleast am able to explain the concept hopefully should be able to implement it after practicing a bit. thank you

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

      +Shaheel Gani You're very welcome :) I'm happy that I could clear up design patterns.

  • @robl39
    @robl39 10 ปีที่แล้ว +78

    "Well hello internet!"

    • @JACK019930
      @JACK019930 10 ปีที่แล้ว +16

      Greatest intro on the internet

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

    hey sir ! i got very low marx in my software design paterns exam.got the results today. so i came looking for tutorials as i dont get any of the design paterns n i came acros these tutorials of urs. n i found them very useful so far. hope thy help me in geting a good understanding of wat design paterns are n in passing my finals :)

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

    This is an amazing explanation!
    Note to other viewers.... you have to understand how abstract classes / methods work in order to get how abstract factories work.

  • @niemand12345
    @niemand12345 8 ปีที่แล้ว

    vivid + clear explanation, you get the big picture first before diving into the code. I really like this tutorial !

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

      Thank you :) I'm glad it helped

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

    No, you are a good teacher. Its just me... After watching a video I go back and watch it again, and 99% of the time, I get what I didn't the second time...

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

    I think your video tutorials should be cited and pinned for students or who-ever in their design pattern study material. People should be open on that. Thank you

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

      Thank you :) I'm happy you have found them helpful.

  • @SravaniVadlamani
    @SravaniVadlamani 6 ปีที่แล้ว +19

    3:20 , UFOenemyShip , RocketEnemyShip , BigUFOEnemyship are not abstract classes. They are concrete classes , the instances of which are being held by a reference of a common parent (In this case , the abstract class EnemyShip) in the main function

  • @mionel237
    @mionel237 8 ปีที่แล้ว +33

    you should have included uml diagram

    • @TehPobo
      @TehPobo 3 ปีที่แล้ว +1

      :(

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

    Thank you :) Yes, these videos are best viewed with the code printed out beforehand. Then if notes are taken during the video on the code in your own words everything should stick. I also covered the Abstract Factory at the end of my refactoring tutorial

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

    You're very welcome :) If you work on this pattern all of the others will be simple to use. This is about as complicated as they get

  • @kittu1982in
    @kittu1982in 9 ปีที่แล้ว +11

    Hi Derek, at 3:21 you said UFOEnemyship() is abstract class. And we can not create abstract class object then how can we return an object of abstract class with new ? can you please explain it to me?

    • @You3gs
      @You3gs 9 ปีที่แล้ว +11

      it s not an abstract class it s a concrete class , he just misspoke :)

  • @brianlaudrupchannel
    @brianlaudrupchannel 8 ปีที่แล้ว +80

    I hate this pattern

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

      +billyblackburn87 Really its easy. Think: Do you need to create a xThing or xAnotherThing? Make a xFactory, it would know how to create xThing or xAnotherThing or in the future xModernThing...
      Usually creating objects need lot of parameters and could get messy when you only want to say something like getANewXModernThing().... And then you allow to get a newThing or a recycledThing or whatever....

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

      You just described the tip of the iceberg, there's much more to it..

    • @fabdlnltc
      @fabdlnltc 8 ปีที่แล้ว +5

      sean0milan0 Please. Describe. I would be very gratefull if you do that :)

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

    I'll gladly make another video to explain it further. I know this is a bit more complicated than my normal stuff. If you keep at it though you'll take your skills to the next level :)

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

    I got it all loaded into Eclipse it makes it easier to follow what you did, wow 15 classes.

  • @jonedwards9512
    @jonedwards9512 9 ปีที่แล้ว +32

    Your tutorials are pretty superb on the whole, however I actually think you teach this lesson kinda back-to-front. If you follow this demo through in the direction you posit, you only really have something whole by the end. My brain wants to start at: what are enemy ships made of? then how are the different enemy ship components made? then how are the enemy ship parts put together? then how are the requests for enemy ships put together.

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

      +Jon Edwards Thank you :) Yes there is always room for me to improve. I should have spent more time documenting everything in UML.

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

      I realise that the above sounded more critical than intended :) I do genuinely think your tutorials are superb! And, in your defence, abstract factory patterns are fiddly things whichever way you come at them!
      I actually found I got it best in the end just walking through it with a debugger.
      The pertinent take-home message for those that are struggling with it is to appreciate the modularity of being able to exchange the factories that build the UFO's constituent parts. Because the UFO is calling an abstracted Factory, it can be chopped and changed to a different factory at some later stage.
      For example: hey, you're months into your development and you suddenly decide that the UFO type is actually best suited to have the same kinds of components as the Rockets ... no problem, just switch out the factory that tells the UFO what it should be made of. No problem! Your requests in Main are untouched as are your program's requests to actually build the UFOs.

    • @kamillatosinski3054
      @kamillatosinski3054 8 ปีที่แล้ว

      +Jon Edwards Thanks for the comment pointing out the usecase :))

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

      I agree with you. The best way if you do not understand something is to debug it ! It always helps me too !
      By the way, with the provided code, this tutorial is good enough !

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

      Necroing this but yeah. I had the same feeling.
      The best way to explain this here would be to explain that the specific ship classes have a factory that builds what they need to have to not just be a generic ship.
      The factory doesn't build the specific ship but each ship is defined by how the factory creates the missing parts them.
      Something like that

  • @bornafrica7887
    @bornafrica7887 2 ปีที่แล้ว +1

    2022 and this is still relevant. Thanks man

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

      Thank you for taking the time to tell me I helped :) I appreciate it!

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

    Thank you very much :) I have been practicing for a while at this. I am very happy if anything I do may help you or others teach better.

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

    I think I improved on this video in the final part if my refactoring tutorial. I hope it helps :)

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

    this video is so freakin golden it's insane..
    5th time watching it today, still keep going 'oh hey..' every few minutes while watching..

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

      Thank you for taking the time to tell me you like it. It was a fun series of videos to make.

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

    You are very welcome :) Thank you very much for the kind message. I'm happy to help

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

    I have a suggestion for you (and for every professor in HS and in Uni): when presenting code in PowerPoint, or other presentation software, try to include the code with syntax highlighting. It really helps to differentiate the parts of the code, the keywords, and the variable names. It really frustrates me when I see black-and-white code in presentations - syntax highlighting is one of the reasons why we do not program in plain Notepad... Use for example Carbon, or Polacode - or just simply take a screenshot of the code in your IDE / Text Editor.
    I really appreciate your time and dedication to these videos, though - it really helps me a lot! So keep up the good work! :-)

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

      Thank you for the input :)

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

    You're very welcome :) EnemyShipBuilding just provides a utility use and separates the code in to smaller pieces

  • @teodorsavov3389
    @teodorsavov3389 9 ปีที่แล้ว +15

    Hey Derek! Love your vids. Could you please provide a UML diagram for this design pattern? Also, in main() we have EnemyShipBuilding MakeUFOs = new UFOEnemyShipBuilding(); which implies that we know that we are building a UFO (as opposed to a rocket ship). Doesn't this kind of go against the whole idea of dynamically choosing objects? Thanks in advance.

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

    That sounds good to me. I some times don't optimize everything because I'm just trying to get the basic idea across. I revisit the abstract pattern in my refactoring tutorial as well.

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

    This might not have been the perfect example on using this pattern, but I was trying to keep everything as simple as possible. Later in my refactoring tutorial I get into more advanced better examples. Sorry about that

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

    Yes that would be very accurate. The aren't very common. I show another example of how to use them in the last video in my refactoring tutorial

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

    I'm not all that smart. I just don't have any other hobbies. You're very welcome :) Im very happy that you enjoy them

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

    Thank you :) It is very exciting to be able to help people all over the world!

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

    One of the DP most difficult to understand. Your diagrams have helped me a lot. Thanks so much for the neat presentation and teaching strategy design. It is much appreciated.

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

      fallback R Thank you :) I'm very happy that I could help

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

    Thanks :) I think I'm going to have to cover UML. I only avoided the normal UML diagrams this time because I thought the pictures might help. I'm definitely going to cover real world topics as soon as I get the basics down. I wish I could get this to work more like a lecture with people asking questions but that doesn't seem to ever work. This is just the beginning. I constantly change my teaching style based on input. Thanks for that

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

    This is a great video, took a bit of rewatching to really get it but pausing and taking notes on each part really helped.
    Seems to me that it's essentially the Factory pattern inside another Factory pattern (Factory-ception). You have an object made up of multiple parts, each part (engine, weapon etc) created using a Factory pattern (i.e. Weapons are made using Weapon Factory), but these parts Factories are then called inside an overall Factory. So essentially you're calling a Factory that then uses another Factory for each part, which is a really neat idea.

  • @shaunz3836
    @shaunz3836 8 ปีที่แล้ว

    Really appreciate your tutorials. You have a knack for explaining these complex patterns in a relatable and understandable way. I especially like your examples and how you have separated and broken each component down to better illustrate how everything fits together as a whole. Keep up the awesome tutorials.

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

      Thank you for the compliment :) I do my best to keep the videos fun and understandable.

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

    Your series of videos are fantastic. Clean, concise and to the point. They've helped me out massively throught my university course, so thank you Mr Banas!

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

    I provide another example of using this pattern in the very last video in my refactoring tutorial. I use this pattern very often when I'm building simulations. These tutorials mainly came from the GOF book, but I used many of my personal notes as well

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

    You're very welcome :) I'm glad you found it useful

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

    Yes you are very intelligent :) You definitely are getting the idea. All of your comments have been very insightful

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

    You put a lot of effort into this, thank you for that. Made my exam prep a breeze.

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

      JFrame I'm glad that I could help :) Best of luck on your exams

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

    You're very welcome :) I'm glad you liked it

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

    You're very welcome :) I definitely don't do this for money. You'd laugh if you saw how much I make. It is very gratifying however to me to be able to help people all over the world!

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

    It just seems so complicated. I guess for now I'm happy to know that this is possible and I'll watch it again if I find myself needing this. But great job anyway :)

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

      Thank you :) Yes learning Design Patterns and Refactoring is pretty high end programming. Very often the most important part about learning them is to learn when not to use them.

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

    Derek I am C# .Net Developer...I am following 100%....Awesome stuff....

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

      abhijeet girase Great I'm very happy that it is helping :)

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

    Thank you :) I think I improved on this tutorial in the final part of my refactoring tutorial. Sorry about the confusion

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

    This was the main one I struggled to understand in class.. Starting to understand it, but it's not there yet. Probably just takes time, definitely gonna dive in to the code. Thank you!

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

      Yes it is a complex pattern. You'll get it

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

    This is really awesome!
    First, I read a chapter in the book head fists design patterns then watching your educational tutorial to brighten things up. And it works. Learning design patterns will become easy thanks to you.
    I will Recommend your channel to everyone.
    And thank you for doing this!

  • @meh.7539
    @meh.7539 2 ปีที่แล้ว

    I **JUST** realized that this system is **probably** a good example how the Borderlands franchise implements their gun customization/randomization system at a very high level.

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

    Thank you very much :) Yes I wish I would have made more examples. I plan on revisiting design patterns when I cover C++

  • @lou8566
    @lou8566 8 ปีที่แล้ว +3

    Thank you for these, It is much appreciated. This format however is great in addition to the other format would be better. I find showing the code helps that much better. That being said, thanks again and keep up the great work.

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

    An abstract class is normally a class that wouldn't make sense to turn it into an object. What would an animal object look like? A dog object definitely makes sense though. Abstract classes are used to abstract out what is the same for all subclasses. It is also used to allow for polymorphic tricks. Concrete classes are made to be used as objects. Does that make sense?

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

    Thank you so much for your videos! I was really confused trying to understand the difference between the factory and facade patterns (since my professor didn't do a good job of explaining it), so your factory design pattern videos saved me before the midterm. Your videos are the best.

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

      Thank you for taking the time to write me such a nice message :) I greatly appreciate it!!!

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

      @@derekbanas and thank you for your work!

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

    You're very welcome :) I'm happy I was able to help!

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

    Derek,
    If I want to add an additional power to the Boss Ship , say Missiles.I will have to add an extra function called "addMissile()" in the EnemyShipFactory class (and not in the UFOBossEnemyShipFactory class) so that polymorphism works. If the above is correct then wont this extra function be redunded for normal enemy space ships (wasting extra memory).?

    • @benjaminfalls
      @benjaminfalls 8 ปีที่แล้ว

      +Harsh Chaudhari Yes, I was wondering the same thing. Without giving it much thought right now, perhaps you could have multiple abstract EnemyShipFactory classes. Then, in the concrete EnemyShipBuilding class, you could use the appropriate abstract EnemyShipFactory class for each UFO with different parts.

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

    Thank you :) I'm doing my best to make design patterns understandable

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

    Abstract factory is just a factory that creates factories

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

    Feels like , Abstract factory pattern is used when we have various factories producing different things and we don't want client to decide which factory object it should consult to make a product, rather than just delegate the process of making an object to the wrapper of all factories , which will have the logic of deciding which factory to consult on order to make the right object.
    It makes me remind if Facade Pattern as well, in this case the Facade will encapsulate all the factories.

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

    Great tutorial! When you read the code and go through it, it all makes perfect sense. Thank you!

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

      +Justine Lo Thank you :) I'm glad it helped

  • @RELO4D3D1
    @RELO4D3D1 7 ปีที่แล้ว +3

    Hey Derek, not sure if you go into this later in your tutorial series but why don't you use public static ENUM's in your factories that define what type of ships are available? So You could use UFOEnemyShipBuilding.makeEnemyShip(UFOEnemyShipBuilding.SHIPS.UFO_BOSS) to create a UFO Boss ship. This will prevent typos in ship types, and also provide a nice list inside a developers IDE on which ship types are available.

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

    That is right. It just contains many factories that make different dynamic objects

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

    Hello Derek, nice video. Good graphics. While the video does a good job of explaining how an abstract video works, it wasn't until I looked at the code that I started to understand the value of the factory. It wasn't until I saw that enemy ships took in the factory in it's constructor, that it became clear the role of the factory. I was going under the false presumption that the factory in the abstract factory pattern behaved the same as the one in the normal factory pattern.

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

    I'll be revisiting this pattern in my refactoring tutorial. I should have kept the pattern in a simpler form. Also I think I didn't spend enough time explaining that patterns can take on many different forms. I'll correct that as well

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

    What a great presentation of design patterns - demystifying...... Great job

  • @RohitSharmairohit
    @RohitSharmairohit 8 ปีที่แล้ว

    Derek your videos gives a total insight. Kudos to your effort for making such quality stuff specially for codes :)

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

      Thank you for the nice compliment :)

    • @RohitSharmairohit
      @RohitSharmairohit 8 ปีที่แล้ว

      Hi Derek,
      Could you please suggest me some good book on Object Oriented Software Design which has sufficient practice sets other than Head First. I already own Head First book.
      Thanks

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

    I am probably very late in commenting this video. I watched so many of your videos, i loved them all. but this one you really went that extra mile with the diagrams which are really awesome. I wished all the videos had that methodology.
    (one thing to add, is that the code you present isnt colorized anymore. although it is a small detail, i reallized code is actually harder to read whitout that purple font on the keywords).
    But, again, awesome video!

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

      Thank you for taking the time to tell me you're enjoying the videos :)

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

    Once again your explanation is crystal clear. Congrats!
    This time I have a very interesting question (I believe), that is... How is you Entity Relation Diagram going to be if those objects need to be database Entities (because you need to persist them)?Let me elaborate onto this idea:
    At the beginning, you create a table to represent the abstract class, for instance EnemyShip, so you add a name column and create a Foreign Key to ESWeapon and ESEngine. So far so good, but what happens when you EvilEnemyShip concrete class (which has a new float property 'turbo') needs to be persisted?
    Never found a "right answer" to this question, though I have come up with 2 different approaches:
    1. You add a 'turbo' column to the EnemyShip table and use it only when needed (ie: on EvilEnemyShip objects) and in any other case you just persist a null value. Ok this may work but it has some remarkable drawbacks:
    - You need to add every EnemyShip specific implementation columns to the EnemyShip table to support its persistance in the DB. This means that the number of TABLE COLUMNS MAY GROW REALLY FAST, and MOST OF THEM COULD BE NULL!
    - At first glance, you can't for sure know what type of specific EnemyShip is for a given tuple. This can easily lead to errors if logic is not consistently implemented in you program code. However, this problem can be solved adding an extra column 'type' where you store which specific EnemyShip it is.
    2. For every new specific EnemyShip implementation you create a new table, for instance the EvilEnemyShip table, and you add every extra column needed to this table to persist all its properties. Then you add a Foreing Key in the EnemyShip table to the EvilEnemyShip. I have come up with this approach to mitigate the problems described in the first approach:
    - Now EnemyShip table columns will only increase at most 1 for every specific implementation. Note that this only decrease the number of new columns but you still are going to have a lot of null values. On the other hand, it is the number of tables that is going to increase in 1 for every EnemyShip specific implementation. Is this tradeoff better? Can't tell. THIS IS WHAT I'M DYING TO KNOW.
    - You can tell which specific EnemyShip implementation a tuple is based on the Foreign Key that is not null for a given tuple.
    Hope yours or somebody else's expertise can help me with this life or death doubt 😂

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

    All credit goes to seniors like you !!! :-)

  • @AngelLopez-qw7ci
    @AngelLopez-qw7ci 3 ปีที่แล้ว

    What would the benefit of passing in the factory to the object actually be? The only thing I can think of is if you don't have access to the code of the constructed object.

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

    I just made every pattern in the gof book. I tried to create them so that they could be used as self contained videos and didn't require the viewer to watch all of the others. The factory patterns seem to confuse people the most

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

    Had to repeat 2 times, but you are great at these! Keep up the good work,

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

    Hello Derek, I am so happy to have found this pattern explanations. Finally I can learn to understand them clearly. And there is this one
    question nobody could ever answer me, but you can: Why maybe every plugin in wordpress starts with a static init method

  • @serock3
    @serock3 9 ปีที่แล้ว +5

    Does every EnemyShip subclass need its own factory? I can't see the purpose of spiting up the construction of the ships into an EnemyShip subclass and an EnemyShipFactory subclass, if they're always unique then why not bake them into one? What extra flexibility does it add? The UFOBossEnemyShip and UFOEnemyShip classes are exactly the same, that seems strange and inefficient. Why even use subclasses of EnemyShip at all then? Why can't it all be baked into the EnemyShip class if the factories are the only thing that gives the ships functionality?
    Edit: Another thing is the EnemyShipBuilding and UFOEnemyShipBuilding, why split them up in in two? Are you suppose to make different Buildings for different lists of ships so that the "if" statements don't become too long?

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

      +serock3 There's a similar example in Head First design patterns (you should read it). However, they use Pizza's and Pizza factories. It makes sense to have have abstract factory classes since you may have lots of different types of ships or Pizzas. Essentially the concrete factories make the ingredients and the concrete products (Ships or Pizzas) are composed of those ingredients. The beauty here is that the concrete products don't know and don't care how the ingredients are made, that complexity is moved away from them through the use of the factory. I suggest you look up "Program to an interface and not to an implementation".

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

    I do my best. I'm very happy it helped you :)

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

    If you wanted to make either a RocketEnemyShip would you have another abstract method in "EnemyShipBuilding" for the rocket ie.
    protected abstract EnemyShip makeEnemyRocketShip(String typeOfShip);
    If not, how would you distinguish between building a Rocket or a UFO?