this post was submitted on 27 May 2024
2 points (100.0% liked)

Programmer Humor

18407 readers
682 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.

top 12 comments
sorted by: hot top controversial new old
[–] alexdeathway@programming.dev 2 points 1 month ago* (last edited 1 month ago) (1 children)

First one are method name, second one are status name.


def open_file_dialog(self):
       self.dialog_file_open = True
       pass

Yoda level preference war.

[–] Croquette@sh.itjust.works 2 points 1 month ago (1 children)

I tend to add is to booleans toreally differentiate between a method name and a status.

def open_file_dialog(self):
    self.dialog_file_is_open = True
    pass

That way, it's easier for my dumb brain to spot which is which at a glance.

[–] db0@lemmy.dbzer0.com 2 points 1 month ago (1 children)

is_dialog_file_open

fite me

[–] TheSlad@sh.itjust.works 2 points 1 month ago

No fiting. IS always goes at the start of names for booleans you are correct

[–] morrowind@lemmy.ml 1 points 1 month ago

Where's file_dialogue_open

[–] redcalcium@lemmy.institute 1 points 1 month ago (1 children)

I'm truly torn with this. The first one seems sensible (action -> target) and easier to read and reason about (especially with long names), while the other one looks more organized, naturally sortable and works great with any autocompletion system.

[–] kunaltyagi@programming.dev 1 points 1 month ago (1 children)

We need a new framework, one that allows universal lookup, and makes life easier

x = _.dialog.file.open
y = _.open.file.dialog
z = _.file.open.dialog
a = _.file.dialog.open

Once done, the formatter simply changes everything to _.open.file.dialog

Let's get this done JS peeps

\s

[–] _g_be@lemmy.world 1 points 1 month ago (1 children)

Insert xkcd about 15th format

[–] rekabis@lemmy.ca 0 points 1 month ago (1 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.

[–] deadbeef79000@lemmy.nz 2 points 1 month ago* (last edited 1 month ago) (1 children)

That's actually filtering not sorting.

That being said, it's more valuable (to me) to be able to find all my things for a topic quickly rather than type.

Foo_dialog

Foo_action

Foo_map

Bar_dialog

Bar_action

Bar_map

Is superior IMHO.

[–] rekabis@lemmy.ca 1 points 1 month ago

If you are looking for Bar, it is highly likely that you are already looking specifically for a particular functionality - say, the action - for Bar. As such, it is irrelevant which method you use, both will get you to the function you need.

Conversely, while it is likely you will want to look up all items that implement a particular functionality, it is much less likely you are going to ever need a complete listing of all functionality that an item employs; you will be targeting only one functionality for that item and will have that one functionality as the primary and concrete focus. Ergo, functionality comes first, followed by what item has that functionality.