• Jabbermuggel@discuss.tchncs.de
      link
      fedilink
      arrow-up
      0
      ·
      8 months ago

      I know that header files have some pretty horrible issues with templates and cyclic dependencies and so on, but from an organisational perspective I really like them. If I have to implement some complicated algorithm I could easily have a thousand likes + of Code, but the header still quite nicely shows the general structure in one or two screens. Whenever I do classes in python I start wishing for headers at like 300 lines, simply because I loose track of all the functions I already made.

      Maybe I’m just not a good python programmer tho.

      • words_number@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        8 months ago

        I’d say at 1000 lines it usually makes sense to extract some parts into other files. But sure, I guess most obscurities have positive aspects. On the other hand, nothing is stopping you from writing a separate file with only function signatures next to your python scripts. It’s just not required, because why would it ;)

    • Sonotsugipaa@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      It’s not the case with this meme, but in C++ template definitions have to be defined in the headers if they’re not full template specializations

  • Lauchmelder@feddit.de
    link
    fedilink
    Deutsch
    arrow-up
    0
    ·
    edit-2
    8 months ago

    Why are you putting the implementation in the .h file? You’re supposed to declare in the header and implement in the .cpp files. The meme is reversed

    • merthyr1831@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      8 months ago

      If C++/C were real languages for real programming they’d enforce this in the compiler.

      No sane language designer would say “it is imperative that you do not implement your class in its header file” then write a compiler designer to say “oh you implemented your code in the header file? lol lmao that rocks”

      They have played you all for fools.

      • Lauchmelder@feddit.de
        link
        fedilink
        Deutsch
        arrow-up
        1
        ·
        8 months ago

        not saying it’s good design, I ditched C++ long ago. at least the C++20 modules API is gonna fix this, right guys?

      • SubArcticTundra@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        8 months ago

        I actually like how much freedom C++ gives you. As long as it is fed valid code, it does not give a fuck about how you choose to structure your project

        • tyo_ukko@sopuli.xyz
          link
          fedilink
          arrow-up
          0
          ·
          8 months ago

          That freedom becomes misery on the instant you have to start maintain the code from some other free spirit, whose style is totally different from yours.