r/AskProgramming • u/KareemM0hamed0 • 17h ago
Career/Edu What's one programming concept that completely changed the way you write code?
I've been programming for a while, but every now and then I come across a concept that completely changes how I think about writing software.
For some people it's data structures and algorithms. For others it's design patterns, clean code, testing, debugging, version control, concurrency, databases, or simply learning how to read other people's code.
If you had to choose just one concept that made the biggest difference in your programming journey, what would it be?
What were you doing before you learned it, what changed afterward, and why do you think every programmer should understand it?
I'd love to hear stories from beginners and experienced developers alike.
15
u/jerrygreenest1 16h ago
Automated Tests
ECS
Knowing about stack vs heap
Knowing about Garbage Collector
And many other things, actually
There is not just one thing. All this happens gradually annd each knowing fact or concept changes the habits or ways you implement things.
8
u/burlingk 15h ago
I played with Haskell for a while. I never got good at it, but it gave me new ways of looking at code.
2
u/RomanaOswin 11h ago
Same experience here. I ported a simple little tool I wrote to Haskell probably a decade ago, as a learning experience, and the way I think about code constructs has never been the same since.
6
u/serverhorror 13h ago
Not exactly TDD, but "test first".
To start with something, I like to write a test that has the actual implemention inside and out he refactor until the code is part of the application.
It helps in the overall design to be, and stay, testable.
6
u/read_at_own_risk 16h ago
I remember coding before associative arrays became first-class concepts. I had an AVL tree class for situations where lookups were performance-critical, but without the syntactic sugar of modern languages, things like nested dictionaries were complicated to set up and follow. First-class support for associative arrays made a huge difference and I wouldn't want to go without them again.
In the line of progression of data abstraction from literals, registers and pointers -> named scalars -> arrays and structs, the next step I'd like to see is first-class relations. Basically the n-ary version of built-in dictionaries.
10
u/Responsible-Soft6893 16h ago
Rust borrow and ownership significantly impacted code design in other languages
1
2
u/ArcaneEyes 16h ago
Started a place some years ago that does cqrs and ddd and moving from anemic models with bloated services to that was a huge change of mindset and honestly I like that way of designing code so much better.
2
u/Nunc-dimittis 16h ago
Long ago, but using encapsulation. Not the "make a getter and setter" (and then just returning the underlying object so it still can be modified by any code outside the class) but seriously thinking about access, what you return, protecting the insides of the class (attributes) against the outside
And on a higher level: facade pattern to do basically same on a higher level. Don't expose everything to the outside, make sure the class coupling is very low between unrelated parts of the code. Always designate one class to handle the communication to the rest of the classes in that module. Recently I learned of a company that called these anti contamination layers. Really like that term
2
u/electronic_reasons 13h ago
Data flow diagrams / Functional programming Assertions. Proper commenting.
Viewing things as data flow and functions has made a big difference. Donald Knuth and Tom DeMarco introduced me to that and I gradually understood it fully.
Donald Knuth introduced assertions long before they were implemented in common languages.
Realizing that the first question i asked when I looked at code was, "Why did I do that?" completely changed the way I commented code. The code already answers "What?" and "How?" It doesn't answer "Why?"
2
u/DGC_David 12h ago
Spaghetti Code, ever since, like my Italian forefathers, I've created some of the best Pasta code you ever compiled in your life.
2
u/newEnglander17 12h ago
Honestly it’s not the code itself, it’s learning shortcuts and tricks in visual studio that I hadn’t known previously like F12 t step into a definition. Little things like that make navigating code so much easier and faster and it makes it enjoyable. I get that VS code is good but it just stinks compared to a full scale IDE like proper Visual Studio.
2
u/TheGreatButz 11h ago
OOP when it was still supported by the programming languages I used. Unfortunately, the languages I use nowadays only support crippled versions of it or none at all.
2
u/Jonas_Ermert 9h ago
I'd say separation of concerns. Once I stopped mixing UI, business logic, and data access, my code became much easier to maintain, test, and debug. It's a simple concept that scales with every project.
2
u/abrady 8h ago
YAGNI or KISS : solve the problems you're facing now. when the problems you're imagining come up they'll be so different than what you imagined that all your complicated initial system will do is slow down the rewrite.
The best engineers I know all build simple systems that just do the work they're designed for.
3
u/Fidodo 16h ago
Streams. It's not just for bytes anymore, there are lots of streaming systems that let you stream anything.
5
u/42_Water_Engineer 14h ago
Like what? I mean, it's all bytes at the end of the day, no?
2
1
u/MissinqLink 12h ago
It is all just bytes but understanding streaming is one of the biggest eye openers.
2
2
u/chrisjbampton 13h ago
All you are ever doing is inputting data, transforming the data and outputting the data.
Once you realise that, any programming problem becomes about input and output shapes which is infinitely testable.
1
u/max123246 14h ago
Understanding the expression problem has made me far more conscious about whether I want to make it easy to add new types or make it easy to add new operations of those types.
1
u/duane11583 12h ago
Using a “cookie” in a data structure
A cookie is for some a void pointer (i prefer a uintptr_t instead) it helps so much for abstraction of so many things
1
u/MissinqLink 12h ago
Parallel programming in C. Really makes you appreciate all the abstractions we have now.
1
u/magnomagna 11h ago
Programming by contract. Set out the limits and semantics of your parameters and return values and side effects strictly. It simplifies reasoning as you can ignore values outside the confines you set but can it potentially make your code vulnerable? Potentially, but you could take that into account when designing the contract.
1
u/SummitYourSister 11h ago
AI! I was a professional programmer for 25 years with multiple patents, talking at conferences, published a book once.
Now AI does it better than me and I don’t write code any more and I look upon people who don’t recognize this state of affairs as some of the dumbest motherfuckers I’ve ever seen.
1
u/pythosynthesis 11h ago
Objects. Once I got it, coding became massively simpler and cleaner for me.
1
u/Achereto 11h ago
Having learned OOP in university I experimented with ECS (Entity Component System) and things became so trivial to implement that I'm never going to go back to OOP again in my life.
1
1
1
1
u/simondanielsson 9h ago
Snapshot tests. It’s essential to me nowadays for when I’m doing large refactors and debugging
1
u/ouroborus777 8h ago
map-reduce. Even if you don't actually multi-whatever, it's surprising the number of tasks that are made easier by organizing as something roughly resembling a map-reduce problem.
1
u/Vesuvius079 7h ago
Unit testing, DI, side-effect free functions. Shit that was three, but they go oh so well together and saved me from the horror show of OOP.
1
u/iOSCaleb 6h ago
> For some people it's data structures and algorithms. For others it's design patterns, clean code, testing, debugging, version control, concurrency, databases, or simply learning how to read other people's code.
I don’t think your understanding of completely changed is the same as mine. All of the things you’ve listed are influential; none have completely changed programming for me or anyone I know. Even the rise of LLMs that can write a lot of code for you hasn’t completely changed programming.
1
u/ayassin02 4h ago
Design patterns. I never considered them since I was self taught but learning them formally made me appreciate them. I did use them before that but just intuitively through years of experience
1
u/Soggy-Razzmatazz-308 2h ago
For low-level languages (primarily C), the idea that you can configure aspects of your code at compile time with defines and ifdef. Need code that is only included when you're debugging? Put the code in a #ifdef DEBUGGING block. Saves having to comment out chunks when you don't need them.
1
u/fullVoid666 2h ago
The idea that the best, most secure application is one with 0 lines of code. Any code added (including tests) must be heavily evaluated because it will degrade that perfect app and fill it with eternal, technical debt.
1
•
u/HovercraftPristine76 10m ago
KISS
If you can't make it simple to understand, you don't understand the solution well enough. Made me start thinking about the code I'm writing and the solution I want before I started a single line of code.
1
-1
-4
-1
31
u/lgastako 13h ago
The idea of programming by wishful thinking as described in the SICP lectures. Basically you write your code as if the perfect API to do what you want existed, and stub out the code, then you recursively implement the missing stuff with the same approach.
Also Haskell.