Live data from Hacker News

Ask HN: Concepts that clicked only years after you first encountered them?

news.ycombinator.com

151–160 of 946 posts

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#151

Earlier quoted context omitted.

Seven years into my career I'm increasingly convinced that the emperor has no clothes with respect to unit tests that are just transcripts of the code under test with "mock.EXPECT()" prepended to everything - 95% by volume of the unit test code I've ever read, written, or maintained.

Yep, I think mocks are mostly a smell. The "functional core" of a module should be entirely or almost entirely unit testable with (possibly fake) dependencies passed in. The glue code ("imperative shell") should be tested at a higher level - "integration" or "end to end" or whatever you want to call it - which looks at the externally observable effects of running the code (database changes or API responses or whateve…

Amen. I have been frustrated at many jobs where developers were so proud of endlessly writing mocks and spending more time on their tests than on core functionality.

Over time I have favored very basic unit tests and leaning in more on automated integration and regression tests. I know the theory of unit tests catching things earlier, I just don’t think it matters in practice.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#152
f(x) = y etc in linear algebra in school. By the time I was learning this in high school I’d already been programming for several years and perfectly understood the concept of function inputs and outputs. It wasn’t until my early twenties that I realized this was just an alternate notation for functions and was so simple.

Sad that my math education was just focused on “memorize steps” for concepts that weren’t clearly explained.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#153
In OO, the interface. It seemed like the most useless construct. Zero implementation. Why make something with no implementation?

Later I realised that the benefit isn’t the code, it’s the freedom you gain later in choosing the implementation. You can create an interface and add a simple implementation, then later swap it out for something more robust. All you’re agreeing to now is the contract of what needs to be done, without any restrictions on how.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#154
Voltage and amperage for me, years after a college electronics course and a childhood of soldering kits I finally started to get it. I was always tripped up with analogies about how it's like water in a pipe or something, which can be useful, but aren't quite right.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#155

It took me an embarrassing amount of time to fully grok what object oriented programming really means. It's one thing to have someone tell you what an object is, but it's another thing entirely to build a fully object oriented system. I remember what made it click: I was designing an animation system, which had a bunch of different interdependent moving parts. Once I started treating each part like an object and lett…

My first job was doing mostly Lego-pieces greenfield development. I learned a lot, but also didn’t learn as much as in my second job where I started having to work with a much more complicated, slightly “legacy” system with a big codebase.

At small code sizes, OO does not really have any apparent advantages to doing everything imperatively or in a hacky way. In fact I’d argue it tends to overly complicate and obfuscate things. But there is a point at which you really start wanting OO instead because you can no longer reason about the binary as a whole, and need to start thinking in terms of interfaces with separation of concerns. Even if you did understand the whole state, there are too many people working on it to keep up with changes to the whole state in a way that lets you reason about the thing as a whole.

At my first job (and in college) code never reached such levels of complexity so OO always seemed like some dumb fad to make things more complicated than necessary. I still that is often the case, but now I absolutely see the benefits when they present themselves.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#156

Earlier quoted context omitted.

> dependency injection The term is unfamiliar to me -- is it related to "fault injection"?

Going to steal a description I wrote for a blogpost several years ago, when I had recently understood DI for the first time so it was very fresh in my mind: https://hasura.io/blog/build-fullstack-apps-nestjs-hasura-gr... Dependency Injection solves the problem of when you want to create something, but THAT something also needs OTHER somethings, and so on. In this example, think about a car. A car might have many sepa…

I'd probably reach for a Builder pattern first for that rather than go full DI container.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#157
post #86

The power of an outline when writing. Over the past few years, I've been teaching myself how to write better. I'm not talking about elementary syntax or grammar. I'm not talking about writing the traditional, American English five paragraph essay. I'm talking about writing longer pieces of prose, articles or blog posts or short chapters with word counts ranging anywhere between 1500-3000 words. On this journey of imp…

This summer I read "On Writing Well" by William Zissner which was an eye opener for me. I'm far from an expert in writing clear texts, but I am definitely noticing more text which are just... big balls of blurb that don't actually say anything. All because of that book. It sounds dumb, but this year it clicked for me how big of a difference a poorly written text compares to a well written text. Hope your training pay…

Zinsser's "On Writing Well" is one of my favorite books, I like how clear and concise its prose is.

I got Joseph M. William's "Style: Toward Clarity and Grace" recommended [1] so you might be interested in it. I read the introduction (I'm planning to read it this year) and with the few examples the author presents it sells the idea that prose doesn't need to be utterly complex to communicate ideas and concepts succinctly and clearly.

[1]: https://news.ycombinator.com/item?id=33601492

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#159
It took me a long time to grasp market economics. I knew it worked somehow but I didn't quite understand why. What really made it click was Milton Friedman's "Free to Choose" TV series[0].

[0] https://www.youtube.com/watch?v=dngqR9gcDDw&list=PLXD32Z5YYi...

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#160

It took me an embarrassing amount of time to fully grok what object oriented programming really means. It's one thing to have someone tell you what an object is, but it's another thing entirely to build a fully object oriented system. I remember what made it click: I was designing an animation system, which had a bunch of different interdependent moving parts. Once I started treating each part like an object and lett…

I've always found OO programming completely natural. n fact, it's the only kind of programming i've ever really done - create a structure with data members, and then create functions to work on that structure. you can (and should) do this in low-level languages such as C and assembler. Of course, if you want to go the whole polymorphic route, i'd suggest using something like c++, but the key ideas are really structur…

As someone who started programming in BASIC, OO is a really good way to think about stuff (it introduces the abstraction of “conjoined data” that is typed and has functions) but it was not natural. It just feels natural now that I’ve spent so long in school and at work dealing with OO languages. I imagine if you had started with BASIC you’d feel the same
Post reply on HN