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 3) 9 comments
sorted by: hot top controversial new old
[–] [email protected] 15 points 4 months ago

Whatever is more useful goes first.

For example, if this we're a list of UI text strings, finding all of the dialogue options together might be useful.

If, instead, this is a series of variables already around one dialogue, then finding the open or close bits together would be useful.

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

To be fair, it's also missing open_dialog_file, dialog_open_file and most crucially file_open_dialog

load more comments (9 replies)
[–] [email protected] 12 points 4 months ago
[–] [email protected] 201 points 4 months ago* (last edited 4 months ago) (3 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.

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

This is the way.

Command statement = an action

Question statement = a status

[–] [email protected] 101 points 4 months ago (6 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.

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

In Elixir, we mark statuses by using a question mark at the end of the variable name. Something like this:

authorized? = user |> get_something() |> ensure_authorized?()

I like this better than the is_ prefix

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

does '?' have type definition in elixir or this is generally agreed design pattern?

load more comments (1 replies)
load more comments (3 replies)
load more comments (5 replies)
load more comments (1 replies)
load more comments
view more: ‹ prev next ›