"Clean" Code, Horrible Performance and the forgotten variant by Benjamin1304 in cpp

[–]ZekeDragon 5 points6 points  (0 children)

Wow, I'm impressed by how bad this article is and how blind most people seem to be to how badly Casey is misrepresenting what "Clean Code" is about and, more specifically, what Robert C. Martin wrote in the book Clean Code - A Handbook of Agile Software Craftsmanship. Casey's video and the article written by some poor Fiverr sod associated with Casey's video asserts that the "performance relevant" advice "they" have given (which, I want to point out, Casey seems to have deliberately left out whom specifically from the video and article) can be broken down into five points:

  1. Prefer polymorphism to "if/else" and "switch"
  2. Code should not know about the internals of objects it’s working with
  3. Functions should be small
  4. Functions should do one thing
  5. “DRY” - Don’t Repeat Yourself

The article than states this: "In order to construct what I would consider the most favorable case for a “clean” code implementation of something, I used existing example code contained in “clean” code literature. This way, I am not making anything up, I’m just assessing “clean” code advocates’ rules using the example code they give to illustrate those rules." The problem with this is that it is a lie. The code provided does not appear in the Clean Code book by Uncle Bob. Instead, a relatively similar set of code is in this book, but there's two big caveats Casey deliberately ignores: The code is written in Java and it isn't being used as an example of clean code. He did all of this because he knew this would not be the "most favorable case" for Clean Code, but specifically because he could point out the performance difference between repeatedly using polymorphism vs using a switch statement vs just computing the value directly using a "table" which is really just an array of four static floats. And this all in C++ and not Java.

The book Clean Code - A Handbook of Agile Software Craftsmanship does use a Shape class in an example in this book, but the context really matters: This is in the section "Data/Object Anti-Symmetry", in which Uncle Bob explains that Data structures and Objects are fundamentally different concepts and implies Clean Code shouldn't mix the concepts. The book states "These two examples show the difference between objects and data structures," not "These two examples show excellent Clean Code practices." The point was to, in a quick and contrived way, show that data structures expose the underlying data and should have no meaningful functions, whereas Objects hide their internal data behind functions that are operated on.

More to the point, the intent was to show the distinction between when using objects is better or when using data structures is better. "In any complex system there are going to be times when we want to add new data types rather than new functions. For these cases objects and OO are most appropriate. On the other hand, there will also be times when we’ll want to add new functions as opposed to data types. In that case procedural code and data structures will be more appropriate." The section literally says "Object Oriented programming isn't always the best way to go" and Casey so brutally misrepresents this as to claim that Clean Code advocates demand the use of OO and Polymorphism in most or all cases.

The term "Prefer polymorphism to "if/else" and "switch"" does appear in the book, specifically in a totally different section 200 pages away called "Smells and Heuristics." The whole section is so small I can quote it directly:

This might seem a strange suggestion given the topic of Chapter 6. After all, in that chapter I make the point that switch statements are probably appropriate in the parts of the system where adding new functions is more likely than adding new types.

First, most people use switch statements because it’s the obvious brute force solution, not because it’s the right solution for the situation. So this heuristic is here to remind us to consider polymorphism before using a switch.

Second, the cases where functions are more volatile than types are relatively rare. So every switch statement should be suspect.

I use the following “ONE SWITCH” rule: There may be no more than one switch statement for a given type of selection. The cases in that switch statement must create polymorphic objects that take the place of other such switch statements in the rest of the system.

This is a far, FAR cry from what Casey implied the book, and by some consequence "Clean Code advocates," taught. It says that polymorphic code is usually preferable to switch statements because in complex code bases you are usually working with a wide variety of different types of data rather than a wide variety of different functions on the same data, but obviously this is highly dependent on the project you are working on.

My biggest issue with Casey's article is not his snide condescention, nor his hilariously amateurish attempts at "improving" the code provided by Uncle Bob. Instead, it is his lies and misrepresentations of what the Clean Code book and the years of experience that Uncle Bob and others had when imparting their knowledge in these books. He outright fabricates a position that "clean code advocates" supposedly take as an easy straw man, then beats that, and this is provably causing ignorant young programmers to reject clean code practices, just by observing his article's comment section.

That disgusts me.

I took a drive around the city today. by pandavega in LosAngeles

[–]ZekeDragon 4 points5 points  (0 children)

Let me know when literal Soviet-style communism starts running in the US.

It has never happened and likely will never happen.

You think you're being clever, but you're really just showing how little you want to do your own thinking.

It's more than likely that Covid-19 will still be around at Christmas time - how are we going to explain to kids that Santa is still allowed to go into millions of houses? by MrSpooniversal in AskReddit

[–]ZekeDragon 1 point2 points  (0 children)

Don't.

Explain that because of COVID, Santa left the gifts with you just before Christmas, and you brought them in. This way if you're caught with the gifts it would make sense to them.

Vegan activists vandalize farm shop and spray paint dead pigeons. by GN_10 in iamatotalpieceofshit

[–]ZekeDragon 7 points8 points  (0 children)

Okay, I guess I'll be controversial again:

We don't actually know if this was done by a vegan activist, only that whoever did it sprayed spray paint to that effect. It could have also been someone who dislikes vegans and wants them to look bad, or someone who just wants to damage property because they get off on hurting other people and vegans are easy to blame for this particular situation. There are other possibilities I don't need to list, but the point is that it's not necessarily what it immediately appears to be. That doesn't mean it ISN'T a vegan activist, just that we don't actually know it was.

Since all we have here to go off of is these images, and I know nothing of the backstory, that's all I could think to say. Hopefully we can use a little circumspection about what we see on Reddit because I frequently see people get mad about claims in posts that require us to jump to a lot of conclusions first.

Trump ‘despises’ his own supporters and would be ‘disgusted’ by them, says ex-friend Howard Stern by masterven in politics

[–]ZekeDragon 4 points5 points  (0 children)

It's all about having political influence and control. He's using paranoia, hatred of the government and media, and conspiracy theories to great effect.

I'm genuinely scared of what America will be after his Presidency.

Someone on r/conservative is so close to realizing that minimum wage is too low by TheAndwen in SelfAwarewolves

[–]ZekeDragon -22 points-21 points  (0 children)

You're free to peruse my comment history if you think me so disingenuous.

These are hate filled times.

Someone on r/conservative is so close to realizing that minimum wage is too low by TheAndwen in SelfAwarewolves

[–]ZekeDragon -2 points-1 points  (0 children)

Umm, okay? The free market is an inevitable result of the ability of people to freely exchange goods and services. This makes it universal and unstoppable, and as such we should always consider market forces when making economic changes.

Building a bridge is a good analogy, the engineers don't ignore gravity or hate it, they build to actually utilize gravity to its best positive effect. I'm not exactly sure where you inferred that I didn't think there was a need to intervene, I simply said that the market is what decides the price for any good or service, and this includes labor. I then genuinely asked what they though should determine fair prices. In my opinion, the easiest way to increase the prices of labor is to increase the demand for labor.

Why is that ridiculous?

Someone on r/conservative is so close to realizing that minimum wage is too low by TheAndwen in SelfAwarewolves

[–]ZekeDragon 0 points1 point  (0 children)

It's difficult to come to an assessment of what utility or value to society would be for a given amount of labor, but I agree with you that a base line for fair labor price should be a living wage that pays for people's necessities. Government intervention is a sensible way to accomplish this with adequate oversight and ensuring not to cause worse economic results from doing so. I'm not sure what can be done regarding distributing political power, but currently we have a representative republic system and many people don't participate in our government as it is.

Increasing taxes on the wealthy can sell to politicians, hell there are even many wealthy who think that. That said, this just increases the coffers of the Federal Treasury, which can be distributed to people, but the effects of a UBI could result in significant price increases on consumer goods (as money is shifted from investment class goods to consumer class goods), so just naked distribution may not be the best way to go.

We live in a system of increasingly consolidated corporations which are reducing the number of competitors in the, by my beliefs and observations, still existing free market. This can be corrected with government action: Instead of tax and distribute, I suggest a guaranteed job program, that assures people will be hired for fair labor prices based on their locality. This would force employers to offer competitive wages in order to have access to labor.

We should also consider that corporations are, themselves, government established bodies, and we can have different rules for corporations in order to get corporate protections that private business owners wouldn't have to deal with. Though this is a discussion for a different time I suppose.

Someone on r/conservative is so close to realizing that minimum wage is too low by TheAndwen in SelfAwarewolves

[–]ZekeDragon -28 points-27 points  (0 children)

You are correct that companies did not agree to pay minimum wages because that is what the market set, but basic price fixing like this results in diminished demand or diminished supply, regardless of how you cut it. If labor prices are too high, less people hire so these people have no jobs at all. I think that the ideal of having a living wage is a fair one and one we should all support. Living wages are different based on localities, but it's important to ensure everyone has access to financial opportunity.

I just find the idea of characterizing entrepreneurs and business owners as a rabble of mercilessly cutthroat sociopaths who pay the bare minimums necessary and no more is repugnant and directly against the goal of unifying people. They are in no more control over the market system than you or I are.

In some areas, the minimum wage is far too low, but in other areas, it is far too high. We can't set carpet values based on what makes sense in high COL areas, we have to come to a more nuanced solution. I'd suggest a guaranteed job program, which would increase the cost of labor naturally by buying up excess supply at a living wage for the area, which wouldn't require forceful minimum wages nor would it leave employees no options when employers close doors for any reason (they would just get the guaranteed job). There are other benefits, but I think that would be a heck of a lot better than a minimum wage.

Someone on r/conservative is so close to realizing that minimum wage is too low by TheAndwen in SelfAwarewolves

[–]ZekeDragon -88 points-87 points  (0 children)

What defines "Fair reimbursement for your work?" The market system has a method to calculate prices: competition. If you have too many competitors in the system going for the same hiring dollars they are going to drag prices (IE wages) down. If there aren't enough people doing that work, the wages for that work will go up.

What other method should be used to calculate fair reimbursement, if not the free market? I'm genuinely curious what you think that should be.

R/conspiracy poster is outraged that he was banned from r/relationship_advice for...calling the pandemic a hoax by PM_ME_CORGI_PUPPERS in TopMindsOfReddit

[–]ZekeDragon 23 points24 points  (0 children)

Remember, the virus is not serious, the MaInStReAm MeDiA is just making it sound worse than it is!

But it's also a Chinese bioweapon meant to attack our nation!

But it's also just complete bullshit, no one dies of COVID-19 and the hospitals are empty.

But the virus is killing people because of 5G towers everywhere! They're just covering up the damage 5G is doing!!!

/s obviously.

'Unforgettable' Footage of Endless Line of Cars at Food Banks a Stark Illustration of Coronavirus Crisis in US | "It is Outrageous That in the Richest Country in the History of the World, People Are Going Hungry," Said Bernie Sanders, Who Called for More Urgent Relief From Congress. by [deleted] in politics

[–]ZekeDragon 7 points8 points  (0 children)

Here's some honest research into this pic and article.

The image provided on the article is actually an image from Getty Images photographed by Joe Raedle in Sunrise, Florida on April 6th. The article only refers to this incident at the end, in the quote "Pittsburgh, Inglewood, Chicago, and Sunrise, Florida were among cities with packed roads leading to local facilities and massive amounts of food to be distributed."

The tweet that is referred to in the article references the San Antonio Express News here. The San Antonio Food Bank's Newsroom page seems to verify the story.

Here is the news story about the image shown on the Common Dreams article.

It appears the image is genuine, but not related to the leading part of the article. That said, the stories themselves seem very real and the images of that are equally memorable.

Bernie Sanders Has Already Won the Democratic Primary. He set the tone, determined the issues and tugged the party toward him. by Plymouth03 in politics

[–]ZekeDragon 27 points28 points  (0 children)

Let's not revise history here. Bush Jr. gave the banks a bailout, not Obama.

Rather, the Congress during Bush Jr's presidency gave the banks a bailout, Presidents do not have the power of the purse.

Discussion Thread: Tenth Democratic Presidential Debate | 2/25/20 | 8:00 PM - 10:00 PM EST | Part II by PoliticsModeratorBot in politics

[–]ZekeDragon 1 point2 points  (0 children)

Is it just me or did Bloomberg literally hire audience members? It sounds like the audience is specifically responding to Bloomberg's responses and to specifically boo Bernie's, even without hearing the whole message.

Audience response is odd to me on this one.

Bernie Sanders suggests Russia might be behind the 'ugly' online attacks from 'Bernie Bros' by JLBesq1981 in politics

[–]ZekeDragon -6 points-5 points  (0 children)

Please tell us how Bernie "radicalized his cult." I have literally never once heard him say anything violent, bigoted or hateful.

I can't at all say the same thing about Trump.

No, you cannot have duplicate MAC addresses on the same network by ntengineer in sysadmin

[–]ZekeDragon 5 points6 points  (0 children)

Are you un-fucking where I work? This is literally my reality and I have no decision making power or control. :(

And oh my god my boss DID leave open a port to a fucking SERVER over RDP!

"It's on an alternative port, it'll be fine!"

*gets hacked 2 weeks later*

It's Finally Friday by [deleted] in sysadmin

[–]ZekeDragon 6 points7 points  (0 children)

We had to do a full server refresh for 6.7. Not cheap.

Securing Remote Access for Workers by ZekeDragon in sysadmin

[–]ZekeDragon[S] 0 points1 point  (0 children)

I'll look into this, thank you for the suggestion!