YouTubevideo· Jun 28, 2024· 7:40· 1,300 views on YouTube

Don't Make Me Think

Watch on YouTube ↗
0:00

React at a moment you like. The best moments light up here.

transcript

19 moments
  1. hey there and welcome to the first episode of learning driven development this is a brand new series and a podcast where I get the incredible opportunity to read learn and then share with you articles blogs documentation or other written forms of content that I come across in the technical

  2. space today we are reading an article called don't make me think by Maxi Ferrera that's at charka CCA on Twitter SLX and this blog post can be found at frontends scale.com so frontend

  3. scale.com so this is don't make me think by Maxi Ferrera at the end of this episode I'll share my observations and thoughts about this article and just overall what I learn and what I want to apply after reading this don't make me think cognitive load cohesion Simplicity micro front ends naming things and how selfishness is the key to good component design published by Maxi on October 22nd

  4. 2023 back on issue number one of the newsletter we were so young we talked about the causes and symptoms of complexity and their importance to the overall health of your codebase one of the symptoms we discussed is cognitive load which is the amount of information you need to keep in your head at a time to make a change my advice for reducing

  5. cognitive load in your codebase was to keep your modules cohesive with which sounds great and all but also what does it even mean I owe you a more detailed explanation so today's issue is all about cognitive load and what cohesion has to do with it in the famous words of every PM you ever worked with let's doubleclick on that cohesion and

  6. cognitive load let's start with an example imagine a file uploader component that is responsible for surprisingly uploading files but also valid file types and checking user permissions some users can't upload files at all others can only upload certain file types and so on

  7. now imagine we need to change the validation rules to add a new allowed file type there is no sign of any validation logic in the file uploader component so we put our detective hat on and start looking for Clues to find where we should make our change in our example codebase there's an API SE service that handles Network requests including requests to the file uploading endpoint this sounds like an appropriate place to put file validation so we follow that path then we discover that

  8. permissions and validation are handled by different modules that call each other as part of some complicated logic so we need to follow those paths as well after a while we find all the different places we need to change to add our new validation Rule and we're able to finish our task but we paid a high cost for it the change took longer than it should have and we ended up feeling exhausted from having to put together this puzzle in our heads this is what high levels of

  9. cognitive load feel like jumping from module to module until we finally find the place or more likely places where we need to make our change at each step we have to make sense of the module we're currently looking at load all of its logic in our heads and figure out where we should go next there are many ways to reduce cognitive load but one that would work particular well for this example is to declare the file type and permissions

  10. relationship closer to the component that cares about them in practice this could look like a simple map for example const validation rules as an array with an extension and allowed to parameters data structure representing our validation and permissions rules could look like this this doesn't simplify the relationship between our services in any way but it does wonders for reducing cognitive load but we might still have

  11. some complicated logic between our different services but now we don't need to concern ourselves with it we can now declare our updated rules without having to load a bunch of information in our heads for example changing the validation rules is much easier now we don't need to think about the complicated logic powering this feature

  12. our updated design is simpler because it's more cohesive things that belong together are together by bringing the file type validation and permissions closer to the file uploader component we're bringing the file uploading concerns of our application closer together which makes them easier to think about we've also made our design more declarative the file validation and

  13. permissions relationship was previously represented as a bunch of complicated logic now we've replaced that relationship with a simple data structure which is both easier to change and easier to understand than any action or operation making things cohesive isn't as always is as simple as in this example so here are a few other things you can do to reduce cognitive load use

  14. descriptive names understanding what something is or does by simply looking at its name is one of the best ways to reduce cognitive load naming things is hard but it's worth spending a bit of extra time to come up with a good one write good comments don't write comments that repeat the code but use them to explain relationships and decisions you've made when naming isn't enough use comments to describe complicated logic in simple terms document highle decisions if what

  15. you need to explain doesn't fit in a code comment or if it spans multiple modules it's a good idea to spin up a quick document explaining the tricky parts of the implementation reducing cognitive load is an effective way to simplify your codebase but more importantly it can be a significant quality of life Improvement for the people who work in it it takes time and

  16. discipline but it's definitely worth the investment don't make the users of your codebase think too much remember this includes both your team and your future self and they will certainly thank you for it one of the things that I really enjoyed about this particular article is

  17. that it was titled don't make me think because I think that is exactly what you need to do in order to make components and a code base and an architecture of an application even better if you think less about how it all works if you think a little bit harder and even less about what the actual program and architecture

  18. and specific components do within the application then you just make things easier it's a simple concept of overthinking if you don't actually overthink how a component works or overthink if this component is ever getting too large or ever overthink what this component actually does and how we should name specific pieces of of that component that's overthinking and in fact making you think harder in the future so the easiest way to not think harder in the future is to don't overthink it now so don't think things

  19. through too much in the now when it comes to building out an application a lot of times when I'm building out products or features within a product one of the things I love to do is start to extract that into a different component or a different naming architecture once it gets to a point where if I'm jumping back into it I don't know where I'm at so don't think too hard about it so that you don't have to think too hard in the future \[Music\]

just you here