Hiker, software engineer (primarily C++, Java, and Python), Minecraft modder, hunter (of the Hunt Showdown variety), biker, adoptive Akronite, and general doer of assorted things.

  • 0 Posts
  • 192 Comments
Joined 11 months ago
cake
Cake day: August 10th, 2023

help-circle









  • Hmmm… That’s true, my rough litmus test is “can you explain what this thing does in fairly precise language without having to add a bunch of qualifiers for different cases?”

    If you meet that bar the function is probably fine/doesn’t need broken up further.

    That said, I don’t particularly care how many functions I have to jump through or what their line count is because I can verify “did the function do the thing it says it’s supposed to do?” after it’s called in a debugger. If it did, then I know my bug isn’t there. If it didn’t, I know where to look.

    Just like with commits, I’d rather have more small commits to feed through git bisect than a few larger commits because it makes identifying where/when a contract/test case/invariant was violated much more straight forward.


  • This only leads to bad code when people get to afraid to refactor things in light of the new requirements.Which sadly happens far to often. People seem to like to keep what was there already and follow existing patterns even well after they are no longer suitable. I have made quite a lot of bad code better by just ripping out the old patterns and putting back something that better fits the current requirements - quite often in code I have written before and others have added to over time.

    Yup, this is part of what’s lead me to advocate for SRP (the single responsibility principle). If you have everything broken down into pieces where the description of the function/class is something like “given X this function does Y” (and unrelated things thus aren’t unnecessarily coupled) it makes reorganization of the higher level logic to fit the current requirements a lot easier.

    For instance I see this a lot in DRY code. While the rules themselves are useful to know and apply they are too easily over applied removing any benefit they originally gave and result in overly abstract code. The number of times I have added duplication back into code to remove a layer of abstraction that was not working only to maybe reapply it in a different way, often keeping some duplication.

    Preach. DRY is IMO the most abused/mis-understood best practice particularly by newer programmers. DRY is not about compressing your code/minimizing line count. It’s about … avoiding things like writing the exact same general (e.g., a sort) algorithm inline in a dozen places. People are really good at finding patterns and “over fitting” making up abstractions that make no sense.


  • I agree; I prefer a “hammer and chisel” strategy, I tend to leave things a little less precisely organized/factored earlier in the project and then make a some incremental passes to clean things up as it becomes more clear that what I’ve done handles all the cases it needs to handle.

    It’s the same vein as the “don’t prematurely optimize.”

    Minimizing responsibilities of individual functions/classes/components is the only thing that I take a pretty hard line on. Making sure that I can reason about the code later and objectively say simple sentences like “given X this does Y.” I want all the complex pieces to be isolated into their own individual smaller pieces that can be reasoned about.

    All of the code bases I’ve been in where I go “oh my god why”, the typical reason is been because that’s not true; when I’m in the function I don’t know what it does because it does a lot of things depending on different state flags.


  • I’ll contest their is such a thing as good code. I don’t think experienced devs always do the best job at passing on what works and what doesn’t though. Universities certainly could do more software engineering/architecture.

    My personal take is that SRP (the single responsibility principle) is the #1 thing to keep in mind. In my experience DRY (do not repeat yourself) often takes precedence over SRP – IMO because DRY is easy to (mis-)understand – and that ends up making some major messes when good/reasonable code is rewritten into some ultra-compact (typically) inheritance or template-based mess that’s “fewer lines of code, so better.”

    I’ve never regretted using composition (and thus having a few extra lines and a little bit more boilerplate) over inheritance. I’ve similarly never regretted breaking down a function into smaller functions (even if it introduces more lines of code). I’ve also never regretted generalizing code that’s actually general (e.g., a sum N elements function is always a sum N elements function).

    The most important thing with all of these best practices though is “apply it if it makes sense.” If you’re writing some code and you’ve got a good reason to have a function that does multiple things … just write the function, don’t bend over backwards doing something really weird to “technically” abide by the best practice.





  • The loudest atheists I know off also happen to be white supremacists

    That tells me a lot about the (supposed) “rationality” of liberal atheism

    I’m really inclined to believe that you’re a troll… Liberal atheists that are white supremacists? I’ve never met anyone that fits that description. I’ll give you the benefit of the doubt a little longer…

    If you want a great example of how religion has been quite negative, see the crusades, salem witch trials, the Spanish inquisition, ISIS, 9-11.

    None of these events have relationships to the teachings of say, Jesus. However, they are atrocities (in cases like the crusades some of the bloodiest conflicts in history) where someone’s belief in god is ultimately what led to the conflict. In many cases the atrocities of a nation state and the religious motivation are hand in hand; the founding fathers specifically tried to separate religion from government because of this problematic history.

    In the modern US religion is often used to dismiss scientific findings. Folks will say “oh it doesn’t matter if climate change is real, God will find a way for us all to continue living.” … or … “it doesn’t matter if COVID is real, God will find a way to heal me” … or … “my kid has cancer but they don’t need doctors they need prayers for God to heal them miraculously.” Religion was even used by some to justify racism based slavery in the US.

    Religion has a long history of being used to incite violence or to dismiss concerns about problems where … whether God exists or not … there are concrete actions that people on Earth can take right this instant that we know will help.

    I’m not going to say “we’d be better off with nobody believing in anything!” but we certainly would be better off if more people/societies didn’t listen to fanatics that have their own agenda that’s truly devoid of rational thought and the high morals most scripture seeks to teach.



  • It’s a bit more complicated than that. The second amendment has been “infringed upon” for roughly a century because it isn’t as straight forward as second amendment advocates claim.

    A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.

    That doesn’t say:

    The right of the people to keep and bear Arms, shall not be infringed.

    Which is what a lot of second amendment advocates wish it says.

    If you read the sentence:

    With the impending meteor, we must have daily meetings for safety.

    it’s pretty clear the meteor is a factor.

    The United States did not have a standing army when the second amendment was ratified. So this could be interpreted more as “the people have a right to security from threats to their freedoms foreign and domestic.”

    Now that said, it’s true (to my knowledge) that the founding fathers were not opposed to violent revolution in the face of a tyrannical government. So the “militia” portion of that really just muddies the waters.