Question of the Week: Thinking Like a Programmer

What does “thinking like a programmer” mean, in practice? Let’s community-source some answers!

1 Like

Programming is great because you can always change the code, change the design, try it over and over again. Real life is not so forgiving!

3 Likes

for me, programming is about outsourcing tasks from me (the human) to someone that can do them better, faster, and without complaining (the computer, some tool, a bultin function, a 3rd part library, a new function).

e.g.:
sure, I can organize my mail inbox, but writing a gmail filter is almost as good, and doesn’t require me to do it.
I can keep a table of expenses and sum them by month, but Excel will do it better.
when I write code and I need to sort an array, is it the best use of my time to write a sorting algorithm? isn’t there someone who has done it already?
if my code need to compare to objects of the same class, do I really need to compare the attributes each time? can’t i push it into some function and update it just there? (DRY)
now that I have this nice function, I don’t want there to be a chance that I used it for nothing, and I don’t want to search the codebase by hand for each occurrence. it’s much easier to stick a tool like a complier warning to tell me that I’ve forgot to use the return value.

everything that can be done by in a reliable way without my involvement, should be done by the code. let me worry only about the important things.

1 Like

For me “thinking like a programmer” is about abstraction, and seeing the world in a certain abstract way:

as entities (classes, objects, modules, … )
with certain attributes (variables, states, class properties, … )
and operations ( functions, methods, sql-queries, … )
in relation to each other (class extension, composition, … )

Whatever language/environment/framework/library I use, whether I use OOP or not -
no matter if I am thinking about the structure of a React app, writing an api or setting up a database -
I am always building abstract models of reality.

3 Likes

Coding is cool. Programming is Awesome!
Programming is different than coding. Programming embraces conceptual aspects of problem solving. Programming is coming up with systemic solutions based on logic and experience and it relies on understanding goals, obstacles and resources.

Conversely, coding deals with language, library and framework particulars. Coding relies on familiarity with classes, functions, queries and modules, as well as the syntax involved with each. Effeciency in knowing what functions to call, what modules to write and what outputs are retrieved from what are requirements in coding.

Coding experts are limited to the languages with which they are familiar.
Programming experts can transform conceptualized solutions into whatever language is needed.
Coders ask “Where is the button that should I push?”
Programmers ask “What should the button do?”
Coders create using the form insuring it fits the function.
Programmers create the function then find the form that works best for it.

Thinking like a programmer means that you can concentrate efforts on logic versus being bogged down with limitations of any particular language. Solutions are the forefront of a programmer’s thought process, instead of worrying about whether the language has a module that performs that function.

Thinking in terms of concepts is the biggest marker of thinking like a programmer.

But of course, this is just MY opinion!!
Enjoy

2 Likes

To is or to is not. :laughing:

So far for me it was a lot of Logic. At those really hard moments, and moments later (maybe decades) when we figure out the solution … it is really something easy/simple sometimes. And if I had put more “Logical Thinking” into it, I would definitely solve it faster. But I guess that’s programming for me right now. I hope that others relate to this :grinning_face_with_smiling_eyes:

2 Likes

My two cents on this topic: Let’s change the human first assumption of the statement:

You need to try to start thinking like the computer does. The computer never acts unexpectedly, the humans tinkering away do.

Taking that reciprocal assumption on board, when there is- let’s call it a difference in opinion. What structures do you need to refactor to make sure you’re getting the right stuff out of your trusty machine? And when the wrong stuff comes out of your machine you still rightly find it fascinating.

  • For example: Say your writing a sweet To Do list app. (Good For you BTW… You go App maker !!). Let’s say when you add a new To Do …It adds 4 instead. You don’t break down and say something along the lines of : Why Have the Chips forsaken me? You go COOL! Okay let’s pop open the debugger and figure out this behavior and go over it line by line. You not only delight in understanding the unexpected behavior you figure out a way the computer will understand what you.

  • You try to expand your knowledge when your stuck. This can mean YouTube, StackOverflow whatever your jam is and and try everything including but not limited to chatting with you fine folk on the forums here. And when you do come you do list what you’ve tried and didn’t work including but not limited to the steps you did in encountering the gaps in your program. Even if it is a weird triple click of a button that requires some years of gaming experience to achieve,

That’s all I got … And looking at the human side of it: We need these clever boxes to solve our silly human things. So … maybe a little bit of - I don’t like the phrase common sense but - maybe observant of the real world? Because everything is obvious when you know the answer? And what is common to you is uncommon to someone else isn’t it?

  • What I mean by that is take for example if you look at “Passing the Technical” in JavaScript the Rain Water example: Understanding that your limited by the shorter buildings because water will overflow. The computer doesn’t care about water other than staying away from it. Take time to notice these things because it will impact what you want your code to be able to express.

That’s all I got. But if this was TL DNR: Thinking like a 'Grammer means thinking like a computer and not making the computer think like a human. You’re probably going to make the computer do a long of wrong things before you make the computer do what you want it to do. The mistakes are a lot of more magical than you think and thank goodness for the get unstuck button in the meantime right ? And in case this didn’t at all speak to you Take this any way : :doughnut:

2 Likes