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.

201 points
*

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.

permalink
report
reply
101 points

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.

permalink
report
parent
reply
114 points

is_dialog_file_open

fite me

permalink
report
parent
reply
58 points

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

permalink
report
parent
reply
18 points

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

permalink
report
parent
reply
9 points
*

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

permalink
report
parent
reply
4 points

jealously weeps in ruby

permalink
report
parent
reply
25 points
*

This is the way.

Command statement = an action

Question statement = a status

permalink
report
parent
reply
5 points

Lol mutable state

permalink
report
parent
reply
72 points

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.

permalink
report
reply
18 points

Not a programmer, but I’d prefer right naming convention because sorting

permalink
report
parent
reply
13 points

I am a programmer, and i also like the naming scheme on the right

Especially for things like filenames

permalink
report
parent
reply
9 points
*

Also a programmer and think method names would be conducive using little endian.

TopicGet()
TopicCreate()
TopicDelete()

Writing this I realize we do this implicitly in some instances.

http.Get() -> httpGet()
http.Post() -> httpPost()
permalink
report
parent
reply
15 points

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

permalink
report
parent
reply
8 points

Aahh you can’t just make this problem object oriented!

C programmers don’t like that.

permalink
report
parent
reply
7 points

Insert xkcd about 15th format

permalink
report
parent
reply
3 points
71 points

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.

permalink
report
reply
26 points
*

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.

permalink
report
parent
reply
6 points

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.

permalink
report
parent
reply
5 points
*

We probably have slightly different work processes.

I’m more likely to be making “foo” functionally complete and then making “bar” complete than I am to be making all my dialogs functional then all my tabs/whatever.

This comes from TDD where I’m making a test pass for “foo”, once done, I’ll do the same for “bar”.

Though it’s even more likely these are different files entirely, rendering the arguments moot.

permalink
report
parent
reply
3 points

I put all those in different files

compont/functions/foo.ext etc.

permalink
report
parent
reply
2 points

Depends on the language’s constraints, but yes: more smaller files please!

permalink
report
parent
reply
7 points

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

permalink
report
parent
reply
3 points

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.

permalink
report
parent
reply
63 points

Where’s file_dialogue_open

permalink
report
reply
37 points

We’re all trying our best to ignore the Americans and you bring up m/d/y… why!

permalink
report
parent
reply
27 points
*

This is the real big-endian way. So your things line-up when you have all of these:

file_dialogue_open
file_dialogue_close
file_dropdown_open
file_rename
directory_remove

If I were designing a natural language, I’d put adjectives after the nouns, so you start with the important things first:

car big red

instead of

big red car

permalink
report
parent
reply
9 points

literally spanish lol

permalink
report
parent
reply
6 points

If I were designing a natural language, I’d put adjectives after the nouns, so you start with the important things first

So - French?

permalink
report
parent
reply
4 points

The thing is that in French, Spanish, etc. it still makes sense if you put the adjective before the noun, even if it might sound weird in some cases. An adjective is an adjective and a noun is a noun.

But English is positional. Where you put a word gives it its function. So “red car” and “car red” mean different things.

permalink
report
parent
reply
4 points

Heathen! You must alphabetize all the things!

Like seriously. It makes scanning code much easier.

permalink
report
parent
reply
11 points

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

permalink
report
parent
reply
48 points
*

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

permalink
report
reply
5 points

My method names are the same way but I aggressively sort things into modules etc so it comes out the other way.

But if I was staring down dozens of these methods and no way to organize them, I’d start doing the sorted names just for ease of editing. L

permalink
report
parent
reply
4 points

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.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 2.9K

    Monthly active users

  • 1K

    Posts

  • 38K

    Comments