Factory Design Pattern

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

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

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

    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

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

      You are amazing!

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

      th-cam.com/video/EAOgVOZjAS4/w-d-xo.html factory pattern in .net and .net core

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

    Here are all the design pattern videos in order, and on one page newthinktank. com/videos/design-patterns-tutorial/

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

    You use the Factory design pattern when you want to define the class of an object at runtime. It also allows you to encapsulate object creation so that you can keep all object creation code in one place.
    The abstract pattern just makes more complex objects

  • @voidpointer398
    @voidpointer398 7 หลายเดือนก่อน +3

    still helping developers after 11 years
    amazing video

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

    I am studying for an interview as a Senior Java Developer and I found these to be very helpful. I am sure I learned all this before but it is a nice refresher since I do not always use them every day at work and I have a bad memory. Thanks Derek, we really appreciate this service you provide.

  • @justintorre694
    @justintorre694 4 ปีที่แล้ว +59

    This tutorial was made so long ago but is still so perfect

    • @teratoma.
      @teratoma. 4 ปีที่แล้ว +9

      what do u mean long ago???
      8 years ago was 2 years ago

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

      "long ago"... very relative

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

    60 seconds into the video and you already explained it so much better than any other resource i have seen so far. and i have watched a ton of them. thank you!

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

      Thank you for the compliment I'm happy I could help

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

    The best thing about your tutorials is that they are precise. That prevents any kind of confusion.. Sometimes I rewind a bit to pick the pace, but over all your lessons are very well imprinted in the viewer's mind.
    Great Work!

  • @NC-ps2ck
    @NC-ps2ck 11 ปีที่แล้ว

    I just wanted to say that when you outline the basic info in text in the beginning, that is extremely helpful. I'm the type of person who likes to get the gist of something aside from textbook descriptions, and those brief and concise intros are awesome. Thank you very much.

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

    You're very welcome :) A C++ tutorial is in the works and will be out very soon

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

    Congrats on this video because you made it very clear and simple! 🙌
    However I'd like to make some notes that can help understand this best to new coders:
    1. Encapsulating the decision making of what EnemyShip to create in the Factory, you avoid duplication of code (yes, youd said it). But I can imagine coders thinking "WHERE!?". Well if you don't do it in the Factory class, then you are gonna put that logic in every place that you may need to create an EnemyShip, such as the main() method you used in the first example.
    2. Another benefit is that inside the factory method you can handle exceptions, such as when the string passed to choose the concrete EnemyShip is invalid, you can for instance throw an IllegalArgumentException. If needed you can catch that exception in the client class (ie: the class using the factory) or maybe just throw a RuntimeException.
    Hope it helps!

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

    Thank you :) I did my best to make the tutorials easy to grasp so they could be applied to other languages. Thank you for telling me I succeeded.

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

    Yes that is where the design patterns came from. They were great solutions for common problems that eventually people started writing down.

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

    You're very welcome :) It is very nice to be able to help people all over the world. I'm glad you liked the video

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

    I have not watched all of your DP tutorials but if the method of teaching used here is the same applied all through the tutorial, then you have won my heart and time. I want to thank you for your time. God bless you!

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

    If you are dealing with many data formats a facade may help you hide that complexity. A factory may help if you need to create many instances for each file format. An adapter may also help you deal with incompatible interfaces? It all depends on what your dealing with. I hope that helps?

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

    Good tutorial. No fluffing around, no waiting for someone to slow type out everything, only important information explained precisely. Nice stuff

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

      Thank you for all the nice compliments :)

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

    You're very welcome :) I'm glad I have an audience for these topics. You're english is very good by the way

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

    You are very welcome :) thanks for taking the time to say you liked it

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

    I eat egg beaters (Egg Whites) now and again. I purely eat this way because I try to be healthy and I really don't like meat. I never liked eating it. I don't have anything against anyone that hunts. When I was little I had to eat deer meat to survive. Thankfully now I can eat what I want :)

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

    super helpful, I love your approach where you explain the 'bad' approach first then explain 'good' way to implement the same functionality with factory pattern.

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

      Thank you :) I'm happy you are enjoying the DP videos

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

    Super cool. I just wrote in about 2 hours a random football commentary. I made classes : Player, Team and TeamFactory (+some particular teams classes) and now the player can pass and shoot. This is so cool because after you implement it, you only have to add stuff and it doesn't break anything. Thank you!!

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

      That's awesome! I'm happy I could help. I love making little fake people in my computer and then just watch them live in there :)

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

      I'm really curious what are your thoughts on this implementation of the factory:
      public class TeamFactory {
      public Team createTeam (Class

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

    Thank you :) I'm planning on making an advanced algorithms tutorial that will be covered as I continue making Android tutorials. I'm planning on covering a bunch of topics other then Android over the next few months including C, C++, JEE Topics, Advanced Algorithms, Ruby and some random psychology topics people have been asking for

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

    I'm glad you are enjoying the videos :)

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

    Thank you for taking the time to tell me the video helped :)

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

    You're very welcome :) It is very nice to be able to help so many nice people

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

    So I just started Ruby and ran into this same issue. I had lots of if-elses to control what got created and how and started to run into maintainability issues. The ideas here were general enough to be applicable to almost any (possibly all?) OO based languages. Thanks so much for posting this!

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

    Yes encapsulation and decoupling is the goal of the factory and many other patterns. I'm very happy to have helped :)

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

    every once in a while I come here to refresh my memory. it is fast and concise. after all these years, still one of the best for design patterns.

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

    I have used these design patterns, figured some of them myself, but never knew these had names before watching this video. But great playlist learned some new design patterns which I think will help me in my upcoming projects. Thank you so much, sir.

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

      I’m happy I could help :)

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

    You're very welcome :) Thank you for taking the time to say you liked it

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

    Thank you :) I'm experimenting with new ways to teach so that information sticks in the brain. I'm glad you enjoy the videos.

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

    My number one goal is to make complex topics easy to understand. Thank you very much for telling me that I succeeded! You're very welcome :)

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

    That is awesome! Congratulations! I'm very happy I was able to help. Thank you for taking the time to tell me that. It means a lot to me :)

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

    Thank you :) I'm very happy i was able to succeed with what I aimed to do in this video. I'm glad you liked it

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

    Happy holidays and Merry Christmas to you and your family as well :)

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

    You explain really well, have an easy to understand accent and your code is pretty clear. Thank you for sharing your knowledge!

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

      Thank you very much :)

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

    Yes this is also called the factory method. The other factory pattern I cover is the abstract factory

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

    I'm very happy that you've been able to use them with other languages! That's great

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

    I'd follow the advice of your professor since he will decide on your grade :) I personally like to cover the patterns from the least complicated to the more complicated. I also like to structure them so that after you learn a concept in one pattern I like to reenforce it by using a similar pattern. The difference between me and professors is that I don't believe there are as many rules as they do. I hope that helps

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

    The diet I created helped me to lose over 80 pounds. It focused on quantity over calories. That forced me to find low calorie / low fat / low sodium alternatives for everything. I've never eaten factory produced meat so I have no idea what it tastes like luckily :) I've seen the videos and agree the process is both terrible for the animals as well as for those who eat the food, but I always try to avoid judging. I agree that regular eggs are way better :D

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

    Great video,thanks! According to headfirst, this is a simple factory pattern...
    Your voice is like a auctioneer. It is quick but very clear.

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

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

  • @thecuriousone12
    @thecuriousone12 10 ปีที่แล้ว +4

    Thank you so much Derek for these videos ! They are very helpful, I learn much more from you than from actually going to college!

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

      UnspokenDesirexX I'm very happy that I can help :) You're very welcome.

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

    I understood factory pattern in just 10 minutes by watching this video...Thanks Derek ..You're awesome :-)

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

    EnemyShip is an abstract class that I used to create UFOEnemyShip and RocketEnemyShip. You cannot instantiate an abstract class. It is just there to facilitate polymorphism. Does that make sense?

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

    Here is some scanner code that should help with that stackoverflow. com/questions/722270/is-there-an-equivalent-to-the-scanner-class-in-c-sharp-for-strings

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

    I see there are quite a few negative comments. I believe the point of this tutorial is to demonstrate use of the factory pattern. Sometimes when you need to illustrate certain aspects of programming you need to skip a few things and ignore "style" and other factors as you're on a clock when creating a video. I believe the factory pattern is brought across quite well in this video and it really helped me understand it.

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

      +Luke Slywalker Thank you very much for the compliment :) i appreciate it.

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

    Mr Banas, you have explained these patterns very well, I would venture yours was the best series on this topic. Good job and thank you sir!

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

      Thank you :) I'm happy that it helped

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

    Your lecture is way better than tons of professors. thank you so much

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

    I'm always happy to help :) Sorry about the confusion

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

    You're very welcome :) I wish more people would make videos so that we could provide a free education for all.

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

    You're very welcome :) Thank you for taking the time to tell me you like the videos.

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

    I'm very happy that you enjoyed it :) That was a little typo on my part. It would be better to say extends with the abstract class

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

    Very clear and informative. Really like the way you jump right to the examples, which immediately show the usefulness of the pattern. Also, it's cool that you have an entire series dedicated to design patterns. Useful stuff. Thanks :)

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

      +MsMaklaj Thank you very much :)

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

    seriously, I also read the design patterns book of those great four - but only after watching these videos I seem to understand the patterns:) good job!

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

      +Starface606 Thank you :) My goal with these tutorials was to make the GOF book easier to understand.

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

    Thank you :) I have been think about covering Ruby because I don't think it would require a ton of videos to cover like java and c#. Ill try to add them soon to mix up the android series

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

    Great tutorial. Really powerful to explain the concept, then step through code line by line to explain why someone would want to use it. I also appreciate that you took the time to edit out downtime in editing the code so you could explain this in much less time.

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

    Hey man, I am a student at the university of applied sciences in Rotterdam ( the netherlands ) and I would like to thank you from the bottom of my heart for all these amazing informative videos, they really help me out!

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

      Thank you for taking the time to tell me that they helped :) I greatly appreciate that. It is also particularly cool that I'm helping people in other countries because I never travel. I feel like I'm seeing the world in some weird way :D

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

    Used to create instances of objects that share a superclass
    Type returned needs to be determined at runtime so we use factory. Centralizes the code that creates the objects
    2:05 uml diagram

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

    8:50 "Show you what is so factory about this factory"! LOL Derek! Great movie.

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

      That's funny :) I'm glad you liked it

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

    The way you are explaining in these videos, presentation are absolutely understanding and cool..:)
    Thanks muck Derek!!!!

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

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

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

    I agree with Derek, while you could make it a Singleton pattern you would be adding more 'complexity' or 'semantics' to a single class, thus giving more responsabilities to a single class, and remember one of the best things to achieve better modularity (I can't think of a OOP definition) you need to have well defined responsabilities for each class.

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

    best tutorial for this pattern, all the others are so confusing, got this in 2 minutes, thanks

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

    You're very welcome :) yes I covered facade. It is on my TH-cam channel in the design patterns playlist

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

    You're very welcome :) Good luck on your interview!

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

    These videos are greatly appreciated. Youre so much better than my professor

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

    although i use php, this video really helps me a lot about kowning factory design pattern, good job Derek

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

    Happy holidays and merry Christmas!

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

    Love the way you breeze through it...never been on the edge of my seat watching a tutorial before...Thank you so much!!

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

    That is a good idea. Anything you can do to lower coupling is almost always good :)

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

    Thank you very much :) I do the best I can to make complex ideas understandable. I'm glad you like them

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

    Thank you :) Maybe if you see another example it will make more sense. I tend to improve when I cover a topic the second time. Look for Code Refactoring pt 5 on my TH-cam channel. It is also on the Factory pattern. I hope it helps

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

    This saved my degree, my last course I just couldn't get it, until I watched these videos. thanks

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

      That's Awesome! I'm happy I could help

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

    Best explanation ever! You put the concepts very simple and straightforward! Thank you for the work you put in!

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

      +Filip Ghimpeteanu You're very welcome :) I'm glad it helped

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

    I'm glad you fixed it. Always feel free to ask questions :)

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

    From bottom of my heart, thank you for making this video. I really struggled understanding design patterns. Thanks

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

    Thank you :) I'm sorry, but a may not understand the question. This is just an example of using the factory method.EnemyShip is used only to be able to pass its subclasses so it is more dynamic

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

    I was for a few months, but my body couldn't handle it. I used to get very jumpy all of the time. If you go completely raw your body processes the food very quickly which a least in me caused stress. If you are an athlete I'd highly recommend it, but it didn't work for me. I only eat grains, veggies and cheese. I could never give up cheese :) No sweets either

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

    You're very welcome :) I do my best to make the topics interesting

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

    Your tutorials are great Derek. They're great for revisiting patterns and I always recommend you for reviewing or learn design patterns.

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

      +Steven Fox Thank you very much :)

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

    How you break the "if else" into new line literally hurts... Nice video :D

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

    You could call it immediately after creation. You could give every ship an id and then refer to it that way. You could cycle through all ships using an enhanced for. You could use reflection. There are many ways. Don't worry I'll be covering refactoring very soon and it will provide real world examples on when and how to use design patterns

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

    Did you compare your code to the code I have on my site. It sounds like a little typo

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

    That's super :) Im glad I was able to help. You're very welcome

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

    Your videos are saving me in school rn. Thank you!!!!

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

      I'm happy to be of help :)

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

    If you created a subclass with a method that is only in the subclass and not in the super class you wouldn't be able to access that method by referring the subclass as the super class using polymorphism. Technically you could with reflection, but I'm ignoring that for now. You may want to look at my reflection tutorial? I bet it will open the world to you, but just understand it isn't considered a good idea to use reflection very often. It is very powerful, but confusing to some people

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

    I can't think of any reason that that would hurt, but that doesn't necessarily mean you should use singleton. I have to think about that. Off of the top of my head I'd say don't do it just because it will make the code confusing

  • @91whoiswho
    @91whoiswho 11 ปีที่แล้ว

    really appreciate your effort. These videos are very clear and precise. I can start with these and then go for the detailed with a crisp and basic idea.Keep it up!

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

    EnemyShip newShip = null;
    that statement in your factory, you can remove that since you return the values directly instead of returning the newEnemyShip :)

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

    thank you so much Derek!
    I'm currently studying design patterns and i came across this great playlist that simplifies every detail. thank you again for the effort! :)

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

      I'm very happy to hear that it helped :)

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

    Thank you so much for your different example. I was read much of websites but I learned with you.

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

    Thanks for the quick reply, it turns out i had a } in the wrong place, again thanks so much for your time in these tutorials, they're great. Much appreciated.

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

    Even after 8 years still, a very good video with clear explains...Thanks!!!

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

    love your videos, Derek. you explain concepts in a direct and digestible manner. thank you 🔥

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

      Thank you for the nice compliment :)

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

    I will anwser some questions though. A Simple Factory pattern is one that returns an instance of one of several possible classes, depending on the data provided to it. Usually all of the classes it returns have a common parent class and common methods, but each of them performs a task differently and is optimized for different kinds of data. The Factory Method pattern is a clever but subtle extension of this idea, where no single class makes the decision as to which subclass to instantiate. Instead, the superclass defers the decision to each subclass. This pattern does not actually have a decision point where one subclass is directly selected over another class. Instead, programs written to this pattern define an abstract class that creates objects but lets each subclass decide which object to create.

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

    Wow, thank you very much :) It makes me very happy to know that I was able to help

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

    i learn from this list more than i learn at school four years.

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

      Thank you :) I'm very happy that it helped

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

    Thank you very much :) I'm constantly trying to improve. Thanks for the input

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

    Thanks very much for this. I had read it on paper several times and just wasn't getting it - you nailed it ;)

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

      Kevin McCaughey You're very welcome :) I'm glad I could help.