Naming things is suddenly easier
Naming things is good skill to have for any programmer.
Read more [masteringlaravel.io]
Posts tagged with naming
Naming things is good skill to have for any programmer.
Read more [masteringlaravel.io]
– clig.dev
Good naming, consistency, clear communication, and discoverability. These are things that do not only apply to command line programs, but to general development as well.
Read more [clig.dev]
Join 9,500+ smart developers
Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
Passing booleans to a method can be code smell, as it is not clear what a boolean does by reading the calling code.
Andraes Möller blogged a few interesting strategies to name the constructors of your PHP objects.
Read more [localheinz.com]
Shawn McCool shares some interesting thoughts on how things should be named.
Read more [shawnmc.cool]
Kevlin Henney makes the case for not suffixing class names, or files with the type of object it contains.
Read more [kevlinhenney.medium.com]
Sometimes it is not clear what the responsibility of a certain class is. This can be solved by adding a suffix to the class name.
Kevlin Henney wrote a good post on the importance of naming things well.
Good naming is part of design. It sets expectations and communicates a model, showing how something should be understood and used. If you mean to tell the reader getMillisSince1970, don’t say getTime.
Read more [medium.com]
React lead dev Dan Abramov makes the case for naming your ideas and projects.
The problem it’s solving might be so ingrained that we don’t even notice it. It’s the elephant in the room. And we can’t discuss what we never named.
Read more [overreacted.io]
?️ Use "declarative" (the state of the thing) names for your data attributes in Vue over "imperative" (an action to take on the thing) pic.twitter.com/LJk2MRT0Bw
— Caleb Porzio (@calebporzio) November 19, 2018
Read more [twitter.com]
In a new post on his blog Sebastian De Deyne shares a few services and tools he uses to help him with naming things.
One of the hardest (and sometimes frustrating) tasks in a programmer's day-to-day workload is naming things. When I have a hard time finding that perfect word, I generally wind up in one of two situations:
Luckily, there are tools out there that can be of help.
https://sebastiandedeyne.com/posts/2018/a-pair-of-helping-hands-when-naming-things
Michael D. Hill posted a great new video on his blog where he makes the case for optimizing for scannability.
As programmers trying to ship more value faster, we want to optimize first around the part of the work that we spend the most time on, and that is scanning code– formulating little, tiny questions and flipping through the code looking for the answers. We optimize for scanning by focusing our attention on sizing, grouping, and, above all else, naming.
http://geepawhill.org/optimizing-a-program-and-programming/
? Symmetry in naming is a powerful tool I never gave the weight it deserves. Embrace the visual relation! A common example in Vue: pic.twitter.com/QEBbHDUvWY
— Caleb Porzio (@calebporzio) November 9, 2017
Read more [twitter.com]
In a new blogpost on vemv.net the author (I couldn't find his real name) argues against using a simple status field.
Dear programmer, do you ever use the name state for your variables? Like state = 42? “Hell no, that’s a terribly generic word. Better to use the domain-specific wording the variable refers to: is_invoiced, visit_count, shopping_cart, things like that.”Sounds reasonable. But sometimes, you have a database column called status, and use it through your codebase, right? “Yes.”
Were you aware that status and state mean basically the same thing in English? “Uhm…”
Mathias Verraes, one of the organizers of DDD Europe, recently gave a talk at DDD London on how to name things to both improve your code and to improve communication with the business.
“Make the implicit explicit” must be one of the most valuable advices I ever got about software modelling and design. Gather around for some tales from the trenches: stories from software projects where identifying a missing concept, and bringing it front and centre, turned the model inside out. Our tools: metaphors, pedantry, type systems, the age old heuristic of “Follow the money”, visual models, and a healthy obsession with language.
Generally I don't like to abbreviate variable names. This answer on Quora lists a few situations where an abbreviation is probably ok.
There is a simple (but unsatisfying) answer to all questions of this form: they are acceptable when they would make the code clearer.This can happen in a few ways. The most common, as you noted, is convention: i, j, k for loop variables, x and y for coordinates, e for exceptions, f and g for functions and so on.
Another is structure. Often, the broad structure of an expression is more important than its contents. Using shorter variable names makes it easier to read at a glance. I think this is often more important than being easy to read in detail!
If a variable has a very small scope—say one or two lines at most—and it's easy to see where it comes from, having a long name is just noise.
https://www.quora.com/When-are-single-character-variable-names-acceptable/answer/Tikhon-Jelvis
I've been using PHP for quite some time now, and I had never heard of class_alias before reading this post by Fabian Schmengler.
Sometimes you want to rename a class or move it to a different namespace. But as soon as it is used anywhere outside the package, this is breaking backwards compatibility and should not be done lightheartedly.Luckily there is a way in PHP to have both, the old class and the new class, while deprecating the old one: class_alias().
A great story by DHH on his quest to find good names for some functions he was working on.
One of the real delights of programming is picking great variable, method, and class names. But an even greater treat is when you can name pairs, or even whole narratives, that fit just right. And the very best of those is when you’re forced to trade off multiple forces pulling in different directions.
https://m.signalvnoise.com/hunting-for-great-names-in-programming-16f624c8fc03
JavaScript practically requires callback functions to do anything asynchronous. Unless you’re talking about generators, you really can’t get away from them. Callbacks are everywhere.http://derickbailey.com/2016/02/15/what-do-you-name-the-callback-function/...
I do use different names for the callback parameter, depending on the circumstance. I believe naming is important as it provides a set of expectations. If your code breaks the expectations of the name, people will be confused and it will cause problems.
Correctly naming things is the most difficult programming task (except for documenting). However, this is only because we often afford these tasks insufficient consideration. As with most things, the more we do it the easier it becomes. In this article we will discover how to choose correct names for our methods.http://codelegance.com/semantic-method-naming/