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…
Ask HN: Concepts that clicked only years after you first encountered them?
181–190 of 946 posts
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#182Earlier quoted context omitted.
Another solution is to eliminate classes and only use structs or similar plain objects. Makes mocking and testing functions much easier. At this point I see no reason for OOP whatsoever and consider it a big mistake.
I agree with OOP not being needed at all, but I don't agree on this being an alternative to dependency injection. However you structure it, there will always be "glue code" that ties the nice inmutable code with the outside-interacting bits, and if you want to unit test those, dependency injection (with functions or state, not classes or instances) is still the way to go.
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#183I'd "understood" the concepts before, but now because I am:
- brushing up on my math to understand every equation or proof they drop in there
- reading them in combination with applied stuff that uses the same concepts, ie the "designing data intensive applications book"
- reading over them slowly, I want my fundamentals to be strong and etched into my head
Things are clicking in a way they never did before.
TL;DR - studying compsci concepts, slowly, from multiple angles (completely mathematical to practical engineering) is just a different level of understanding from doing one or assuming your mind will bridge the gap.
YMMV.
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#184Voltage 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?
#185Unit testing and using dependency injection to write test-able code. I'm not sure if it was years, but it wasn't immediate. I just didn't understand why dependency injection was good at first, and not just someone's weird personal code style choice. I thought it was just people being "Enterprisey" which I'd encountered many times over the years. Once I committed to unit testing, I realized how necessary it is. Unfort…
> dependency injection The term is unfamiliar to me -- is it related to "fault injection"?
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#186Basic music theory. Almost no one I encountered bothered to actually explain anything. They simply regurgitated things and I guess expected me to somehow intuitively understand something or other.
Any good resources that do it the right way?
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#187Earlier quoted context omitted.
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…
How are mocks a smell if "unit testable with (possibly fake) dependencies" is okay? That's what mocks are. Or do you mean specifically "expecting" interactions with those mocks? Because I agree that's usually not that valuable.
Ideally, service/library owners would write and maintain the fake to ensure that it stays in sync as changes are made to the actual service.
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#188One of the big aha moments which clicked for me only fairly recently was staring at some physics equations my own internalized realization that light doesn't experience time and then I had to tell everyone haha - but that one eureka moment unlocked a whole lot of understanding and certainly a lot more questions. This of course was after all the schooling and physics where it somehow sailed over my head the whole time…
I woke up at 2am with the intuition that light was like a lightning strike across spacetime, with no time and no distance between the emitter and absorber.
Why and how, though. What are the fully-baked implications.
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#189Things like Repositories, Aggregates, Bounded Contexts, and so on are going to be a net drag on your system if you only have a few 100 kloc of code in a monolith. But they really start to shine as you grow beyond that. Bounded Contexts in particular are a gem of an idea, so good that Uber re-discovered them in their microservices design: https://www.uber.com/blog/microservice-architecture/.
(Edited to clarify the book author)
Re: Ask HN: Concepts that clicked only years after you first encountered them?
#190[0] https://en.wikipedia.org/wiki/Axiom_of_choice
[1] https://en.wikipedia.org/wiki/Tychonoff%27s_theorem
[2] https://en.wikipedia.org/wiki/Open_mapping_theorem_(function...