• 0 Posts
  • 7 Comments
Joined 1 year ago
cake
Cake day: June 2nd, 2023

help-circle

  • ugo@feddit.ittomemes@lemmy.worldSchrödinger's Code
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    23 days ago

    Im my defense, I did test it. It was working for me.

    But then someone else touched it without understanding it or flipped the truth value returned by one of the functions used by my code without properly fixing the call sites.

    Edit: or they had a merge conflict and they don’t know how to correctly resolve those.



  • ugo@feddit.ittoMemes@lemmy.mlLost and found
    link
    fedilink
    arrow-up
    12
    ·
    1 month ago

    You have expressed my feelings excellently. I find football a very entertaining sport (not that I have the money to watch it, or the time / energy / social media connections to keep very up to date with it) but the fanbase can be absolutely braindead.

    I mean, I love rivalries and some shithousery, but things escalate too often, too much, and too quickly.

    Still, wish I knew of ways that would allow me to keep up to date with stuff without costing me a good chunk of change or a huge amount of time, or having to have a twatter account or whatnot.






  • Meh. Been developing professionally with C++ for 10 years at this point. I’m one of the weird people that kinda likes C++ and its pragmatism despite all its warts.

    I’d like C++ better if it didn’t have inheritance. There are better solutions to model interfaces, and without inheritance people can’t write class hierarchies that are 10 levels deep with a different set of virtual functions overridden (and new virtual functions added) at each level.

    And yes, that is not hypothetical. Real codebases in the real world shipping working products do that, and it’s about as nice as you can imagine.


  • You do have a terminology mismatch. In C++, an abstract class is a class with at least one pure virtual method.

    Such classes cannot be instantiated, so they are useful only as base classes.

    An interface is more of a concept than a thing.

    Sure you can say that Iterable is an interface that provides the Next() and Prev() methods and you can say that Array is an Iterable because it inherits from Iterable (and then you override those methods to do the correct thing), and that’s one way to implement an interface in C++.

    But you can also say that Iterable<T> is a class template that provides a Next() and Prev() methods that call the methods of the same name on the type that they wrap (CRTP aka static polymorphism).

    Or you can say that an algorithm that scans a collection T forward requires the collection to have a Next() method by calling Next() on it.

    And I can think of at least 2 other ways to define an interface that isn’t using abstract classes.

    And even if using abstract classes, inheriting from them is definitely the least flexible way to use them to define an interface, because it doesn’t allow one to do something like mocking functionality in tests, because it’s not possible to redefine the class to be tested to inherit from the test interface implementation with mocked functionality, so one still needs something to the effect of dependency injection anyway.

    So yeah, abstract class is very different from inheritance, and it’s also very different from interface, even though it relates to both.