How billionaire Charles Munger fixed my Angular app

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I recently found myself reading Charlie monga's poor Charlie's Almanac and it ended up being one of my favorite reads in a while it included a translated quote from 19th century mathematician kuk Corby which was invert always invert and it was this exact mindset that ended up solving a state management problem I had in my application recently the essence of this strategy involves flipping the problem on its head and that may reveal different ways to think about the problem or different ways to approach it an example given is that proofs by contradiction in mathematics when trying to prove that the Square < t of 2 is irrational we can invert the problem and sort of approach it backwards we can assume that the square < TK of 2 is rational and then show that that is impossible if we can prove that it is impossible for the squ < TK of two to be rational then we have also proved that it is irrational this can be useful in a range of disciplines outside of mathematical proofs but let's see how this thinking helped me in a programming context to solve my Estate Management problem first we'll need some context on how I go about structuring my applications I have a full video on this approach so I'll link to that if you are interested but there are just a few important things to know for the sake of this video I generally have a folder for each of the features in my application inside of these feature folders there will be a file for the main feature component and three additional folders data access UI and utils the data access folder contains any data fetching or State Management stuff the UI folder contains additional dumb components the feature uses and utils contains things like helper functions so this is where my problem begins I have this dashboard feature and in the data access folder I have a state service that manages the state for this feature since this service is contained within this dashboard feature it should not be shared with any other feature in the application and it is only provided specifically to this dashboard component feature through angular's dependency injection system if I wanted to share this state service with other features then it would live in the shared folder and it would use angular's dependency injection system to provide that service globally but the problem occurred when I wanted to create this word service which would be shared globally but this word service needed to use a small part of the state from the dashboard State service thinking through this problem in a normal that is to say non inverted way I came to two obvious Solutions one move the dashboard State service to the shared folder and provide it globally or two keep the dashboard State service where it is since its primary purpose is still to manage the state of this feature but provide it globally from that folder so that the word service can still access the state it needs neither of these Solutions are particularly good the first option breaks collocation of related code and the second disregard regards rules of the architecture I'm using the problem I am facing here is that word service has a dependency on the dashboard State service but what if we invert this problem what if we flip the dependency and see what things look like if the dashboard State service has a dependency on the word service instead we take the state that the word service needs out of the dashboard State service and have it live in the word service instead the dashboard State service can then depend on and inject the word service to access that state which is fine because word service is shared globally this just immediately fixes the problem in a clean way now the dashboard State service remains entirely private and local to the dashboard feature and the word service has access to all of the state it needs the solution is almost blindingly obvious in hindsight and I think that highlights the power of this always invert concept we can get stuck in particular ways of thinking and it can help us see problems from a totally different perspective if you like this video consider inverting the state of the like or subscribe button before you go and I hope to see you back here for the next one
Info
Channel: Joshua Morony
Views: 7,456
Rating: undefined out of 5
Keywords: tutorial, tutorials, coding, coding tutorials, angular, angular tutorials, mobile, mobile apps, apps, html5, ios, android, hybrid, web apps, progressive web applications, programming, performance, ui, ux, animations, screencast, rxjs, nx, ngrx, architecture, signals, advanced
Id: zSrIhla0svQ
Channel Id: undefined
Length: 4min 14sec (254 seconds)
Published: Wed Jun 12 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.