4
Reading this question I came across the following sentence:
There are only two hard problems in Computer Science: cache invalidation and naming Things.
-- Phil Karlton
The focus is on the second problem that is to name the things, which seems to be referring to variables, functions or anything else in programming. Of course this can be a kind of "joke" too, seeing that it seems simple to name things xD. However, when we realize, it becomes a somewhat complicated task.
At least for me, it is often complicated to give name to functions and variables, even classes, I always wrap myself in the meaning that that code should pass and makes me think a lot about its interpretation, different from mathematics where the shape helps to visualize patterns.
Here are some examples of names of methods that have become very long and that I have had difficulty naming in the past:
EstaNoCaixaAbertoDoDiaAtual(int idBaixaServico)
Caixa.ObterIdDoCaixaAbertoNoDia()
ExisteRegistroDeAberturaPendente()
And there are even native PHP functions like geoip_time_zone_by_country_and_region
or mailparse_determine_best_xfer_encoding
which has a somewhat long and complicated name. This may repeat in other languages and libraries, but I will not list them all here.
I could even decrease the names by creating classes or making another kind of separation, which leads me to think that object-oriented programming is to help name things after all (of course it goes much further)And all this verbosity leaves the task of appointment very costly, no doubt it seems.
Against this background, I would like my question answered.
Question
- Why is it so difficult to name things, is there any way get around this problem?
I read your 2x text and I couldn’t get the point. You mean: naming variables, functions, classes? If it is, I humbly and with all due respect, find the easier part of the code.
– Sam
Putz, I was going to answer this t, but I’m with p last x i yet and I can’t figure out what the variables t, p, x and i are.
– Woss
Overall, I think the naming process requires that the solution is properly structured; and structuring the solution requires mastery of it; and mastering the solution requires mastery of the problem; and mastering the problem requires being able to understand the name of things;
– Woss
Just in case, name things after facial hair (Beard, Moustache, Goatee) and delegate to the reviewer find the appropriate name!
– Jefferson Quesado