Facade Pattern in Unity

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

Комментарии • 65

  • @Tarodev
    @Tarodev 2 года назад +57

    What a beautiful little demo scene. Nice tutorial Charles.
    Also, Dotween and Shapes... match made in heaven.

  • @AlekseyLoykuts
    @AlekseyLoykuts 2 года назад +8

    Love it, how in code you solve problems by introducing the new layers wich can cause you more problems

  • @emanueltejadacoste2250
    @emanueltejadacoste2250 2 года назад +3

    What happened to the videos and playlists on your channel? 🥺

  • @mathboy8188
    @mathboy8188 2 года назад +2

    Even before there were "design patterns" (pre-GoF), this pattern was one of the most (maybe the most) common... and maybe the only one named. It's a "wrapper", it's "wrapping up" code, especially 3rd party code, but also even for presenting a virtual API of a module or subsystem within your own large applications. (It's a more general and fluid idea than the specific and named design patterns, but the essential idea is closest to the facade pattern.)
    It's... Single Responsibility Principle AND loose coupling AND encapsulation AND saving you from being a prisoner of your own vendors AND is useful (perhaps necessary) for testing. It reduces complexity and so allows new coders to learn the system quicker, and maintenance programmers to navigate the system more efficiently... as well as all coders being more likely to use the system correctly.
    AND it's very easy to do. Of all the coding patterns & principles & maxims, this one might have the biggest payoff for the effort.

    • @Novack_
      @Novack_ 2 года назад

      Yep, beyond the pretentious renaming, he is describing a wrapper.

  • @Kodeman0100
    @Kodeman0100 2 года назад +11

    Great video, I would love to see some more examples with DoTween

  • @thebebinator
    @thebebinator 2 года назад +1

    This is great. A nice return to your slow measured pace. Thanks a lot for the clear demo, hope to use this soon!

  • @sega5785
    @sega5785 2 года назад

    The pattern you've described in example is more like strategy. This functionality wrapping design looks like so. So it hard to distinguish why this is a facade and where it is) But each pattern is always staying near earch other. I decided to put my thoughts about this pattern here))
    Let's start with simple example from real world. What is the facade of the building? - simple, it's the front/face side of the house. It can consist of doors, windows, flowers, turf etc. But house has more functionality then just door and flowers in the front. If we try to translate this example into program, we'll got superclass of house with all the stuff and functions that each house built of. And working with such classes in real life is like a punishment. Listing thousands of lines of code and searching for the " truth". To solve this problem we can use facade pattern. For example the clining company class works only with facade(real not pattern) of houses and there no need to expose all functionality to this guys, who knows maybe they can broke things like heating system or electricity))) So we decided to implement the interface IFacade(bad practice to name like this in real ptojects) to house class. Then the duty list of clining guys will look like this list. And then they will accomplish their job according to information/functionality of this interface. They will see only the "front side of this class" - the interface which used like facade for cleaning system. Other systems may want to use other house functionality, so they need to see other "front sides of this class". I've described one of many implementation of facade patern. I hope it helps someone.

  • @RehtseStudio
    @RehtseStudio 2 года назад +2

    OMG LOVE IT.
    Really like how the video started in using this library and then how to use the Facade Pattern to simply the process😍; the caller example was the best way to explain this.
    I'm reaching level 2 mind set with this videos😁

  • @saschareisen6715
    @saschareisen6715 2 года назад

    It also shows us the Open-Closed - principle, not just the SRP, because you dont need to keep drawing concerns in the Minimap - class. you expose the functionality into somthing for a specific purpose, in this case of drawing to a minimap.

  • @Songfugel
    @Songfugel 2 года назад +2

    Basically a web service (like WCF) inside your local domain for your classes, or the Indian call center for your classes ^_^
    I personally would abstract it a bit more, and useinterfaces and have each of those "services" provided be their own composite class member that the service is sending requests to.
    That would allow you to make huge changes on the fly trying out different versions/implementations of the imported classes or even change vendors completely, without rest of the being any wiser about it
    Writing that 3rd party code directly to the facade class seems just moving the problem to another place, something a partial class or a region could have handled just as well.
    But that tiny little abstractoin layer add, youbcan really leverage the power of decoupling it can bring

    • @serekqwerty
      @serekqwerty 2 года назад

      Your idea is very correct. But working with interfaces in Unity is a huge pain that is better to avoid at all costs.

    • @Songfugel
      @Songfugel 2 года назад +1

      @@serekqwerty Not really, interfaces is the biggest strength of C#, so not using them is handicapping yourself a lot. Only the default editor doesn't support them by default as concrete classes, which is no problem at all. It is very easy to work around or add it in, and Odin supports them
      Unity itself has no problems with them

  • @Abken.
    @Abken. 2 года назад +5

    Cool way to view Facade as a call centre!
    Suggestion: Teach us how to use Decorator!
    Decorator is another cool pattern that I find really useful with Unity.
    For example I want to improve/remake the Player logic and it's risky to start editing the already perfectly working Player logic (also it's against the Open-Closed SOLID principle) and I start working on another class (e.g. PlayerV2 or even new class part of a future class system MagePlayer, WarriorPlayer).
    Decorator helps a lot with keeping the project running and working as expected while changing/improving some of the Player v2.0 class. It would be really bad if I start changing the Player's logic, method parameters and all of sudden the whole project gets full of errors, warnings and I can't check my logic until it's fully finished.
    Or last example (I think the best one) - I need the "basic" old Player class for levels/scenes 1-5 and I need the new one in level 6. I don't want to completely lose the previously working logic. In the future I can decide to deprecate the original Player completely, but until then... the decorated new Player classes will do a lot of good.

  • @aaronperron
    @aaronperron 2 года назад +1

    This definitely some infallible code. 👌

  • @dusan7873
    @dusan7873 2 года назад +1

    That was really good, thanks! I would like to see series focused only on design patterns and their use in game development, kind of like this one.

  • @doge9203
    @doge9203 2 года назад +2

    very nice topic, although, I'm a slow learner so just like before it'll take me weeks or months going back and forth to this video. thanks!

  • @jaykinbacon2379
    @jaykinbacon2379 2 года назад +3

    Would like to know the difference between a wrapper class and the facade pattern...
    So far, it seems like they're the same thing?

    • @Novack_
      @Novack_ 2 года назад +1

      Or an abstraction layer, or a mere controller. Millenials like to use pompous names for everything.

    • @gasparweb
      @gasparweb 2 года назад +1

      I felt the same. 9:16 of wrappers over things. I mean in 30 seconds you could explain something like this. Example: "wrap third party assets function calls on something more meaning full to you".

  • @lavizpandey9957
    @lavizpandey9957 2 года назад +2

    Finally something new to learn

  • @arreme3755
    @arreme3755 2 года назад

    I was literally today searching for this pattern.

  • @mauriciopartnoy2789
    @mauriciopartnoy2789 2 года назад

    Nice one! There's always something new to learn about code architechture. You are a good teacher! Freya is a great gamedev math teacher too.

  • @skizooooooooo
    @skizooooooooo 2 года назад

    from 6:25 on, I'm lost. I can't follow all the jumping around.. I think I get the concept though?

    • @lazysnail145
      @lazysnail145 2 года назад

      He did really poor explaination the reason behind the whole shabang. If you use 3rd party code directly everywhere in your classes, you will have a hard time if say you want replace shapes library with new better shapes which uses different API. So you will have to rewrite all your code. But if you use intermediate wrapper class to access 3rd party api, you need just update the code in this class.

  • @codersexpo1580
    @codersexpo1580 7 месяцев назад

    Are you no longer doing videos and supporting your patron site? Looks like its been a long while since you've graced us with your wonderful vids my friend.

  • @asliniarayanadam
    @asliniarayanadam 2 года назад

    Man, great content again!
    You should continue to UniRx too!

  • @juicedup14
    @juicedup14 2 года назад

    I'd love more code reviews :)

  • @Qupear
    @Qupear 2 года назад +1

    Found this video helpful. But I have a little suggestion for you to think of - can you change a color theme of an editor a bit? I mean, use some more contrasted one. Or maybe be zoom in a little.

  • @FoxApo
    @FoxApo Год назад

    Another amazing channel to sub!

  • @itsonemole
    @itsonemole 2 года назад

    Pls do observer pattern next !! BTW loved your video ......

  • @KonradGM
    @KonradGM 2 года назад +1

    what happened to this channel and the website? last conent was few months ago and it was done after the joining annoucement? whats going on?

  • @cjwang1121
    @cjwang1121 2 года назад

    I wonder what the font and syntax color palette you're using. It's beautiful and well readable.

  • @davestomper3428
    @davestomper3428 2 года назад

    Great video Very confused by all of this more of an art guy trying to learn to code. But it seems like a complex way to make a minimap from other videos I have seen. Still gave it a thumbs up though

  • @ivanherrera5059
    @ivanherrera5059 2 года назад

    Your channel should have a million subs now.... what happens with RUclips!!!?

  • @neither9318
    @neither9318 2 года назад

    Hi sorry its kinda irrelevant but whats the music at background around 5.00 also great content Cheers!

  • @gameShu_Yaksha
    @gameShu_Yaksha 2 года назад

    Can Facade pattern only be used for interacting with complex libraries or are there any other use-cases?

  • @Mackelashni
    @Mackelashni 2 года назад

    Thanks, tis was awesome

  • @uchihai_a_h4871
    @uchihai_a_h4871 2 года назад +2

    Well, I call it wrappers. Never studied design patterns but I intuitively use many...

    • @gasparweb
      @gasparweb 2 года назад

      The whole video is a wrapper! I mean, fancy levels and scrips, but if you cut the cream, all it is about is just a function wrapper. Most videos from this channel are like these. Smoke and mirrors mostly. A few real, interesting or refreshing bits of info.

    • @uchihai_a_h4871
      @uchihai_a_h4871 2 года назад +2

      @@gasparweb Well, I can't complain about that as he is trying to help community and these videos are free.So, I don't have much expectations....

    • @gasparweb
      @gasparweb 2 года назад

      @@uchihai_a_h4871 On the other hand, Tarodev videos are straight to the business, and contains meaningful information.

    • @uchihai_a_h4871
      @uchihai_a_h4871 2 года назад

      ​@@gasparweb Well, the dude has started recently only and still full of gasoline...
      things tend to get slow as time goes but I hope he never does :)

  • @veaarthur3655
    @veaarthur3655 2 года назад

    newsletter link is broken

  • @jeremiahmcelroy2726
    @jeremiahmcelroy2726 2 года назад +1

    The Facade Pattern aka actually using object oriented code.

  • @jugibur2117
    @jugibur2117 2 года назад

    Great explanation, thanks!

  • @RaonCreate
    @RaonCreate 2 года назад

    Nice video! What about your course? Is it coming soon?

    • @InfallibleCode
      @InfallibleCode  2 года назад +1

      Yes! We're working on it, just had to slow down for a bit since Charles just had a baby. He'll be back at work next week and we'll pick up production again. We'll give an announcement soon when we can commit to a release date. - Matt

  • @JonHuhnMedical
    @JonHuhnMedical Год назад

    Isn't this the same as a wrapper?

  • @Elenthiriel
    @Elenthiriel 2 года назад

    high quality video

  • @mrvastayan
    @mrvastayan 2 года назад

    the continue to website button after you subscribe to the newsletter takes you to a broken site

  • @MarekNijaki
    @MarekNijaki 2 года назад

    Great video

  • @sigmareaver680
    @sigmareaver680 2 года назад

    I watch Freya's RUclips channel sometimes. She is quite good at explaining shaders. I originally found her by her video about bezier curves which was really well done.

  • @ithappystore
    @ithappystore 15 дней назад

    Your channel is a perfect match for our Megacity Low-Poly Asset Pack! Check your inbox - we’d love to discuss a collab with you!

  • @manzell
    @manzell 2 года назад

    Heads up your website is down

  • @gustavoaraujo8710
    @gustavoaraujo8710 2 года назад +1

    go freya!!

  • @asadickens9353
    @asadickens9353 2 года назад +1

    All my life i’ve HATED 3rd party libraries and i would try to rip them out or put them behind what I call a “framework wrapper”. Now i know that is called the Facade Pattern!
    My favorite thing about it is the ability to keep your interface in your project but swap out the implementation! 1 place to update, instant removal of 3rd party asset.

  • @serekqwerty
    @serekqwerty 2 года назад

    So basically, the Facade Pattern is a way of implementing S from S.I.M.P.L.E which is best fit for external codebases. Cool

  • @andersencastaneda6080
    @andersencastaneda6080 2 года назад +1

    Moving the code from one file to another file is not a structural change.

  • @SasoriSoft
    @SasoriSoft 2 года назад

    my story with a facade pattern. I want to try a new design pattern with his new game...
    after a few lines of codes and scripts...
    yup did the new design pattern.... as a facade

    • @LeoLFerraz
      @LeoLFerraz 2 года назад +1

      Those are certainly words...