The object/class/thing would normally be its own class file, the action would be a method/function of said class.
Ie:
fileDialog.open()
fileDialog = Class (Dialog), Subclass (FileDialog)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
The object/class/thing would normally be its own class file, the action would be a method/function of said class.
Ie:
fileDialog.open()
fileDialog = Class (Dialog), Subclass (FileDialog)
There is a reason why little endian is preferred in virtually 100% of cases: sorting. Mentally or lexicographically, having the most important piece of information first will allow the correct item be found the fastest, or allow it to be discounted/ignored the quickest.
I was going to write something like this. You actually wrote about semantic order, but syntactically it is as much important e.g. it is easier to sort dates such as 2024-05-27 than 27.05.2024 in chronological order.
But also, sorting big endian automatically groups elements associated with common functions making search, completions, and snippets easier (if you use them). I'm torn
dialog_file_open_dialog I prefer big.LITTLE cpus
I do one, the other senior dev does the other. We fight about it in pull requests.
Your team needs to have a coding standards meeting where you can describe the pros and cons of each approach. You guys shouldn't be wasting time during PR reviews on the same argument. When that happens to me, it just feels like such a waste of time.
Or they need to kit car about stuff like this since it probably doesn’t actually matter.
Preachin to the choir, friend. I'd get worked up about it but I'm paid the same regardless of how upset I get.
As a rule of thumb, I always put action verbs at the end of method names
A third option there is
open_dialog_file
or dialog_open_file
?
New file
New file (2)
New file (3)
New file (4)
A fourth there option is
sjajvxuwjdofgwu
AjsgGhS77bndugxg
gehshagfahcdvwjdvwjd
AjsgGhS77bndugxg (2)
I worked at a place where all the DB column names were like id_user
, id_project
. I hated it.
I didn't really care about this thread until I read this comment.
I have never thought about it
I prefer everything to be how you would read it as text. So create_file_dialog
it is. Honorable mention is to have it namespaced in a class or something which I think is best. file_dialog.create
or dialog.create_file
or even dialog.file.create
I agree. I say open door so the function should be named openDoor
.
Honestly nowadays none of that matter if you're using any remotely modern IDE with good indexing and a sensible search, you can start typing however you mind works and it will find it no matter how it's named.
I used to like the action
followed by direct object
format, until some time ago when trying to find methods or variables related to a specific object. If the action comes first, scanning for the object without an IDE means first reading unnecessary information about the action. That convinced me to opt for $object-$action
in situations where it makes sense.
For example in CSS, I often scan for the element, then the action, so $element-$action
makes more sense. BEM kinda follows this. When dealing with the DOM in JS, that makes sense too button.fileDialogOpen()
, button.fileDialogSend()
, ... makes more sense when searching.
Of course one has to use it sensibly and where necessary. If you are writing a code that focuses more on actions than objects, putting the action first makes sense.
A similar thing is definition order.
def main(args):
result = do_something(args.input)
processed = process_result(result)
transformed = transform_object(processed)
return transformed.field
def do_something(some_input):
...
def process_result(result):
...
def transform_object(obj):
...
I find this much easier to follow than if main
were defined last, because main
is obviously the most important method and everything else is used by it. A flattened dependency tree is how these definitions make sense to me or how I would read them as newbie to a codebase.
Variety is the spice of life.
I don't know and that's the problem :(
I keep asking myself what to choose, only for changing it a day after cursing myself to choose a stupid name.
Big endiant is great for intellisense to quickly browse possibilities, since it groups it all in the same place. But that's also a detriment when you know what you want. You can start typing without the prefix but you'll have to go through the better suggestions of intellisense first.
Little endiant is the same thing, but in reverse. Great when needed, but bad for browsing.
Although I do have some fix I'm starting to use. But it's not applicable everywhere, and not in every language.
What I do is use module as prefix. Instead of dialogue_file_open
, I create a file_open
in the dialogue
module, allowing either directly calling file_open
, or dialogue::file_open
. Using intellisense on the module allow for easy browsing too!
Although in OP's post I'd rather have file_open_dialogue
as it convey the more significant meaning, being to open a file, first. Then "dialogue" is just the flavour on top
Big endiant is great for intellisense to quickly browse possibilities, since it groups it all in the same place.
If only someone would train a program… we could call it a Large Language Model… to knowingly group the names together so we wouldn’t have to choose between human-readable format or dB format.
Guess that will never happen because instead we’re stuck using “AI’s” to inflate stock prices instead. /s
I remember seeing a proposed language that would allow each programmer to choose what name to use for each item. Don’t like ‘open_file’? Choose to see it as ‘file_open’ every time you review the file in the future.
While we battle with each other endlessly, we keep forgetting that the computer doesn’t care.
For me it's simple.
Pseudo-OOP in C which takes dialog* as a forst argument? dialog_open_file
Otherwise - make it human readable
First of all, it's spelled dialogue
OP's username is in German, so it's probably half-German-English code
Two wars can exist simultaneously.