No video

Why I Don't Write Long Methods Anymore

  Рет қаралды 2,617

Gui Ferreira

Gui Ferreira

Күн бұрын

Пікірлер: 24
@victorie66
@victorie66 11 ай бұрын
I think this is one of the most important Clean Code principles! I also like to sort the small methods in execution order, so you can read it from top to bottom like a book. It's also better to use methods and variable names instead of comments because comments are often lies.
@gui.ferreira
@gui.ferreira 11 ай бұрын
The sort-by-execution order is an interesting twist 🤔
@herewegotoday
@herewegotoday 3 ай бұрын
I sort public methods alphabetically and private methods are in execution order as they typically just assist the public methods. It does get complicated if a private method supports more than one public method though. and yes...comments get lost and outdated very quick
@lunat38
@lunat38 11 ай бұрын
Extract method is the most effective (and quite easy to apply) refactoring technique I think. good job as usual
@gui.ferreira
@gui.ferreira 11 ай бұрын
Thank you! Cheers!
@John.Oliver
@John.Oliver 11 ай бұрын
For the past 30 years, I have pushed for smaller functions, and by extension, classes - long before it became "popular". Although there is, technically, a performance hit due to stack operations when pushing / popping function arguments, the clock cycle count for these operations is so small compared with the very large and complex code we write, it is negligable.
@gui.ferreira
@gui.ferreira 10 ай бұрын
I would even risk to say that in 2023, that type of perf gain is only a concern to 1% of us.
@John.Oliver
@John.Oliver 10 ай бұрын
@@gui.ferreira I guess this shows my age! 👴
@gui.ferreira
@gui.ferreira 10 ай бұрын
@@John.Oliver Age is different than experience 😉
@kitsurubami
@kitsurubami 9 ай бұрын
The refactor you performed is exactly how I write my code.
@gui.ferreira
@gui.ferreira 9 ай бұрын
You are doing a great job 😉
@Kimesh
@Kimesh 11 ай бұрын
What a great video. Very well explained and the example helps to show the benefits too. At my work we struggle with the issue of huge methods. This would be so helpful to improve that! Thank you!
@gui.ferreira
@gui.ferreira 11 ай бұрын
Thanks! I hope the video helps your team 😉
@raman465
@raman465 8 ай бұрын
Thanks for video I agree with this approach to extract method to do code clearest. My idea and response to criticism is we have a lot of small methods Code should be like good book. You should read code like book!
@gui.ferreira
@gui.ferreira 8 ай бұрын
That's it. It's one of the important ideas of the 4 Rules for Simple Design
@diogosilv4
@diogosilv4 11 ай бұрын
Great demo! Thank you!
@gui.ferreira
@gui.ferreira 11 ай бұрын
Glad you liked it Diogo!
@krccmsitp2884
@krccmsitp2884 11 ай бұрын
I like that.
@krccmsitp2884
@krccmsitp2884 10 ай бұрын
Known as Integration Operation Segregation Principle (IOSP) in Clean Code.
@omgCHopper
@omgCHopper 11 ай бұрын
One of the reasons people give for not following this type of refactoring into smaller methods, with single responsibility, is performance. They argue that the use of smaller methods results in poorer performance. I'd love to hear this debated and teased out further, as I find smaller methods with single responsibility easier to read and maintain, but I don't have an easy way to answer the question of performance vs maintainability when it comes to this issue.
@gui.ferreira
@gui.ferreira 11 ай бұрын
There's an argument to be made on the performance side. However, in 2023, most languages/runtimes do an excellent job on that side. My go-to line of thought is that it will be a micro-optimization and you shouldn't sacrifice maintainability for the sake of it until it's proved you really need it.
@herewegotoday
@herewegotoday 3 ай бұрын
You're totally right. That's the #1 reason I always hear for not using multiple methods. I always argue that developer performance typically matters more and has more impact to cost than hardware.
@nove1398
@nove1398 11 ай бұрын
Very nice video
@gui.ferreira
@gui.ferreira 11 ай бұрын
Thanks 🙏
Do I Need MediatR in Vertical Slice Architecture?
7:58
Gui Ferreira
Рет қаралды 6 М.
Think About this Before Creating a New Mock
13:12
Gui Ferreira
Рет қаралды 2,9 М.
What will he say ? 😱 #smarthome #cleaning #homecleaning #gadgets
01:00
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 3,7 МЛН
The Most Legendary Programmers Of All Time
11:49
Aaron Jack
Рет қаралды 552 М.
Senior Angular Developer Interview (theory)
41:57
WeCoded
Рет қаралды 17 М.
How do I Stay Organized as a Developer
15:21
Gui Ferreira
Рет қаралды 2,2 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 83 М.
The Missing TDD Skill according to Kent Beck
9:51
Gui Ferreira
Рет қаралды 1,7 М.
Building Complex Objects in a Simple Way with C#
12:19
Gui Ferreira
Рет қаралды 8 М.
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 272 М.
Refactoring A Tower Defense Game In Python // CODE ROAST
36:49
ArjanCodes
Рет қаралды 257 М.
Understanding Effects In Svelte And When To Use Them
27:31
Joy of Code
Рет қаралды 4,6 М.
What will he say ? 😱 #smarthome #cleaning #homecleaning #gadgets
01:00