The Flyweight Pattern

Поділитися
Вставка
  • Опубліковано 15 кві 2021
  • The Flyweight Pattern lets you have your cake and eat it - at least in software terms.
    Source code available at: github.com/JasperKent/The-Fly...
  • Наука та технологія

КОМЕНТАРІ • 10

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  3 роки тому +1

    So many patterns. Which ones do you use most?
    Source code at: github.com/JasperKent/The-Flyweight-Pattern
    Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
    And if you liked the video, don't forget to click the button.

  • @VindicatorMorty
    @VindicatorMorty 3 роки тому +4

    Nice so its a kind of recycling. Did you tried some stress testing with a high count of items? I am curious how the performance would improve.

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  3 роки тому +2

      Performance is always going to depend on the specific circumstances. The example is to simple for any benefits to really show. It's worth noting that as well as the memory benefit, there can also be a performance benefit, since reference comparison can be used as a quick check as the first stage of value comparison.

    • @davidwhite2011
      @davidwhite2011 3 роки тому

      @@CodingTutorialsAreGo Not you specifically but it seems like most c# tutorials that suggest speed improvements don't use big datasets. Think about using /bchavez/Bogus (github) great faux data creator so we can see a scaled version and see the performance increase. BenchmarkDotNet then is like unit tests for performance testing.

  • @belugaaa6649
    @belugaaa6649 2 роки тому +1

    Waiting for more design patterns.

  • @Schnickalodeon
    @Schnickalodeon 3 роки тому +2

    Thats another very good Video. I have to try this Pattern in future Projects.
    Could you please make a video about the Repository and UnitOf Work Pattern?
    Sidenote: If I am not wrong you don't need the "else" Statement because if the item is found you return it immediately.

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  3 роки тому +2

      The use of else there is purely a matter of personal style. I prefer it because it keeps the code symmetrical.

  • @rustamhajiyev
    @rustamhajiyev 3 роки тому +2

    Thank you for the video! Can we say that flyweight pattern and cache are the same things?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  3 роки тому +2

      There are similarities, but they're not exactly the same.
      The purpose of a cache is to store things in memory in order to save repeatedly loading them from a slower data source (such as a database). But a cache doesn't necessarily do anything to merge identical objects.
      Flyweight does not have two separate levels of storage.
      The two can quite commonly be combined.

    • @rustamhajiyev
      @rustamhajiyev 3 роки тому +1

      @@CodingTutorialsAreGo Ok, now I get it. Thanks!