On the topic of resourcefulness when writing code

I heard someone in a Codecademy video say “Googling is 80% of a software developer’s life.” This was a relief to hear because, for like 20 years, I felt like an inferior coder because I couldn’t solve problems without searching for the answer. (Interiority complex is a real thing …)

My question is, when is this resourcefulness, and when is it just copying the code you find and modifying it for your needs? What do you learn by searching, landing on a Stackoverflow page, copying some code, and then modifying it so it solves your problem? Do you learn as much as you would by trying to solve it on your own for half an hour and then going to other sites and borrowing code from the developers who went before you?

If I modify some code I find on the internet, I try to at least read through it and understand what it’s doing before I paste it into my code editor. Is that enough?

I guess what I’m looking for is your process for learning … at what point do you stop dealing in theory and start looking for the specific answer to what you’re trying to solve? Does that matter?

Thanks for pondering this with me.

As the great William Shakespeare wrote,

“The fool doth think he is wise, but the wise man knows himself to be a fool.”

There is, I would argue, never any harm or grounds for derision in realising one doesn’t know something and searching for an answer. :slight_smile:

I think this would depend on whether you understand the solution that you come across.

Blindly copying and pasting blocks of code from somewhere like SO, which we may not understand entirely, at best represent a missed learning opportunity. At worst, you could be introducing some serious errors and vulnerabilities into the program.

If you’re searching for a code snippet to aid you in solving a problem you’re staring down, and taking the time to look into why that solves the problem and improve your understanding rather than simply saying “Eh, it works…” and moving on, then I’d say you’re fine. It might take a few iterations before a particular programming pattern or method sticks and you can recall it easily, but that’s part of learning.

I’d say it’s not so much about arriving at a point where you recognise that what you know at present is insufficient and going to find an “answer”. It’s more about realising that you don’t know X, finding a solution using Y and Z, and utilising that to expand your knowledge.

It’s the same as if we were discussing homework at school; those who do it themselves learn the material, by studying it but also by making mistakes and figuring out how to resolve them. Those who simply copy what they presume to be “correct” don’t.

3 Likes

Spot on.


@redfrau

I’d say that, two problems, although they may look fairly similar (trying to achieve a similar goal) are never entirely the same. Blind copy-pasting might not always fit within one’s attempt to fix said problem.

Which in turn brings new opportunities in finding alternative ways of solving a problem that has now been extended through third-party influence. This could, however, lead to a vicious circle.


Then there’s the problematic of determining the best path towards a solution. I reckon it’s quite common practice among newer devs to reach a presumed solution by adding blocks of code they have a limited understanding of. You can usually easily spot code that originated from some obscure blog post 12 years ago. I see this happening a lot in the PHP community. It might work at first, but one could ponder on the ramifications if it were to break down the road.

What then? Can it be detected, let alone fixed? Does it pose a security risk one’s not aware of?

If one’s not able to understand it, and comment it, should it be used in the first place?


The other aspect I see, however, is the principle of not reinventing the wheel. Making use of third-party code could prove helpful in one’s attempt to reach a working solution faster, better, without spending precious time on yet another attempt in coming up with an already established solution. This is what libraries, modules, and frameworks generally help solve (speaking of resourcefulness).

3 Likes