I quite enjoy writing fish scripts. Largely because I can actually remember the syntax for conditionals and loops.
605 karma · joined November 8, 2017
I quite enjoy writing fish scripts. Largely because I can actually remember the syntax for conditionals and loops.
This is the key, and one of the reasons I love Blue Apron. The meals come in such exactly portioned amounts that the only thing left when I'm done eating is the packaging. There is zero food waste, ever. (Incidentally, this makes an effective weight-loss diet if your problem is overeating like me.)
That being said, I wonder if Blue Apron would still come out ahead of home cooking if you did not attempt to make the same meals but instead more typical home cooked meals. Blue Apron recipes on average are more varied and have more ingredients than what a person would normally cook, so I wonder if the extra food waste is more a consequence of trying to reproduce them.
> It’s easy to write off these tragedies as catastrophically bad judgment.
Yeah, because they are. I have never once thought about risking my life for a selfie. The only thing the author offers to explain why this isn't true is that some selfie deaths occur while the photographer is engaged in “non-risky” behavior. That would make them accidents. Whether someone was holding a phone when an unforeseeable accident befalls them seems pretty irrelevant.
Overall I'm not sure 259 people dying in six years worldwide can be called an epidemic, especially when you consider that they may have died this way even without handheld cameras to document it. It seems very silly to call it “our obsession” with photographing risk-taking when obviously the overwhelming majority of people do not do this.
I'm not a mathematician but this doesn't sound right to me.
My point is that if we want to keep teaching kids connected writing, there are cursive scripts that are easier to teach, easier to write, and easier to read than the one we've clung to for so long.
Entrepreneur is where you have a Twitter full of Gary Vee memes and Elon Musk retweets.
This form of writing was dated as soon as the ballpoint pen was invented, which was in the 19th century. Writing it with a pencil makes even less sense. By tradition we have clung to this terrible writing style instead of introducing something more sensible and modern like italic cursive, which is connected but without loops.
Why do you need to restrict this possibility? How many places in your code create new users, and how many places in your code need to validate users? If the answer is “many,” you have serious design problems that should not be solved by introducing more classes but by restricting how many different areas of code do the same job.
Also, the private constructors do absolutely nothing. The static factory methods in this blog post could be written the exact same way as a constructor, and they would work exactly the same. The only reason the author uses a static factory method is because that's what he was taught to do in Java.
It's just OOP for OOP's sake in a language with tons of features designed for avoiding OOP.
How about this code instead:
export interface User {
readonly name: string;
}
export namespace User {
export function validate(user: User) {
// In "strict" TS, `name` is required at compile time to not be null or undefined.
if (name.length < 2 || name.length > 100) {
throw new Error('User must be greater than 2 chars and less than 100.');
}
}
}
Unlike the OOP solution, there's no guarantee that any given `User` is valid unless you check it with `User.validate`, but there should be minimal places if not one single place where users are actually validated, such as where they are saved to the database or backend.You can also cheat a bit in my experience by waking up maybe 45-90 mins before you normally would, then going back to sleep. The dreams you have in this period should be more vivid and easier to remember.
const foo = { x: 1, y: 2 };
const bar = { ...foo, z: 3 }; // has x, y, and zDon't use that same password for anything else!
I don't really agree that these questions test debugging skill. In real life if I read a bit of confusing code and get tricked, I will usually know immediately thanks to my IDE, compiler, automated tests, debugger, or behavior of the program. On this test if I get tricked, I just lose points.
In my experience most debugging presents as trial-and-error (a terrible test-taking strategy) or seeing a bug and reasoning at a high level which component of the software is responsible and gradually narrowing it down. Carefully reading through lines of code is usually the last step, unless I've got an especially elusive bug.
> And the variable naming quip... are you serious? One of the worst mistakes you can make when trying to read code for understanding is to rely on documentation layers like comments and variable names. Those things lie. Read the code.
I'm not sure what sorts of code you're reading but this opinion seems extreme. Do you really just wholly ignore comments and variable names? I have encountered inaccurate examples of both but I have never thought to distrust them by default. As far as I recall this has not caused me serious issues while debugging.
If a CS student taking this test does not get “tricked” by this question, they should definitely be able to answer it.
And how about this lovely question:
> A personal identification number that opens a certain lock consists of a sequence of 3 DIFFERENT digits from 0 though 9, inclusive. How many possible PINs are there?
Putting aside the value of this question in the first place, the correct answer is 720 but it also includes the answer 1000 in case you didn't notice the emphasis on “different”.
Doesn't seem like a great test to me unless it's about your reading comprehension and ability to decipher code with single-letter variable names.