this post was submitted on 27 May 2024
717 points (97.9% liked)

Programmer Humor

19331 readers
19 users here now

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.

Rules

founded 1 year ago
MODERATORS
 

geteilt von: https://lemmit.online/post/3018791

This is an automated archive made by the Lemmit Bot.

The original was posted on /r/ProgrammerHumor by /u/polytopelover on 2024-05-26 21:23:20+00:00.

(page 2) 50 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 4 months ago* (last edited 4 months ago) (1 children)

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)

load more comments (1 replies)
[–] [email protected] 18 points 4 months ago (1 children)
load more comments (1 replies)
[–] [email protected] 22 points 4 months ago

Mmmmmmmm... Lexicographical Endianness.

[–] [email protected] 71 points 4 months ago (7 children)

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.

[–] [email protected] 3 points 4 months ago

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.

[–] [email protected] 7 points 4 months ago

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

load more comments (5 replies)
[–] [email protected] 6 points 4 months ago

dialog_file_open_dialog I prefer big.LITTLE cpus

[–] [email protected] 47 points 4 months ago (2 children)

I do one, the other senior dev does the other. We fight about it in pull requests.

[–] [email protected] 36 points 4 months ago (2 children)

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.

[–] [email protected] 5 points 4 months ago (1 children)

Or they need to kit car about stuff like this since it probably doesn’t actually matter.

load more comments (1 replies)
[–] [email protected] 20 points 4 months ago

Preachin to the choir, friend. I'd get worked up about it but I'm paid the same regardless of how upset I get.

load more comments (1 replies)
[–] [email protected] 2 points 4 months ago

As a rule of thumb, I always put action verbs at the end of method names

[–] [email protected] 13 points 4 months ago (3 children)
[–] [email protected] 4 points 4 months ago

open_dialog_file or dialog_open_file?

[–] [email protected] 30 points 4 months ago* (last edited 4 months ago)

New file

New file (2)

New file (3)

New file (4)

[–] [email protected] 10 points 4 months ago (1 children)
[–] [email protected] 8 points 4 months ago (1 children)

sjajvxuwjdofgwu

AjsgGhS77bndugxg

gehshagfahcdvwjdvwjd

AjsgGhS77bndugxg (2)

load more comments (1 replies)
[–] [email protected] 5 points 4 months ago (2 children)

Create a file handler class to avoid the issue

[–] [email protected] 3 points 4 months ago (1 children)
load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 17 points 4 months ago (2 children)

I worked at a place where all the DB column names were like id_user, id_project. I hated it.

[–] [email protected] 5 points 4 months ago

I didn't really care about this thread until I read this comment.

load more comments (1 replies)
[–] [email protected] 1 points 4 months ago

I have never thought about it

[–] [email protected] 48 points 4 months ago* (last edited 4 months ago) (2 children)

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

[–] [email protected] 4 points 4 months ago

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.

load more comments (1 replies)
[–] [email protected] 20 points 4 months ago (1 children)

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.

Anti Commercial-AI license

load more comments (1 replies)
[–] [email protected] 23 points 4 months ago

Variety is the spice of life.

[–] [email protected] 5 points 4 months ago (2 children)

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

[–] [email protected] 1 points 4 months ago* (last edited 4 months ago)

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.

[–] [email protected] 1 points 4 months ago

For me it's simple.

Pseudo-OOP in C which takes dialog* as a forst argument? dialog_open_file

Otherwise - make it human readable

[–] [email protected] 11 points 4 months ago (2 children)

First of all, it's spelled dialogue

[–] [email protected] 3 points 4 months ago (1 children)

OP's username is in German, so it's probably half-German-English code

[–] [email protected] 5 points 4 months ago (2 children)
load more comments (2 replies)
[–] [email protected] 14 points 4 months ago

Two wars can exist simultaneously.

load more comments
view more: ‹ prev next ›