as a lead dev, I can only say that you never want to debug such code, which contains 10 small functions, because someone decided to split everything. It is a huge pain to debug such code, because you have to switch context a lot. You have to switch between function, classes, files. Sometimes it is much better just to have one bigger method instead of 5-10 small. Sometimes it is always better to not create an abstraction for every single potential change, because many of them will never happen. For example, it doesn't make sense to create an abstraction for delimiter, because delimiter may never change. But sometimes it makes sense to create such abstraction, haha...that's the hardest part of programming - to find a good balance and write readable not overcomplex code. It is not hard to create overcomplicated code with many abstractions, but the real problem is to create easy readable code for complex solutions.
@RafaeldaSilvaPeres4 ай бұрын
Just like in real life people who can communicate good won't be just randomly spitting complex words that encapsulates bunch of meanings in itself, but will actually know when it is needed to use them, just like when you in a courtroom then maybe it might be a scenario for that or when writting an official document, otherwise, even tho you can say some badass words nobody will understand you, therefore failing to communicate, even tho what you saying makes sense.
@adennis2004 ай бұрын
Thats exactly what my lead keeps saying all the time. We have so much abstraction, that nobody can follow the code anymore. Debugging is so hard and take up too much time. You should not abstract for abstraction-sake.
@edmel1443 ай бұрын
As a novice programmer I find too little abstraction is way worse than too much. At my level (finance job vba and Python) people just out everything in one procedure. I think if you have little experience you should abstract until you release you’ve got too far, then dial it back, otherwise you will never know where the line is. Though I am coming from a consideration as programming as a skill all can use in their everyday job, rather than professional devs working on enterprise software.
@sanglin93873 ай бұрын
you can fight the trend . kinda ugly people teach abstraction
@TheIllerX2 ай бұрын
@@edmel144 Yes, you can do both too much and too little abstraction. Beginners typically do almost no abstraction and mid devs are sometimes more prone to do too much. It is a bit like the old saying that if you just got yourself a nice hammer, everything starts to look like nails. Later you realize there are more tools that matter than the hammer. I'm not sure I agree on taking the abstraction too far and then try to reverse it though. It is easier to abstract and split functions apart than going the other way, I would say. Once you have created too many small functions and they are used everywhere in the code, you cannot just remove them without having to refactor a lot of existing code.
@stangeorge68935 ай бұрын
This is what the "elegant mid developer" would do, not a senior. You take a simple function with 2-3 mistakes and create so many abstraction layers it's crazy. You should have stopped at injecting the external deps as params and that's it.
@vigneshwaran92095 ай бұрын
People are in love with abstractions man. They just abstract anything and everything.
@psychoclips68175 ай бұрын
Thank you! So refreshing to hear this from others.
@javier.alvarez7644 ай бұрын
Yeah also realized these having 10 enterprise projects. Abstractions are good in theory, but an overkill and overengineering if no one will actually used it and it is only specific to that context. There are only good to when you rearch the project. Scope and requirements of the project keep changing in the middle of the process.
@ratfuk93404 ай бұрын
Programming is about abstraction. This video is about how to manage abstraction. The results don't have a crazy amount of more "abstraction layers", you're being ridiculous. Also, pure functions are easier to reason about so that part is valid. The issue with the video are the examples: it's pointless to wrap db.saveFormatted(name) into its own function that does nothing but call the method with the parameter. Same for the formatName function, the function for that already exists and it's the strings.TrimSpace function so there's no reason to wrap it unless you really want to rename it for some reason (there are valid reasons for wrapping to rename). In other words, the formatAndSaveName function was actually already consistent with what the video is trying to say, imo. After the changes in the video, all calls to the original formatAndSaveName function have to be replaced with a call to formatName followed by a call to saveFormatted. But it'd be more sensible to just use the original unwrapped library/module functions that have already been tested. And if you do this is many places in the codebase, it's sensible to make a function that does both of them (with the delimiter passed as a parameter) which is what the formatAndSaveName function was (after dep injection). So in that sense, yes, there's redundant abstraction in these examples but nothing "crazy". But let's be more generous in our interpretation: the examples in the video are just that, examples. The principles that they try to convey are totally valid and useful. You just have to be mindful when to apply them.
@Joshuaomorales3 ай бұрын
As expected from someone who do not do unit testing.
@AAntonovG5 ай бұрын
This technique is not a Got-Tier developer, but just a middle-developer who says WOW, looking at the elegancy and beauty of this code. If you look more carefully, you will see, that you just move complexity from one place to some other. This other place is usually is some initialisation code, like main function or DI-container. So you either not test this other code, saying "oh, this is initialisation code, I don't need to test it" or you have absolutely the same problems as the original code. You cannot mock DB, you have to change tests when your behaviour changes. BUT one important thing changes when you apply this famous trick: you brake encapsulation, making refactoring almost impossible.
@Pavel-wj7gy5 ай бұрын
Sad to see this comment not getting upvotes it deserves. Content makers on KZbin are notorious for coming up with sterile examples upon which they try proving a point and, incidentally, revealing that they don't really understand what they are doing.
@Kyle-do6nj5 ай бұрын
Other than "DI/Injection", the rest should really just be called "Compartmentalization"
@privateagent5 ай бұрын
In what language you cannot mock a dB?
@AAntonovG5 ай бұрын
@@privateagent my statement was not about some language, but about the DI-trick, where you move DB initialisation outside of some function. There, outside, you still have to create DB connection and if you like to test this "outside code", you cannot do it, because it creates DB connection and sometimes it is not applicable for unit tests. So you have to mock again, and mock again and it could happen infinitely. At the end of the day you just don't test all your code with DB, you keep it untested. Hope it makes more clear my idea.
@DoDo-uw2no5 ай бұрын
@@AAntonovG Hey thanks for your comment, for my understanding could you maybe clarify why refactoring would be impossible? Also if having the initialisation code in the meson function (or some init function) is not the best approach since you sometimes can’t unit test it. What would be the correct way of handling this situation?
@StanislavStratiev5 ай бұрын
I can't read the code with all this movement :( have a good day.
@Dungeon_Synth_Enjoyer5 ай бұрын
KZbin has a built in pause function. All you got to do is click on the screen. You’re welcome.
@snyp25275 ай бұрын
Or maybe the creator should avoid situations where a viewer has to pause the video every 5 seconds @@Dungeon_Synth_Enjoyer
@user-fed-yum5 ай бұрын
@@Dungeon_Synth_EnjoyerSome people have neurological issues with moving text. That's why, for example, CSS has directives supported by every browser, to reduce motion. Your proposal to pause every so often is naive, unhelpful, and rude. Please educate yourself about accessibility guidelines, ie how to consider people with a range of disabilities, before you write any client side code.
@Yooper_eh5 ай бұрын
@@Dungeon_Synth_Enjoyer Sorry, that's not the point. While the animations are very entertaining and flashy, you lose focus on what is happening. Just taking out the old and replacing it from various directions is distracting. If an element is removed just to be re-inserted in another place, it is better to just have it move from where it started to where it needs to be. Pausing the video just freezes all the elements out of position. A better approach is a side-by-side or over-under comparison.
@Yorgarazgreece4 ай бұрын
@@Dungeon_Synth_Enjoyer yeah that's rather dumb argument. i shouldn't have to pause every 5 secs and even miss the thing because final code stays for less than 1 sec on screen. Also pausing loses train of thought.
@y3t_2 ай бұрын
i was watching this during commute and the background music made me cry in the bus
@kantancoding2 ай бұрын
😂 my bad. I didn’t realize how sad the music was when I made this. Maybe I was just in a sad mood.
@pokefreak21125 ай бұрын
that func saveFormatted is a bad idea it doesn't do any formatting and just saves the raw input, so if your API consumer doesn't format first you now have incorrect data in your db. should've called it saveUnsanitized if that's what you really need, or just call it saveFormatted and implement as db.save(format(name)) that way the format function is still testable but any data inserted into the db using your api is also formatted
@LawZist5 ай бұрын
Its only a simple example for the video you know right?
@kazmi4015 ай бұрын
@@LawZist If it is only an example then what is the meaning of title "God-Tier Developer"
@LawZist5 ай бұрын
@@kazmi401 by showing you a simple example to teach someone a new skill that will get him one step further to be a god tier developer, or maybe it is just sound good and get more traffic and likes because its sound better.
@Tinker775 ай бұрын
The name of saveFormatted is fine. The name saveFormatted implies that what is being saved is already formatted. It isn't named formatAndSave, or processAndSave, etc. The fact that it uses the past tense of Format (Fromatted) specifies in plain English that the function ... saves something that has been previously formatted . Now I would be a little more wordy in my function name to something that describes WHAT is being saved, such as saveFormattedFullName.
@ratfuk93404 ай бұрын
The format function is just a wrapper around a library function it seems. The library function is definitely already tested too so really the only reason to wrap it is to rename it. var fname = ... var lname = ... var delim = ... var name = strings.TrimSpace(fname, delim, lname) db.save(name) I don't see the reason to rename an already existing API that has the same properties: TrimSpace is pure (at least I assume so, otherwise the example in the video isn't either), and since the first and last names, and the delimiter is defined in the same scope as the call, there's no issue. And then if you really want, you can wrap that last two lines which would be what the video has after changing the delim to be a parameter but before wrapping the save and format functions. Imo bad example in the video but good principles.
@draakisback2 ай бұрын
While these ideas are fine in the abstract, they can truly get out of hand in real world examples. I can't tell you how many code bases I've worked on that tried to follow the solid or clean code principles only to end up so far in the abstract that they kind of lose the entire point and become way too complected. My rule of thumb is to just try to make my business logic as pure as possible but only within reason. If I find that the code is ballooning because of some abstraction that I've added, then usually it's not worth the pain. You also have to be aware of how much overhead you're adding to your program. Dependency injection can be really expensive depending on the dependencies that you are injecting into your functions/classes.
@Nellak20115 ай бұрын
@Kantan Coding Lovely video, I think the three patterns you chose are indisputably good. Unfortunately, it seems most of the comments are ignorant and don't know what they are talking about. Keep up the good work and great animations!
@kantancoding4 ай бұрын
Hey! Thanks for the feedback. I encourage discussion even if people disagree with me! So it’s a good thing imo. Maybe we can change their minds 🙂
@nerewan5 ай бұрын
single word: "incapsulation" u shouldn't pass so many parameters into yr method, but u could pass them over class constructor, it's more readable and easily to maintain
@nerewan5 ай бұрын
@@edmunns8825, oh, thanks, dude! I was totally sure that it is "in" as "in something" 😅
@anho-uw2vt4 ай бұрын
But the video is about functions not methods or functional programming not object-oriented programming. So the video title should more be like "coding techniques for functional programming"
@ratfuk93404 ай бұрын
Hell no lol.
@ShadowKestrel5 ай бұрын
I love how zig takes dependency injection to such an extent that memory allocation is passed into any functions that need it (in the form of an Allocator struct)
@benjaminblack915 ай бұрын
Better than implicitly passing around some global variables like in malloc.
@ianokay5 ай бұрын
Fantastic video, simple, well explained, and accurate. Also not trivial or straight forward, despite being simple, which is a great combination. Thank you for your efforts
@kantancoding4 ай бұрын
Thank you for watching!
@Rtzoor5 ай бұрын
to much animation. going back and forth multiple times was making it hard to keep track, because you expect a forward progression, but then be pulled back unexpectedly, then forward again, you quickly lose the sense of knowing what to expect. furthermore, the second and third techniques were glossed over compared to the first one, which feels imbalanced and incomplete. however, the overall structure was well, as well as the individual animations, and the examples as well. im sure some minor changes will make the production quality even better. it seems like you forgot to account for how the audience will process the content, getting absorbed in your own understanding, which is a very common pitfall. all that aside, i am looking forward to the next one!
@kantancoding5 ай бұрын
Thank you for this! It really helps 🙂
@MaxPicAxe5 ай бұрын
Very well put together video and I really like the power the music brings. I think the animations were a bit excessive especially when watching at 2x speed but other than that it's perfect.
@kantancoding4 ай бұрын
🤣yeah maybe you are right about the animations being excessive. I will tone it down in the future. But anyways thanks for taking the time to give feedback that is actually helpful.
@mochadwi5 ай бұрын
i really love the animation, giving me more clarity, thanks!
@bjni5 ай бұрын
im living in Japan trying to become a golang backend dev, cool that you focus on golang
@FernandoLeonRamos5 ай бұрын
these videos are so good. already knew it but damn. i wish i was a noob watching these
@omegand.5 ай бұрын
Your style of editing is so good...
@coladock5 ай бұрын
Nope, hard to read the codes...
@AlfredLotsu5 ай бұрын
Keep going King, more examples please
@malmiteria4 ай бұрын
5:00 no offense but creating a function called saveFormatted that has the only responsibility to call ... saveFormatted... huh?! such a junior mistake. You already have a function that does the job, call it, that's it. No need for an extra function that exclusively calls the function you wanted in the first place. Same for splitting formatAndSaveName It only makes sense because you completely ignored the "call" side of those function, and unquestioningly consider any side effects to be bad. Everywhere you called that function, you now have to call both format and save, which both makes it a huge source of bugs, by making it easy to forget one of them, and completely misses the point of API abstractions. Not only that, but the fact is, you'd *have* to call them both everytime or so, making the idea of separation of concerns really not apply here. Formatting and saving are really really really related concerns, not separate, when your task is to format and save.
@mhouney3 ай бұрын
I like these kind of videos. Very informative! How do you animate these videos?
@kantancoding3 ай бұрын
Thank you! And thanks for watching. As for your question, I can’t really explain it in a comment. It’s not like there’s one tool that produces a good video. I use many tools to try to make the videos as engaging as possible.
@Icewind0075 ай бұрын
Great video and style! Although, it's so relaxing I almost fell asleep.
@kantancoding4 ай бұрын
😂
@TannerBarcelos5 ай бұрын
These concepts are important across all languages, but something about Go makes it all so elegant and easier to understand. Awesome video.
@anho-uw2vt4 ай бұрын
Only if you are following a functional programming style. In object-oriented programming, you don't pass in that much parameters.
@Joshuaomorales3 ай бұрын
The developers who are complaining about the amount of abstractions in this video are those who do not appreciate or understand the DRY principle.
@_theashishbhatt5 ай бұрын
Hey Kantan, I like your content and appreciate you experimenting. This style of animation (long duration "flying in") is making it difficult to read. Try with different animation styles, in the powerpoint world there's "appear" effect which is a little less distracting. I feel it would be less distracting if the text stays on screen longer than it's moving, try toning down the "duration of animation". You are close, just a few more tweaks.
@kantancoding4 ай бұрын
Hey thank you! Good points that are helpful. I will keep iterating
@trungao80114 ай бұрын
I like this coding font, what is it?
@dancortes21645 ай бұрын
Great video! This makes code really readable!
@modolief5 ай бұрын
Very clean vid, thanks
@avalagum79575 ай бұрын
I think that what the author talked about is called functional programming: a function output depends on the function arguments only. If you care about side effects, then maybe you should learn Scala and then use zio, cats-effect ... to deal with side effects.
@GabrielJimenez-wt3hw5 ай бұрын
this man is CodeAesthetic at this point
@eduardointech5 ай бұрын
Liked, subscribed.
@psenej5 ай бұрын
woow i love this kind of coding video !! what do you use for the filmmaking of the code part ?
@mizatt5 ай бұрын
I don't understand how extracting saveFormatted into its own function addresses the side effect. You're still calling it using db, which is pulled from outside of the formatAndSaveName function's scope
@bossmusa90755 ай бұрын
same here
@Creezusz5 ай бұрын
Couldn't he just put the formatted name into the original d.saveformated? Why even make a function out of it, if it just calls another function?
@maximusultra99284 ай бұрын
what language is the first code in?
@kantancoding4 ай бұрын
Go
@oussamabouallati5 ай бұрын
Sir , which software that you use to make such kind of videos.? Thank you
@riptorforever25 ай бұрын
I would like to know too. The transition effects are of much better quality than the 'morph transition' in Microsoft PowerPoint. I would like to know what software was used in these code transitions, moving only the necessary words.
@John-n9f1o5 ай бұрын
You have good videos, any chance you can not have music playing? I'm trying to figure out what you're doing and the sound is a distraction. Thanks.
@EngineeringLife05 ай бұрын
Amazing video bro. I wanted to ask how do you edit your videos like this? Do you hire someone or do it yourself? What tools do you use to get everything like it is.
@malcolmanderson67355 ай бұрын
You write a test first, then make it work. Repeat until done.
@Hartex925 ай бұрын
This might be the best dependency injection explanation i've seen
@martinnorberg79405 ай бұрын
Mocking is not the goal. Mocking is a necessary evil you reach for when integration tests are not enough. It's not something you want to do.
@kantancoding5 ай бұрын
When did I say mocking was the goal? 😂
@Zmey56565 ай бұрын
You have too sad music this time(((
@ArnarYngvason5 ай бұрын
Testing frameworks have "monkey patching", which allows you to inject dependencies without having to make your code more verbose by adding arguments. I think too many programmers completely miss the point of abstraction. Abstraction is mainly so that you as a human can better understand the code. It should simplify your code, and reduce "noise". You have too much going on in your video. Everything is moving and zooming in and out. The part of my brain that does pattern recognition refuses to participate. "separation of concerns" is often good, but I would consider it more of a guideline, often "locality of behaviour" can trump this rule. "deterministic functions" I agree with, although your example was too simple and didn't explain well why pure functions are good and side effects are bad. I think what truly defines a senior programmer is knowing when to break the "rules". Or perhaps we need another tier of programmer above senior.. a master programmer.
@antoniofuller23315 ай бұрын
Any code that is loosely coupled is good code
@AAntonovG5 ай бұрын
By the way, quality of video, the voice, the picture, everything is on very high level, sorry, forgot to mention it in first comment.
@baxstart90085 ай бұрын
Not so popular take but whenever I see functions that just have one line and call other functions, I cant help but think that its not necessary cuz you can easily replace any callbacks to the function with its single line, The two functions at the end can EASILY be replaced by their one single line in their function block, and you can just call those instead in the main function, Readability? No problem you can always put comments so that you and other people wouldnt get lost on what youre doing, Having functions do nothing but return or call other functions is borderline unnecessary unless its trying to make a reach to an external function, and if you mind that it looks less imperative that way, then thats all on you now
@lunarthicclipse82195 ай бұрын
They can, but wrapping a function with another function call is really useful when implementation of the function itself changes. It's the same principle as virtual/abstract methods. What if you would like to call a function that should ONLY be called when you are on android, or another function taht should ONLY be called when you are on IOS? you would have to create if checks every time you call that function, when you can just wrap it around to act as an interface and have the function itself chose the required strategy to perform its action.
@baxstart90085 ай бұрын
@@lunarthicclipse8219 yeah your example kinda fits with what I said on the last part where it wouldnt look unnecessary anymore if you want it to have certain reaches, and thats understandable enough
@lunarthicclipse82195 ай бұрын
@baxstart9008 yah exactly, that is probably the only time it's ever useful lol.
@MaximilianPahl5 ай бұрын
Great video. But please allow more time to read/understand the code.
@kantancoding4 ай бұрын
Will do!
@muhammadumarsotvoldiev87685 ай бұрын
Thank you so much! Great video. May Allah be pleased with you 1. Creating objects inside function (DI) 2. Global variables (non-deterministic, DI) 3. Single responsibility (seperate functions)
@tomsterbg81305 ай бұрын
I'm sure every developer will agree that it's terrible to write atomic functions. Atomic notes are amazing and insane, but atomic functions usually don't end up in a very well-put place or form to be reused endlessly. It's good to write this type of code in a place that you won't edit much like a game engine's devops tools, but the code that you write to glue stuff together shouldn't be like this.
@kantancoding5 ай бұрын
Every dev agreeing on anything would be wild 🤪
@WillEhrendreich2 ай бұрын
What do you mean by atomic? When I hear atomic I think of transactions like in a database or something.
@simo_the_goat5 ай бұрын
Kantan, didn't you make the same video last 2 weeks?
@eleandro5 ай бұрын
Yes.
@eleandro5 ай бұрын
Actually, it is different...
@brandondcruz97785 ай бұрын
Awesome, now I have 7 functions, each needing 6 complex parameters. It's gonna be really fun to implement these functions in 30 very different situations, creating those complex objects every time. Now my codebase is 10,000 lines, just like Google's! Wow, writing code is so fun.
@kantancoding5 ай бұрын
Can you elaborate?
@Rama-cr9lc5 ай бұрын
@@kantancoding What do you need him to elaborate? His point is concise and clear. Imagine applying this for a hughe codebase; it instantly becomes unmaintainable as you now have, as a result, complexized your functions interfaces, created lots of helper functions and populated all your files with lots of imports. You have to strike a balance
@antoniofuller23315 ай бұрын
Wait, I was always using dependency injection, but I didn't know it was called dependency injection. I just instinctively thought it was a better way of coding 4:00
@notgonnaleo5 ай бұрын
why are people always willing to fill their code with dumbass layers just to read a variable value lmao
@asagiai49655 ай бұрын
What's wrong with the first code? Well I guess It have 2 different types of returns, though you are only expecting 1? The if statement can get long if you have multiple things to validate? Others?
@ImperiumLibertas5 ай бұрын
The code had several functions and external dependencies that could change resulting in unintended changes to the output of the function. This is what is referred to as "tightly coupled code." He uses dependency injection to resolve this issue but I don't recommend using the DI pattern especially for external dependencies. It's usually better to wrap external dependencies than to pass them in.
@asagiai49655 ай бұрын
@@ImperiumLibertas that's another
@aroundyouaroundme5 ай бұрын
The video should've been named '3 coding techniques to mid-tier developer with god-tier ego'. There are 3 tiers of developer. 1. I cannot use it. 2. I can use it. 3. I can _not use_ it. You stucked at the tier 2. Good luck with a progress.
@antoniofuller23315 ай бұрын
Why am I here? I need dependency injection tutorial
@oliverscott64215 ай бұрын
Haskell tho
@szczepanpogromca40445 ай бұрын
Great video! The editing and code examples are super aesthetic! What editor theme is that btw? The colors are perfect
@artembolshakov11945 ай бұрын
this is so bad example of DO. these functions like you wrote them can work only in libs with good level of abstrations, but good luck to deal with them in production code and static typing languages.
@kantancoding5 ай бұрын
What is DO? You mean DI right? Also, this is a statically typed language. Your comment needs more work to be useful. But thanks for watching 🙂
@heste.4 ай бұрын
Let me ask you a question: (does not give time to even pause the vid and see the code)
@kantancoding4 ай бұрын
You’re right, should have gave more time
@NiNgem-bb6lc5 ай бұрын
Nice :3
@cicoti5 ай бұрын
Do you want to be elegant, or do you want to be understood?
@kantancoding4 ай бұрын
Understood for me
@andreaslassak21115 ай бұрын
using + for string? thats not even Senior. FTW is this video !!!
@Yorgarazgreece4 ай бұрын
too much animation. can't process it. i'm static dumb 1fps guy sorry 😅 edit: if the animation was faster, and the code stayed on screen a bit longer it could be readable. but i'm not fast enough to even pause the thing at the right time 😂😂
@kantancoding4 ай бұрын
Thank you! This is actually really helpful. I will keep this in mind for future videos.
@tua75825 ай бұрын
It's 'delimiter' - not 'delimeter'
@kantancoding4 ай бұрын
You’re correct. I can’t spell 🤷♂️
@kurshadqaya16845 ай бұрын
Keynote editing. 👍
@kunns1235 ай бұрын
Bad choice of music
@kantancoding5 ай бұрын
🙂
@ReTroIIer5 ай бұрын
Is delimeter some new kind of distance measurement? Like Centimeter, kilometer, delimeter? 😂 It's delimiter
@kantancoding5 ай бұрын
You got me. I can’t spell 😂
@EmreSezgince5 ай бұрын
There is no god except for Allah being unique
@user-fed-yum5 ай бұрын
This video is so far away from the real world. It doesn't do a great job of explaining the concept, on the contrary, it creates many arguments as to why it's a bad idea. It's a poor example, out of context, that needs more than five minutes. The title is inaccurate, click bait. Whilst some might find the animations nice to look at, time spent in a code editor showing actual working code that tests, builds, and runs, would be much more educational and credible.