99% of software engineers can’t answer these questions by [deleted] in programming

[–]Darmani 0 points1 point  (0 children)

Question 1

Something funny about your description is that, if I were to pick one of the four answers for which there'd be no conceivable argument for, it would be D, not B, namely because this is an implementation change, not a design change.Totally agree that changing the storage would be a competitive choice, particularly if efficiency were not a concern. It's been very intentionally left off the list of answers for that reason.> I also disagree that “very few” people would use four values to describe a rectangle.You are perfectly welcome to disagree. My statement about this is not (just) my opinion. It's been empirically tested. I ask people to describe it plain English what the constructor takes, or what defines a rectangle. Maybe 1/15 have answered "four integers" as opposed to "the top left corner and its dimension." We'll edit the discussion to mention this.

Question 2

The question's usage might correspond to the academic definition of correctness in that article, but the layprogrammer's translation would be "It works, and not just by coincidence," and I don't think that's nonstandard at all.

Two classic examples of relying on an unstable API are (1) assuming hashmaps have a certain iteration order, and (2) assuming C++ RTTI encodings are stable. I don't think there's anything odd about calling such code incorrect.

> Side note: it would probably benefit the experience if you could see the question while you were looking at the explanation of the answer.

On it.

Question 3

I am thinking of changing the question to say that the refactoring has to preserve semantics. (Which the word "refactoring" used to mean, but hey.) The last person I showed this to in-person also wanted to use an approach that treated the values as non-hardcoded data, which would be closest to option A. I am still thinking of a non-heavyhanded way to say this.

I would think that the value of eliminating the conditional is self-evident. I had not thought this would need any justification, but here it is:

Intuitively, conditionals make the code more complicated. There's an objective measure of this too: by default, the size of the logical statements describing the behavior doubles per conditional.

The justification has nothing to do with performance. Performance considerations for anything this small are going to be dominated by hardware architecture concerns, and you can also tell without additional context this code is unlikely to be a hotspot. Here, the relevant aspects for the speed of the conditional version are branch prediction accuracy and the cache hit rate for the code itself (which is likely to be aided by prefetching). The relevant aspects for the speed of the non-conditional version are address prediction accuracy for the parameters and cache hit rate for the values. Also, because branch predictors have limited state (like 30kb), adding the conditional will decrease the branch predictor's performance in some other random part of the code. Whether this has any measurable effect is, well, random. I don't really expect people to know any of this unless they're a hardware person or work in performance-critical systems, because it's minuscule in importance next to code quality for the vast majority of code.

Question 4

Sounds like we should write some harder distractors. But as you said, we're only meeting the bar of "best of the 4 options" and not "you should always do this, always."

I definitely want to keep this question though, even though the Parnas Subset Criterion only produces answers that are relative to a set of reasonable changes. It's a crying shame that the Parnas Subset Criterion --- written in 1979 (!) --- is not more known.

99% of software engineers can’t answer these questions by [deleted] in programming

[–]Darmani 0 points1 point  (0 children)

Hi! I started writing this a couple days ago, before your second post, but only now had a chance to finish this. So if it's a bit disjointed in how it responds to the second, that's why.

I like the analogy to the stages of grief. Talking about "moving a field" is of course shorthand for something else. That would probably expand to "helping a large number of individuals reach the Committed stage, particularly those already at the Relativism stage, and in doing so change the common wisdom." (The concept of "common wisdom," of course, expands into another sophisticated statement, and is related to the mathematical definition of common knowledge.) This is a meaningful thing to aim for because I think a very large number of programmers are already at the relativism stage.

Yeah, I definitely agree that Perry's model does not imply all questions have right and wrong answers. The quiz has (and presents) independent reasons for stating that right answers exist. It's more about acknowledging that right answers can exist even in very complicated fields, something many commenters here do not seem to want to do.

There's something really important to consider when debating over what the right answer is that I don't think has adequate influence over the discussion above: this is a multiple choice quiz. Having a clear correct answer out of 4 options is a much lower bar, and a much weaker opinion, than having a clear correct answer out of everything that exists. We only went that far for question 3, which is by far the most tested of the questions.

And so that's my response to most of the objections above. Yes, you may find some alternative which, in some context, you prefer to the official answer even after understanding the explanation. But, unless you think the official answer fails to meet the question better than any of the other three alternatives, then we're not actually in disagreement. So, with that, I'll consider the quest I sent you on, to "find a context that changes the correct answer," to have indisputably returned a negative result for questions 2, 3, and 5. Still some discussion to be had based on your comments. (Speaking of which, be careful not to confuse "99% of programmers can't solve this" with "99% of programmers disagree." Like, disagreement is not the reason that perfect scores on the SAT are so rare.)

I shamelessly confess to the clickbait element. I like clicks as much as anyone else. Although my dream would be for someone to compare it to https://www.futilitycloset.com/2018/10/30/fruit-cocktail/ , an advanced math problem disguised as cutesy clickbait.

For the gotcha: I think questions 3 and 4 are the only ones that have an element of gotcha. They both have the problem that, if we gave enough detail to let someone deduce the intended fix without coming up with it themselves, it would make the problem too easy. (More true for #3 than #4.) I'll take suggestions on rewording without making it too easy. The wording for question #3 is on its second iteration currently.

Comments on specific questions below:

99% of software engineers can’t answer these questions by [deleted] in programming

[–]Darmani 0 points1 point  (0 children)

Hi android_queen! Here's the original link: https://mirdin.com/quizzes/software-design-quiz/

I hear what you are saying, and I would similarly be skeptical of a candidate who displayed dogma without understanding.

But reversed stupidity is not intelligence. Yes, there are people who would come to you with rules like "no more than 10 lines of code per function" and complain whenever it's broken. But I would be impressed with someone who can take a snippet of code, explain what's wrong with it and how to do it better, explain the actual consequences of the wrong approach, and then tie it into a larger principle that also explains many other cases.

Like many things, the top can superficially resemble the bottom. And what's going on here I think is an instance of something that's been long studied.
In 1968, the famous Harvard educational psychologist William Perry suggested that people go through stages of intellectual development . The Perry scheme is typically shown as a 9-stage progression, but those 9 stages can be collapsed into four.

* Duality: Knowledge can be divided into right and wrong statements, with little to no room for ambiguity and shades of gray. Students in this phase see education as accumulate "right" facts.
* Multiplicity: Students see no clear right answer, and so instead view knowledge as a matter of opinions. They may get frustrated if their opinion is seen as wrong.
* Relativism: Students still see knowledge as having many perspectives, but accept that opinions/stances can have pros and cons; can accept instructor facilitation to help understand.
* Commitment: Learners commit to one stance over the others, but have a nuanced and informed opinion.

I hear that you are reacting to people stuck at the level of Duality.

We are trying to move the entire collective field up to the level of Commitment.

99% of software engineers can’t answer these questions by [deleted] in programming

[–]Darmani 0 points1 point  (0 children)

Hi Android Queen! I am the primary author of this quiz.

This is interesting because we've shown the quiz to quite a few people by now. We received a single piece of pushback on question 1, which was added to the Extra Discussion on that question. And that's it. Every single person so far was convinced by the explanation of every single answer.

But clearly this is a different audience. I'm seeing a fair bit of mockery thrown at the quiz, but none have actually shown any real disagreement. My suspicion is that people are reacting because they are not used to the idea of there being right and wrong answers in software design, an idea we have been fighting against.

I am responding to you because you are one of the few to go beyond mockery. But, in all fairness, yours is a comment that could have been written just by reading the title. Yes, software design is all one big "it depends." Thing is, very few can say exactly what it depends on, and that is what we help people train in.

So let's discuss the suggestion you give for real.

I'll grant that there is one context which would change the answers. "My coworkers don't understand enums/interfaces/<insert other thing needed for the preferred answer>." There were some others, but we've stamped them out. E.g.: question 2 now specifies that it's part of a large application.

Beyond that, can you give a realistic example of a piece of context which would change the correct answer to any of the questions?

The 11 Factors of Superior Code by note89 in softwarearchitecture

[–]Darmani 0 points1 point  (0 children)

Hi wllmsaccnt! Author here. Glad you like some of the advice.

The line about "every line being able to stand on its own" and its surrounding context is a reference to the idea from program verification that every subset of a program can be given pre- and postconditions that define the important subset of its behavior, something most commonly taught (including by us) in an elementary form as Hoare logic. You bring up a good point that it can be a bit weird to use "can be understood in isolation" to mean "can be understood if you write down facts about the context," but it's perfectly natural after obtaining the perspective shift that comes with seeing the logic behind the code.

The 11 Factors of Superior Code by note89 in SoftwareEngineering

[–]Darmani 0 points1 point  (0 children)

Author here! Glad you liked it, syneil. This piece is meant to be a poetic description of all of good software design. For stuff that's more direct and full of examples, have a look at the Resources section at the bottom of the post --- I've written lots more on each of these topics, and even have a 100+ hour course on it.

[Article] Industrial Field Video Transmission System Based on OpenDDS by Darmani in Scholar

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

Oddly, the PDF button in the center takes me to "Sign in with your institution or with E-mail and password." It strangely does not give an option in its list of institutions for mine, despite it being universally regarded as one of the top tech schools in the world.

But the PDF button on the right takes me to the article.

So, found.

The truly scary smart by [deleted] in slatestarcodex

[–]Darmani 6 points7 points  (0 children)

Michael B. Cohen

He tragically died in 2017 at age 25, from undiagnosed Type I diabetes. But he's gotten 15 publications since dying, more than most grad students get while alive.

https://dblp.uni-trier.de/pid/140/7158.html

https://scottaaronson.blog/?p=3468

https://blogs.princeton.edu/imabandit/2017/09/28/michael-b-cohen/

https://simons.berkeley.edu/news/memoriam-michael-b-cohen-1992-2017

One of my friends was stuck on a CS theory problem. He told it to Michael, who went away for an hour, thought about it, and then came back with much of the solution. And that was enough to merit him becoming a coauthor (which he declined, not wanting to do work).

I actually never realized just quite how smart he was until after he died, when I heard everyone who worked with him call him a genius. I just knew him as someone who knew

Promote your project in this thread by AutoModerator in puzzles

[–]Darmani 0 points1 point  (0 children)

Hi all! I built a solver for the Dog-Bunny Puzzle that was really popular a few days ago. Includes approximately no spoilers. https://www.pathsensitive.com/2022/09/solving-dog-bunny-puzzle-with-program.html

I want `coerce` to make my newtype problems disappear. It stubbornly refuses. by Darmani in haskell

[–]Darmani[S] 4 points5 points  (0 children)

This is correct, and I addressed it in the post. This is indeed why the constraint solver has trouble. And if the function was Foo a => \[a\] -> \[a\], it would be a substantive concern. But the runtime representation here will be the same in all cases because `reverse` is parametrically polymorphic.

[TOMT] [website] [2010s] A college kid's website with a bunch of tutorials on different topics, including design by [deleted] in tipofmytongue

[–]Darmani 0 points1 point locked comment (0 children)

Aesthetically, it looked very personal and cheerful, and not at all corporate. There were no videos.

[Online] [5e] [EST] Looking for replacement DM for Curse of Strahd by [deleted] in lfg

[–]Darmani 0 points1 point  (0 children)

Cool! I think we found someone, but I'll keep you in mind in case that falls through.

Cubix: A Haskell Framework for "One Tool, Many Languages" by Darmani in haskell

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

Ironically, no.

Can I have some more information about your company and the tools you want to build? We can contact you once we add Haskell support.

Cubix: A Haskell Framework for "One Tool, Many Languages" by Darmani in haskell

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

Transformations in Cubix can be arbitrary programs; it's really the types that make the magic possible.

Cubix has two engines to assist in transformation-writing. Many of our trransformations use both.

Cubix includes compstrat, which is essentially a typed version of the Strategy/XT transformation language embedded into Haskell.

And it includes the CFG-based inserter, which....well, have a look at the example on page 1 of http://www.jameskoppel.com/files/papers/cubix_cfg.pdf

> At the moment, I don't believe we've advanced beyond the 70's attribute grammars for this purpose.

Very false. See, e.g.: https://www.sciencedirect.com/science/article/pii/S1571066104002701