Level Up Your Code: Dynamic Data Processing

preview_player
Показать описание
Today we explore dynamic data processing in code. This typescript code example is pretty similar to a lot of real-life applications, but keep in mind the term dynamic data processing is very broad.

0:00 Ugly Code
0:07 Brief overview
0:42 Pretty Code (all code is beautiful)

#programming #datastructure #codeexamples #typescript
Рекомендации по теме
Комментарии
Автор

pretty good vids!
it's much more nicer if u could tell us about the actual problems first and then the solution, theory, etc after it.
And may be adding before/after of the code too.

wicakradityo
Автор

one last touch i would do to the code is instead of using else, i would guard clause the function. So in the if statement it will return something(for this specific it's appropriate to return null or undefined) and move the console.error after the if

if (...){
...
return null
}
console.error("...")

mcbrincie
Автор

You can make it better by moving local property config to static

microthecat
Автор

1:25 Also more performant since now the time complexity went from O(n) to O(1)

dinhero
Автор

im with you, but I think you only helped half way, by saving the possible configurations in an object you don't need to worried about the if else blocks (where you are right there is no need to do it like that) however you give up on a lot of static checking by doing it like that, what I would recommend is creating an enum for the possible user types (admin editor and viewer) and then also abstract the configurations to some kind of struct/class/trait/interface or something,
then I would do a match/switch on the user type mapping it to the appropriate object
basically my issue is that the problem you are presenting is only caused by representing distinct variants of data in your code as strings rather then within the blocks of the language causing the ugly if else chain, where what you would want whenever possible is to move the the variants to compile time,
think of when you want to add another user type, there will be nothing to remind you to add it in this function also where if you have an exhaustive match, it will become an error at compile time :)

potzko
Автор

What are you using to animate the expanding and contracting code blocks?

lcarsos
Автор

Hey, I really like your animations, have you considered making the code for motion canvas for your animated videos public so that we can learn using the tool😁😁

anshulkumar