Refactoring a Python Data Validation Interactive Shell

Поделиться
HTML-код
  • Опубликовано: 21 дек 2024

Комментарии • 27

  • @ArjanCodes
    @ArjanCodes  День назад

    👉 Check out brilliant.org/ArjanCodes/ to try Brilliant for free for 30 days, and get 20% off an annual premium subscription.

  • @TomDonahue
    @TomDonahue День назад +17

    Thanks Arjan! This was painful in all the right ways :) My first programming language exposure was C# (through the Unity game engine), and it's a language that really encourages abstractions and "clean code" principles. In the command and commandargs classes, I was trying to enforce something similar to C#'s interface structure, and definitely overcomplicated things. I need to get KISS and YAGNI signs posted to my desk...
    Loved the suggestions, loved the refactor--thanks for taking the time to go through this!

    • @ArjanCodes
      @ArjanCodes  День назад

      Hey Tom, thank you for being courageous and submitting your code. It was a lot of fun working on it and I hope the second pair of eyes helps you improve your skills. And feel free to disagree with some of the things I did - there’s always an aspect of personal taste to development.

  • @yassineboujerfaoui1160
    @yassineboujerfaoui1160 День назад +1

    Really like the way you've resolved the Liskov substitution principle violation in 28:01 (which was hidden with a `type: ignore` comment) through functions.
    I've personally would've gonna for making `Command` classes a generic class as a function of `CommandArgs` classes. But after seeing this, using functions really makes sense!

  • @Martin-lv1xw
    @Martin-lv1xw 16 часов назад

    Beneficial kinds of stuff. Thanx Arjan.

  • @MrVernuk
    @MrVernuk 22 часа назад

    Awesome video about refactoring! I really appreciate your effort to show how the code should look for better understanding and easier changes in the future, with less effort and fewer mistakes!

    • @ArjanCodes
      @ArjanCodes  19 часов назад +1

      Thank you, I’m happy you liked the refactor! 🙏

  • @twelvethis3979
    @twelvethis3979 46 минут назад

    Loved the video, thanks a lot Arjan. Highly instructional. I've been arguing for functions instead of those tiny weird "function classes" in my company for a while. I'll be showing the video to my fellow developers at work.

  • @Forseti2
    @Forseti2 День назад +2

    I'm really like I've chosen Pycharm at the beginning. It offers many convenient things, eg that moving of code Arjan struggled littlebit with in VSCode - Pycharm automatically refactor imports according the change you made when you moved files to other folder.

    • @NikolaiPismennyi
      @NikolaiPismennyi День назад

      Vscode also does this with standard python plugins. Not sure why Arjan is not using them

    • @Forseti2
      @Forseti2 День назад +1

      @NikolaiPismennyi okay, interesting - anyway VSCode is rather multipurpose IDE and it's great (no doubt about it), but needs to tweak for special purpose (eg Python development) where Pycharm comes tweaked and prepared immediately after instalation. Ok, let's say plugin installing in VSCode is easy thing, but then the intellisense didn't work as I would expect - after some time I've found that VSCode limits depth of search when observing the dependencies and by default that depth was too low, so it didn't show popups with suggestions,... And there is more such things. Another thing is debugger in VSCode, I don't really like it, but that's maybe thing you can get used to... 🤔
      Anyway - for quick tests is VSCode great, for serious work, I prefer Pycharm.

    • @NikolaiPismennyi
      @NikolaiPismennyi День назад +1

      @@Forseti2 well the plug-ins come by default the moment you try to run python. So you have to make an effort to turn them off.
      Not disagreeing with you about PyCharm vs VSCode. But I think more people would have used PyCharm if they didn't ask for money for really basic features (like support for Jupyter Notebooks). And now they also don't have any nice AI features vs VSCode based projects like Cursor

    • @Forseti2
      @Forseti2 День назад

      @@NikolaiPismennyi ah, sure, I'm not really not using these features. So it doesn't bother me, but you are right - for people that do, that's dealbraker.

  • @hoseynamiri
    @hoseynamiri День назад +7

    Wow! I love your refactoring videos! Please make code roast. Would you go over a library I built?

    • @ArjanCodes
      @ArjanCodes  День назад +4

      Glad you like them! You can submit your code for a roast on my Discord server (there's a dedicated channel). To join, go to: discord.arjan.codes.

  • @romanroman4665
    @romanroman4665 День назад +2

    yeah, python refactoring series ☺

  • @nemanjaradojkovic1224
    @nemanjaradojkovic1224 19 часов назад +1

    Love your code roasts, Arjan!
    Would it also make sense to use a `defaultdict` in `register_event` ? And the "could not add..." message in the same function should maybe say "listener already added to event".

  • @TheScott10012
    @TheScott10012 День назад +6

    So they made a less flexible data exploration in cli instead of a notebook?
    I think as part of your code reviews you should also give feedback on whether decisions made before even writing code are good ideas...

    • @ArjanCodes
      @ArjanCodes  День назад +20

      I disagree. I don't want to make any assumptions about the motivation of the developer. Not all tools are aimed to be used by tons of people. There are plenty of projects that developers work on that have a different goal, ranging from learning about a particular technology (such as how to build a CLI), or wanting to have something simple for internal use or as part of an automated script (in which case a notebook won't work).

    • @joshuadonahue5871
      @joshuadonahue5871 День назад +4

      So they wrote a computer program instead of riding a bycicle? I think as part of your code reviews you should also give feedback on whether decisions made before even writing code are good ideas

    • @zstrout
      @zstrout День назад +1

      I have something similar that I use all the time. But I 1) just use the python REPL instead of my own custom CLI and 2) change some environment variables in windows (I also did something similar in Linux too) so that I can right click on a file and have an "open in pandas" option that passes the file name as an arg to the script then creates an interactive session with the variable `df` as the dataframe of the file. I then use regular python commands to manipulate the data or plot it. This is like a step between excel and a notebook. It is really a godsend for huge csv or xlsx files that take forever to load in excel.

  • @FighterAceee94
    @FighterAceee94 День назад +1

    Arjan you mentioned settings at the end of the video. I'd love to hear your thoughts on setting up an INI configuration file in combination with a Settings GUI and loading of these settings into the application. My GUI project uses very diverse settings all over the codebase, and I'm torn between the current system and some sort of a centralized setting value handling system.

    • @greyshopleskin2315
      @greyshopleskin2315 День назад

      For settings I like pydantic-settings.
      You can just create a model and you can configure it to automatically read values from environment variables, a .env file, toml and more formats

  • @johanmartijn
    @johanmartijn 17 часов назад

    What would have added are doxstrings. So a new user knows wat each function does

  • @ramimashalfontenla1312
    @ramimashalfontenla1312 День назад

    Like DocDB video!

  • @johanmartijn
    @johanmartijn 17 часов назад

    Nice in between remark about the Callable being moved to ABC, which makes no sense 😂