Hacker News new | past | comments | ask | show | jobs | submit login

>Thus said I would find the other example an ominous sign on the code architecture. I would be more at ease to find a line like :

That's just your bias kicking in. I didn't define the requirements of the program. If I defined the requirements of the program to be ONLY printing out a number that represents the left edge of a box when the measurement is inputted into the console than defining an entire box struct is in itself a code "architecture" problem.

Maybe another name wouldn't trigger any "Smell".

   speedOfLightInVacuumMetersPerSecond = 99999999999....
Is your brain telling you that it should be structured like so:?

   Vacuum.light.speed = 9999999999
Likely no, because it doesn't make sense to place light as a parameter of vacuum... showing that a big long phrase in a variable name is not in itself a "smell" that needs to be "re architected."

You see it is not the grammar of the phrase that is making you want to restructure the code but the contextual meaning. This is one of those optical illusion like triggers in our brain, you want to organize something in a certain way but my post didn't give you a logical reason to do so. I never defined that an entire Box was provided as input.




Of course, context modulates everything. Here the context is an informal discussion to throw generalities on our own feelings on what makes a code readable. Sure, for more specific cases backed with some contextual data, it might be overkill to have a too sophisticated code hierarchy.

For your new example, I would find any of the following more fine:

maximum_celerity = 300 # Mm/s

class Physics { public const speed c = 299792458; }

current_pace = speed(particle: photon, environment: vacuum, unit: Units.parsecs_per_year)

So, I agree, length of identifiers alone is not enough to trigger a "this would be more nicely structured as…", and context matter. "speedOfLightInVacuumMetersPerSecond" is readable, and might be good enough for some specific contexts. But I wouldn’t take that as a desirable practice example.

Just because context matters, doesn’t mean that "all generality are absolute evil" (a statement that condemn itself).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: