TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What was your “eureka” moment while programming?

3 pointsby minionslaveover 8 years ago
My Eureka moment was when I figured out what interfaces were for.<p>I never understood the difference between interfaces and abstract classes. I asked on online forums and stackoverflow the typical answer I got was: &quot;An interface is a contract that you define... A class has to implement the methods defined in the interface for it to work.&quot;<p>&quot;Why do I need to use a contract if I can can simply implement the call the methods directly? Why do I need that middle man&quot;. I was working on a small web api project with Nancy, MySQL lite was used initially, but, I wanted to use a database like MySQL or PostgreSQL. The small project I was working on to learn Nancy needed refactoring. So, I asked myself &quot;What if I could swap database at will&quot;. That when all the concept of interfaces came together.<p>I could simply use an interface as a mediator, which mean defining methods inside an interface, as long as the code calling the database implements these methods, things will work fine.

1 comment

hoodoofover 8 years ago
Understanding how to pass functions.<p>For me this was more important than grasping object oriented programming.<p>The second deep insight was that programming is less about language syntax and mostly an exercise in manipulating data into and out of common data structures such as arrays and hashes.
评论 #12485534 未加载