The #1 Way To Get Better At Programming

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.ค. 2024
  • Strangler Fig, Introducing Seams and Wrap Method are just some of the refactoring techniques that will help you level up your code and help you start to think in Systems, identify where to use Patterns and uphold the Principles of Software Engineering in your Games. We're revising Stats and Modifiers to add optimizations and new features suggested by the community!
    Last week's video for reference: • EASY Stats and Modifie...
    Want to support me? 😀
    Buy me a coffee! ko-fi.com/adammyhre
    🔔 Subscribe for more Unity Tutorials / @git-amend
    Discord: / discord
    #unity3d #gamedev #indiedev
    ▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
    0:00 Rules of Refactoring
    1:20 Strangler Fig
    2:04 Refactor 1: Linked List to List
    7:22 Introducing Seams
    7:55 Refactor 2: Stat Modifier Factory
    11:35 Refactor 3: Operation Strategy
    15:00 Refactor 4: Operations in Order
    17:17 Wrap Method
    20:00 Refactor 5: Caching
    Source code: github.com/adammyhre/Unity-St...
    Assets Shown In This Video (Affiliate Links)
    Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
    Tiny Heroes: assetstore.unity.com/packages...
    Hierarchy Icons: assetstore.unity.com/packages...
    Better Transform: assetstore.unity.com/packages...
    Better Mesh Filter: assetstore.unity.com/packages...
    Kyeoms VFX: assetstore.unity.com/publishe...
    Pure Nature 2 : Mountains: assetstore.unity.com/packages...
    HIGHLANDS - Stylized Environment: assetstore.unity.com/packages...
    Damage Numbers Pro: assetstore.unity.com/packages...
    Follow me!
    linktr.ee/gitamend
  • เกม

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

  • @git-amend
    @git-amend  2 หลายเดือนก่อน +8

    Happy Sunday!!! Let me know YOUR pain points are when it comes to refactoring your own code (or someone else's) in the comments below! 👍

    • @MarushiaDark316
      @MarushiaDark316 2 หลายเดือนก่อน +2

      One of my biggest pain points is not doing it sooner and waiting for scope creeps to kick in and leaving a bigger mess to untangle.

  • @SuperLordee
    @SuperLordee 2 หลายเดือนก่อน +11

    This channel is pure gold. I am using Unreal and not Unity but I still learn a lot by watching your videos!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +2

      Great to hear!

  • @echoness_
    @echoness_ 2 หลายเดือนก่อน +3

    Thank you! This is so valuable! Have been working on a project that structures are super chaotic and very hard to read, knowing how to refactor is a life changer.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Great glad to hear that!

    • @echoness_
      @echoness_ 2 หลายเดือนก่อน

      @@git-amend Also thank you for recommending the book!

  • @daniel3dart
    @daniel3dart 2 หลายเดือนก่อน +1

    This channel is amazing! Please keep all of it coming.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thank you! Will do!

  • @publicmmi
    @publicmmi 2 หลายเดือนก่อน +1

    Thanks for the very nice video! Now its the perfect time to make a video about Unity Tests :)

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Haha! We’ll see!

  • @EmreSezer6666
    @EmreSezer6666 2 หลายเดือนก่อน +2

    video on procedural level generation would be great. Thank you for the great video btw.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Great suggestion! Thanks!

  • @Fitz0fury
    @Fitz0fury 2 หลายเดือนก่อน

    Thanks for this one it will help ppl alot. Since you showed me strangler fig earlier this week i sliced 4 systems out of my prototype manager class!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Excellent! I’m glad it’s helping!

  • @prometheus1100
    @prometheus1100 2 หลายเดือนก่อน +3

    Great video! I once again learned a ton. If you would ever consider writing an (e)book explaining software architecture principles in the context of Unity, I'd buy it in a heartbeat ;)

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Great suggestion! Maybe one day!

    • @lee1davis1
      @lee1davis1 2 หลายเดือนก่อน +1

      Ditto!

  • @ragerungames
    @ragerungames 2 หลายเดือนก่อน

    Yay, finally a new video! I don't know if it's just me, but I eagerly await Sundays for Git amend videos...

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks!

  • @KyleWithAnM69
    @KyleWithAnM69 2 หลายเดือนก่อน +1

    How long have you been programming for? You're very articulate with the way you speak. Very valuable content!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Thank you! I've been a career software engineer my entire adult life, which has now been more than 2.5 decades, but I actually wrote my first program about 10 years before that.

  • @ryaz4704
    @ryaz4704 2 หลายเดือนก่อน

    This is... brilliant. Thanks a lot.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      You're very welcome!

  • @V-post
    @V-post 2 หลายเดือนก่อน

    If you haven’t already, a video on unit tests would be great.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      I have this video here you might like, it's an introduction to unit testing: th-cam.com/video/Wh27sG0DXzU/w-d-xo.html

  • @Hersatz
    @Hersatz 2 หลายเดือนก่อน +1

    Always be cautious with wrapping.
    It always look like a dirty easy fix as we "only" need to add logic on top of existing logic and maybe make some fields protected and whatnot, but in the long term it over complexify everything.
    I had to wrap a whole lot of non-networked classes into networked classes once to not break offline parts of an app and, let me tell you, it was not a fun time to refactor and orient oneself into the whole project afterward.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks for sharing your experience! I'm sure those words of caution are warranted.

  • @zafercelik2955
    @zafercelik2955 2 หลายเดือนก่อน

    A solid economy system for next video would be awesome!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks for the idea! Maybe not next week, but I'll put that on the list.

  • @Ironlionm4n
    @Ironlionm4n 2 หลายเดือนก่อน

    This is exactly what I needed..

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Fantastic!

  • @bachhoang9004
    @bachhoang9004 3 ชั่วโมงที่ผ่านมา

    amazing video, keep it up

    • @git-amend
      @git-amend  3 ชั่วโมงที่ผ่านมา

      Thanks, will do!

  • @tst2648
    @tst2648 2 หลายเดือนก่อน

    This is fantastic! Any recommendations on which strategies to use to apply limits to the stats (defense maxes out at a value for example) or entirely skip modifiers (some debuff temporarily omits attack bonuses for example)?

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Good question. I think there are a few ways to go about all of those things. I think it really depends on the game, but you might - for simplicity - just clamp them before returning each property in the Stats class getters. But of course, any upper limit might very over time or as the game progresses, so that might involve another strategy that could be handled by the Mediator as well.
      I think more complex scenarios might require another refactoring, and I'd have to give it a bit of thought before introducing any changes.

  • @migueldc6845
    @migueldc6845 2 หลายเดือนก่อน

    git-amend MVP

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thank you!

  • @simonnordon8421
    @simonnordon8421 2 หลายเดือนก่อน

    Something I've been learning the hard way. It is MUCH easier to write bad code, then refactor it, then it is to write 'good code' from the start. I spent 5 hours rewriting the same movement script. I should just make something that works and come back to it later.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      I hear ya on that one! 💯

  • @beyondray70
    @beyondray70 2 หลายเดือนก่อน

    Hello! Thank you so much for your videos, I would like to know your list of books that I should read to improve my skills, I would really appreciate it!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks! If you join the Discord and go to the programming channel there is a pinned comment with my list of recommended books to read from beginner to advanced!

  • @TheKr0ckeR
    @TheKr0ckeR 2 หลายเดือนก่อน

    Great video as always, do you plan to record a generic UI Manager or UI / Popup management? I think this topic is a problem for a lot of game devs to manage them in a generic / modular way.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Possibly - can you have a specific scenario in mind?

    • @TheKr0ckeR
      @TheKr0ckeR 2 หลายเดือนก่อน

      ​@@git-amend For example I am creating a popup manager where we access popups by dictionary, But i couldnt decide which way i should create the KEY. For now, I created the dictionary as which we give type in generic and get the popup. The problem is if we have same popup classes with different prefabs, it wont be able to register since the type is already added to dictionary. So how can i identify which popup I want as best practise/generic way? Should i pass a custom struct that includes Type and id variable, but then it will be kinda hard to find my popup from where i get, i need to give struct params and search my key list and find the required one. ENUM way is kinda bad for me too. What do you think about that
      ```cs
      private readonly Dictionary _popupMap = new Dictionary();
      public T TryGetPopup() where T : BasePopup
      {
      if (!_popupMap.ContainsKey(typeof(T)))
      {
      Debug.LogWarning($"Popup {typeof(T)} is not registered.");
      return null;
      }
      return (T) _popupMap[typeof(T)];
      }```

    • @TheKr0ckeR
      @TheKr0ckeR 2 หลายเดือนก่อน

      @@git-amend I am creating a popup manager where we access popups by dictionary, But i couldnt decide which way i should create the KEY. For now, I created the dictionary as which we give type in generic and get the popup. The problem is if we have same popup classes with different prefabs, it wont be able to register since the type is already added to dictionary. So how can i identify which popup I want as best practise/generic way?
      private readonly Dictionary _popupMap = new Dictionary();
      public T TryGetPopup() where T : BasePopup
      {
      if (!_popupMap.ContainsKey(typeof(T)))
      {
      Debug.LogWarning($"Popup {typeof(T)} is not registered.");
      return null;
      }
      return (T) _popupMap[typeof(T)];
      }

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      @@TheKr0ckeR Ok I see, I'll give that some thought. As to your comments being deleted, I can see one that is being held for review but I'm not sure why... it doesn't seem inappropriate!

    • @TheKr0ckeR
      @TheKr0ckeR 2 หลายเดือนก่อน

      @@git-amend I think passing string ot enum is the fastest way though i am not sure its the best way

  • @user-rm2pj9jf8s
    @user-rm2pj9jf8s 2 หลายเดือนก่อน

    I think it's amazing. I'm a beginner who does implementations mostly in singletons, and I learn there are these ways by looking at your code.
    I'm curious, do you build all the architecture from scratch and implement the game?

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +2

      Thanks! Like most people, I start with a simple prototype. Then I have a better idea of how to structure a project. Then I just continue to iterate and refactor.

    • @user-rm2pj9jf8s
      @user-rm2pj9jf8s 2 หลายเดือนก่อน

      @@git-amend oh.. very difficult process. It's amazing that a skilled person like you is still like that.
      While watching your lecture, I am also revising the Stat system,I'm surprised to hear that you're also starting with a small project.

  • @mohamadkh221
    @mohamadkh221 2 หลายเดือนก่อน

    💥💥💥💥

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks!

  • @halivudestevez2
    @halivudestevez2 2 หลายเดือนก่อน

    Engeneir's first rule: if it works, do not touch...

  • @Strangertoyourlife
    @Strangertoyourlife 2 หลายเดือนก่อน

    Me and colleague had to refactor a single script for a client that held the logic for the ENTIRE app. It was also 3 methods, one being a 52 else if statement that did different things depending on the name of the button being pressed (did a string compared) T-T

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Hahah... sheesh.

  • @silchasruin4487
    @silchasruin4487 2 หลายเดือนก่อน +1

    I may have been doing some of this without knowing the official terms for it and I have had painful experience with refactoring too much at a time, losing way too much because what you thought was inefficient or pseudo code contained the logic for something else that you really needed. Also I think proper documentation is required even for your own code. Coming back to it after a while can have you hunting through your code trying to make heads or tails as to what you were doing. Just my experience.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      Thanks for sharing. I agree, documentation is an essential part of development.

  • @damonfedorick
    @damonfedorick 2 หลายเดือนก่อน

    Nice.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Thanks!

    • @damonfedorick
      @damonfedorick 2 หลายเดือนก่อน

      @@git-amend Congrats on 9K.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      @@damonfedorick Thanks! Been a very interesting journey so far, and not long until the channel will cross that 5 figure number!

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

    Is there anyway i can support you? Because your content is incredibly useful

    • @git-amend
      @git-amend  หลายเดือนก่อน +1

      Sure, there is a link to my Ko-Fi page in the video description! Cheers!

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

      @@git-amend Supported! Also, have you thought about doing anything on VR/AR in Unity?

    • @git-amend
      @git-amend  หลายเดือนก่อน +1

      @@AriyaBayat I have a little bit, but I think I might try to combine it with techniques that are a bit more general. Another viewer asked me a while ago to do a video about Lionhead Studio's Black and White magic system which relies on pattern matching. This is actually very similar to a project I made a while back to help people learn languages like Korean and Japanese in VR, by pattern matching movements. So, it's a technique that applies to VR and normal games. Not sure exactly when yet, but it is on my list.

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

      @@git-amend Cool I just checked it out now, and man those creatures look goofy 😂
      But that's cool and the VR tech looks ahead of its time. I'm only asking because it seems that Unity is doubling down on all the XR stuff and I'm sure these optimisation techniques are still applicable for those kinds of projects like you say

  • @wesplybon9510
    @wesplybon9510 2 หลายเดือนก่อน

    Rule #4 is "Yes, you should be unit testing" 😁

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      💯

  • @mohamadkh221
    @mohamadkh221 2 หลายเดือนก่อน +1

    Do you have a plan for teaching ECS?

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      Yes, one of these days when time permits.

  • @NghiaTran-pg1is
    @NghiaTran-pg1is 2 หลายเดือนก่อน

    I can see you have integrated Copilot deeply in your workflow, how was the experience so far? And can it replace a junior dev rn:)) just ask for fun, this kind of question appears 10 times a day on my Reddit newfeed

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      I suppose it could replace a Junior, but it really depends. Like a Junior, it makes a lot of mistakes, and it cannot abstract solutions to large complex systems.

    •  2 หลายเดือนก่อน

      @@git-amend IMHO the purpose of a junior is not to write code so much as to grow into a senior. Hopefully, copilot will make this process quicker and more painless, but there is a risk that it prevents learning by doing things "the old-fashioned way". I'm currently hopeful though!

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +1

      @ I agree completely!

  • @MarushiaDark316
    @MarushiaDark316 2 หลายเดือนก่อน

    Since you brought up unit tests - do you have a video on that already? I don't really understand the purpose of them as opposed to just playing through your game. "If an error occurs and no one's around to see it, is it really an error?"
    To me, the idea of unit tests seems like doubling the workload for no real benefit, but more advanced devs keep telling me they're essential. If you don't have a video already, could you perhaps consider making one and explain it like I'm five? As if I've never heard of a unit test before or how it's better than spot testing like how you tested your refactors by walking around in play mode?

    • @SanderDecleer
      @SanderDecleer 2 หลายเดือนก่อน +1

      Just imagine your computer playing through your game very very fast and reporting when things don't go as expected.
      This might seem like double work at first, but when your game gets increasingly larger, testing everything starts to take more and more of your time, so writing tests starts to pay off on the long run.
      It also makes me feel more confident in my code

    • @MarushiaDark316
      @MarushiaDark316 2 หลายเดือนก่อน

      @SanderDecleer Sure but I have to code it to look for specific things whereas I might catch something even I wasn't planning on testing for, and if I can't plan for it, I can't write a unit test for it.

    • @SanderDecleer
      @SanderDecleer 2 หลายเดือนก่อน

      You should absolutely still play your game to find such cases. When you eventually find one, make a failing test for it, then fix it. That makes sure you never need to worry about it again.
      Especially handy in situations where the reproduction is not trivial.

    • @git-amend
      @git-amend  2 หลายเดือนก่อน +2

      There is a video on the channel about Unit Testing, it's in the Architecture playlist, it will help you with getting started if you are interested.

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

      @@MarushiaDark316 the purpose of Unit Test is to make sure what is already passed the test will pass the test again, if not, it will inform you immediately to avoid side effect. There will cases like random bug (hard to reproduce) because chain of side-effect

  • @GameDevBox
    @GameDevBox 2 หลายเดือนก่อน

    Refactoring is the best way you can make your game better even improve your skills. you can't write best when you start

    • @git-amend
      @git-amend  2 หลายเดือนก่อน

      💯