I have been following the channel since its debut and got significantly better at coding in the meantime. While it is more and more rare for me to find enriching concepts in the “I explain you something” kind of videos, I still learn a lot from the refactoring ones. Bottom line is that I would like to see more of these videos! Hope it helps in your audience targeting 😉
I was worried that the Code Roast series is falling off because recently entries were pretty decent written code, actually. This episode truly bring back the good-old Code Roast, code that is written by someone who is obviously knowledgeable in programming and Python but has very questionable design choices, I love it! Shout out to the code author for the submission so us all can learn from your mistakes.
Great video as always Arjan. I'm looking forward to part two! In this code, it was absolutely right to replace "command" with a tuple but I think there is a case for using dataclasses like this. It can make code much more readable as you don't need to remember what each positional member is and if you want to add more members in the future, you don't end up with lots of tuple[0], tuple[1] code.
What i like about code review is the opportunity to improve and simplify code that (should) already work. One of my mottos: First make it work, then make it better. Thanks Arjan; another terrific start to a video.
Ack-- I didn't notice this was a two-parter! Looking forward to the dramatic conclusion to this cliffhanger next week. So far, it's deeply satisfying to watch you ripping out huge chunks of code and seeing how much simpler things can be...
@@ArjanCodes Watched the whole thing and I have a questions: why have a help_shell function at all if it's just (so it seems) returning a print statement? Other than that, I'm going to see about removing some fairly basic dataclasses that I have in my own code using the example of Command = tuple[str, int] that you provided. :D
I felt like I was at the theater watching an action movie and right at the climax, they stopped the video and turned on the lights and I was pulled back into reality! Ok, maybe I’m exaggerating… looking forward to part 2!
For the shell component: why not use argparse from the stdlib or even better, typer from the same author of fastapi? Unless it's a learning opportunity, a lot of the code could be golfed by using libraries that are battle tested and provide better functionality.
Good catch, and to your question, no. If you split on a space (the default: sep=None), none of the sub-parts will contain any trailing or leading whitespace.
Half an hour isn't that long. We're also long over that mantra, that youtube consumers don't watch anything more than 10 minutes. I know a list of other channels, that feature hour long videos. So if it's not for the reason, that you want to split up content over several weeks, I'd just go with a full roasting session one at at time, no matter how long :) I suppose there will be other projects in need of some roast for the forseeable future!
about the auto formatter, make sure everyone use the same rules, and always format before committing otherwise you create a terrible pull request review experience :( (thousands of changes related to formatting...) There are ways to reinforce formatting before committing
As a developer myself, I really like your channel, Arjan, but it pains me to see you manually fixing the imports after rename operations. It gives me a bad vibe when I see people not fully utilizing their IDE or not knowing the shortcuts :D:D
22:59 - Why is it that Python does not accept "None" as type hint when a function doesn't have any parameters? I.e. why can't you write: def help_shell(None) -> None: I personally think it's strange since on the output side, "None" is allowed...
The type hint of the return value of a function is given after the -> arrow. As to the arguments of a function: a function can have NO arguments and in that case there is only white space between the opening and closing parentheses. Or a function can have 1 or more comma separated formal arguments, each of which is identified by an identifier. Python keywords (None, from, import, in, class, ...) are not allowed as identifiers. So: seeing None between parentheses means the function has 1 one formal argument. But it's identifier, None, is not allowed (try it out, you would get 'invalid syntax'). So: a function without arguments can be recognized by really having NOTHING between its parentheses (well, white space is allowed).
As others have said, but also, why would you want to write None as a type hint? "def help_shell()" has nothing in the arguments, so it serves the same purpose you expect Although you can set the default value of an argument as None like this: from typing import Optional def help_shell(value: Optional[int] = None): pass
Between the poor adherence to convention and the overly-complex design, it's pretty obvious the original author was (a) coming from another language and/or (b) isn't terribly experienced and went overboard trying to put "fancy" code into the public domain.
I would love to see a code roast for a code written by an experienced python dev for once. I have a couple of projects I would like to submit but not sure this would fit this series tbh
It feels like "baby's first Programming Pattern", and that the author tried to slap as many patterns into his code as possible. Can't knock them too hard though, as I've been there, done that too. 😂
👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis
I have been following the channel since its debut and got significantly better at coding in the meantime.
While it is more and more rare for me to find enriching concepts in the “I explain you something” kind of videos, I still learn a lot from the refactoring ones.
Bottom line is that I would like to see more of these videos!
Hope it helps in your audience targeting 😉
Thank you for sharing this!
100% filipopisello, totally agree with this. Thanks again @Arjan for another great video
I was worried that the Code Roast series is falling off because recently entries were pretty decent written code, actually. This episode truly bring back the good-old Code Roast, code that is written by someone who is obviously knowledgeable in programming and Python but has very questionable design choices, I love it! Shout out to the code author for the submission so us all can learn from your mistakes.
Thank you, glad you enjoy the series!
Some people prefer light roast coffee, some people prefer dark roast coffee, but the only roast I like is a CODE ROAST!
Code Roast with a cup of coffee.
Well said ... written I mean ... 😉
@@costelinha1867Woah! That's too much of a good thing! 😂😂😂
Thanks!
Thank you, Peter! I really appreciate your support.
Great video as always Arjan. I'm looking forward to part two! In this code, it was absolutely right to replace "command" with a tuple but I think there is a case for using dataclasses like this. It can make code much more readable as you don't need to remember what each positional member is and if you want to add more members in the future, you don't end up with lots of tuple[0], tuple[1] code.
I was waiting for another code roast. thank you, Arjan. honestly, I don't mind if you make longer videos cuz they bring a lot of value.
I love refactoring as a hobby. You get raw ideas and wild code and make good art out of them. Until someone finds your ideas raw and your code wild.
What i like about code review is the opportunity to improve and simplify code that (should) already work.
One of my mottos: First make it work, then make it better.
Thanks Arjan; another terrific start to a video.
Thank you - glad you liked it!
Refactoring - Martin Fowler made a great book on it - it contains techniques most people haven't heard of, and are missing in most IDEs.
@@NostraDavid2 I'll go check it out. Thanks for posting.
finally again!!!! the most i learn from are code roasts
Glad you find them helpful!
I like this series a lot!
Glad to hear you liked it!
Ack-- I didn't notice this was a two-parter! Looking forward to the dramatic conclusion to this cliffhanger next week. So far, it's deeply satisfying to watch you ripping out huge chunks of code and seeing how much simpler things can be...
Thank you Roy! I’ll post the second (final) part next Friday!
Let's goooo!!
Yes!
@@ArjanCodes Watched the whole thing and I have a questions: why have a help_shell function at all if it's just (so it seems) returning a print statement?
Other than that, I'm going to see about removing some fairly basic dataclasses that I have in my own code using the example of Command = tuple[str, int] that you provided. :D
Could you please make another video about Asyncio with the advanced concepts and also learning videos about cloud design patterns?
All I wanna do is watch your code roasts. Moar pls :)
To be fair, I do have some pretty big python spaghettis that he could probably review...... specially on my earlier projects....
@@costelinha1867I plan on starting a UA-cam channel to do this kind of stuff (code roasts). Do you think you'd enjoy that?
@@aflous Maybe... I could check it out.
I felt like I was at the theater watching an action movie and right at the climax, they stopped the video and turned on the lights and I was pulled back into reality! Ok, maybe I’m exaggerating… looking forward to part 2!
Coming this Friday!
I love this series
Damn, the final version is looking really clean. I can't wait to see how you're typing the code into the editor and experience a free time travel 😂
Love this series!
I'm glad you're enjoying the content!
Nooooo I didnt know it was split into 2 videos 😆 I cant wait until the next video, great work!
Thanks! Coming this Friday! :)
I wish I had the confidence of deleting something when you don't know what it is, and deleting something for completeness such as @ 11:00 .
The best rubric. I love it
Thank you Roman!
Such a funny intro 😂😂😂. Love that
For the shell component: why not use argparse from the stdlib or even better, typer from the same author of fastapi?
Unless it's a learning opportunity, a lot of the code could be golfed by using libraries that are battle tested and provide better functionality.
@17:40: What is there to strip? More precisely, if you a string split on a space, will any part ever start/end in a space?
Good catch, and to your question, no. If you split on a space (the default: sep=None), none of the sub-parts will contain any trailing or leading whitespace.
'BASH'ing other people's code ++ Need more linux converts. ;)
when editing variable names: ctrl+D or ctrl+shift+D is... gold.
Even better: F2 (Rename Symbol)
God I love Code Roasts hahah. And I loved the intro! 😂 Also, did you lose some weight by the way man; really fits you!
Thank you! Yes, I lost some weight. I've been prioritizing my health for the last year! :)
Half an hour isn't that long. We're also long over that mantra, that youtube consumers don't watch anything more than 10 minutes. I know a list of other channels, that feature hour long videos. So if it's not for the reason, that you want to split up content over several weeks, I'd just go with a full roasting session one at at time, no matter how long :) I suppose there will be other projects in need of some roast for the forseeable future!
about the auto formatter, make sure everyone use the same rules, and always format before committing otherwise you create a terrible pull request review experience :( (thousands of changes related to formatting...)
There are ways to reinforce formatting before committing
Regarding the Command type, wouldn't it be better to use an explicit TypeAlias as per PEP 613?
Where are the tests? Did I just catch somebody doing manual refactorings without the safety net of tests? Living on the edge.
"bashing other people's code".
Pun intended? 👀😂
In a nutshell, there was no good use of bash commands in this code so far
Please upload part 2 today, else I will start panicking 😣
Coming this Friday!
Any particular reason you didn't use the the Rename Symbol feature instead of manually renaming things in multiple places?
Help, I'm stuck in a loop, while end_of_roast is False: ... 😂
As a developer myself, I really like your channel, Arjan, but it pains me to see you manually fixing the imports after rename operations. It gives me a bad vibe when I see people not fully utilizing their IDE or not knowing the shortcuts :D:D
My approach: Delete everything and use argparse
This, but with click.
Or Typer (which better supports types)
26:21 line 84?
else:
pass
22:59 - Why is it that Python does not accept "None" as type hint when a function doesn't have any parameters?
I.e. why can't you write: def help_shell(None) -> None:
I personally think it's strange since on the output side, "None" is allowed...
Because None is a value, not a type.
You can't write `def Help(1): ...` either, for example.
The type hint of the return value of a function is given after the -> arrow. As to the arguments of a function: a function can have NO arguments and in that case there is only white space between the opening and closing parentheses. Or a function can have 1 or more comma separated formal arguments, each of which is identified by an identifier. Python keywords (None, from, import, in, class, ...) are not allowed as identifiers.
So: seeing None between parentheses means the function has 1 one formal argument. But it's identifier, None, is not allowed (try it out, you would get 'invalid syntax'). So: a function without arguments can be recognized by really having NOTHING between its parentheses (well, white space is allowed).
As others have said, but also, why would you want to write None as a type hint?
"def help_shell()" has nothing in the arguments, so it serves the same purpose you expect
Although you can set the default value of an argument as None like this:
from typing import Optional
def help_shell(value: Optional[int] = None):
pass
Between the poor adherence to convention and the overly-complex design, it's pretty obvious the original author was (a) coming from another language and/or (b) isn't terribly experienced and went overboard trying to put "fancy" code into the public domain.
I would love to see a code roast for a code written by an experienced python dev for once. I have a couple of projects I would like to submit but not sure this would fit this series tbh
@@aflous Yes! That would be great!
yeah, but I bet every python dev can remember the feeling when your code started thunder with all the __dunder__
It feels like "baby's first Programming Pattern", and that the author tried to slap as many patterns into his code as possible. Can't knock them too hard though, as I've been there, done that too. 😂
Am I the only one that was driven absolutely mad by the colored squiggle lines on every line? What is up with the editor?
Congratulations, you have just totally ruined all his unittests! ;)