DEV Community

Discussion on: Other People's Code and the Intentional Fallacy

Collapse
 
scotthannen profile image
Scott Hannen • Edited

I'm struggling with this because to me, both communicating and understanding the intent of code are necessities. That's why we give classes, methods, and variables descriptive names. Describing intent is also a purpose of unit tests.

Naturally we must at times be able to distinguish between the intended and actual behavior of code. Finding that difference and the reason for it is how we fix bugs. Without knowing intent, how would we even know if code works as expected? How could we do a code review if the coder and the reviewer couldn't communicate about the intent of the code? How could we judge whether it was well-written without knowing its intent?

Collapse
 
val_baca profile image
Valentin Baca • Edited

OP can correct me, but this discusses code once written While in CR, the code is still flexible.

they argue that even notes about a piece, or contemporaneous journals from the author at the time of the piece's writing, are still only secondary sources for deriving authorial intent, and that pieces of work as an end product are always the primary source

That said, I do think you're onto a point. Literature is art; code is not. This is an art to coding (i.e. "The Art of Computer Programming"), but only in the verb form of programming itself. It's not "The Art of Computer Programs".

Unlike written literature, the code we write, read, and maintain are mutable and mean to be modified for a given purpose. There are certainly critiques that can be be used across both fields, but they'll eventually be limited by the fundamental differences in the two fields.

Collapse
 
nektro profile image
Meghan (she/her)

What I got was that there are two types of optimization.

1) rewriting the implementation of a function to be faster or more efficient
2) making it so that function never has to be called in the first place.

What I think OP is trying to say is that we should be trying to do method 2 a lot often when we refactor, but it can be hard to determine why the function was written in the first place simply from the function's existence.