Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
pcouy ( pcouy@lemmy.pierre-couy.fr )  to Programming@programming.dev · 2 years ago

Code Smells Catalog

luzkan.github.io

external-link
message-square
41
link
fedilink
  • cross-posted to:
  • programming@programming.dev
48
external-link

Code Smells Catalog

luzkan.github.io

pcouy ( pcouy@lemmy.pierre-couy.fr )  to Programming@programming.dev · 2 years ago
message-square
41
link
fedilink
  • cross-posted to:
  • programming@programming.dev
A collection of Bad Code Smells in a Catalog form for Developers & Researchers. Code Smell is a typical bad code implementation, and learning these concepts immiedietly makes you a better developer!
  • FizzyOrange ( FizzyOrange@programming.dev ) 
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

    I don’t need to Google anything. I have 30 years experience writing C & C++.

    This is not about storage durations

    Yes it is.

    https://en.cppreference.com/w/c/language/storage_duration

    it’s local to a function

    Only the visibility is local. The data is still global state. You can call that function from anywhere and it will use the same state. That’s what global state means.

    https://softwareengineering.stackexchange.com/a/314983

    Some of the biggest issues with global state are that is makes testing difficult and it makes concurrent code more error-prone. Both of those are still true for locally scoped static variables.

    • Boomkop3 ( Boomkop3@reddthat.com ) 
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      2 years ago

      Again, it’s an easy refactor to make it not global. There are cases where that extra abstraction work simply does not add value.

      With your background, you should know that

      • FizzyOrange ( FizzyOrange@programming.dev ) 
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        it’s an easy refactor to make it not global

        I have enough experience to know that making global state non-global is usually anything but easy.

        • Boomkop3 ( Boomkop3@reddthat.com ) 
          link
          fedilink
          arrow-up
          1
          ·
          2 years ago

          Damn, suppose I won’t just pass it as a pointer from the call site. That’d be so difficult to add an int to a struct

          30 years my ass

          • FizzyOrange ( FizzyOrange@programming.dev ) 
            link
            fedilink
            arrow-up
            1
            ·
            2 years ago

            Yes, and then pass the context from the call sites of that function, and all the way up to main(). Oh look you’re refactored the entire app.

            That’s best cases too, you’d better hope your program isn’t actually a shared library running in a SystemVerilog simulator with state instantiated from separate modules via DPI, or whatever.

            30 years my ass

            lol when you have 30 years experience you will have actually tried to do this a few times and realised it isn’t usually as trivial as you hope it would be.

            • Boomkop3 ( Boomkop3@reddthat.com ) 
              link
              fedilink
              arrow-up
              1
              ·
              2 years ago

              That’s not a great approach, but you do you

Programming@programming.dev

programming@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programming@programming.dev

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 66 users / day
  • 423 users / week
  • 1.72K users / month
  • 4.17K users / 6 months
  • 449 local subscribers
  • 28.8K subscribers
  • 2.97K Posts
  • 23.1K Comments
  • Modlog
  • mods:
  • snowe ( snowe@programming.dev ) 
  • Ategon ( Ategon@programming.dev ) 
  • UlrikHD ( UlrikHD@programming.dev ) 
  • bugsmith ( bugsmith@programming.dev ) 
  • Spyro ( Spyro@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code