kuuhana
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Programmer Humor@programming.devbygandalf_der_12te@discuss.tchncs.de
2 years

new preference war just dropped

i.redd.it

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.

108
    You must log in or register to comment.

    • alexdeathway@programming.dev
      2 years

      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 years

          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 years

              is_dialog_file_open

              fite me

                • TheSlad@sh.itjust.works
                  2 years

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

                    • sus@programming.dev
                      2 years

                      that works for 2 word names eg is_open or is_file, but in this case is_dialog_file_open is structured like a question, while dialog_file_is_open is structured like a statement

                        • Rinox@feddit.it
                          2 years

                          Doesn’t matter, the point is that, if it starts with “is” then you automatically know it’s a boolean.

                          • redfellow@sopuli.xyz
                            2 years

                            It still works. is_this_thing_some_thingy. Is is just a prefix for if the suffix returns true/false.

                      • 4wd@programming.dev
                        2 years

                        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

                          • alexdeathway@programming.dev
                            2 years

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

                              • Faresh@lemmy.mlEnglish
                                2 years

                                If it’s like Lisp, then ? is just part of the symbol and doesn’t have any special syntatic meaning. In different Lisps it’s also convention to end predicate names with a ? or with P (p for predicate)

                              • cytokine0724@sh.itjust.works
                                2 years

                                jealously weeps in ruby

                                  • FMT99@lemmy.world
                                    2 years

                                    We do this in Ruby all the time, we just prefer methods over variables, usually.

                                    def authorized?
                                      current_user&.authorized?
                                    end
                                    
                                      • cytokine0724@sh.itjust.works
                                        2 years

                                        I’m a principal backend engineer routinely writing Ruby for my day job, so I’m familiar, lol. But you can’t do it for local variables and that just sucks. Definitely a +1 for Elixir.

                                • Yondoza@sh.itjust.works
                                  2 years

                                  This is the way.

                                  Command statement = an action

                                  Question statement = a status

                                  • crispy_kilt@feddit.de
                                    2 years

                                    Lol mutable state

                                  • redcalcium@lemmy.institute
                                    2 years

                                    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.

                                      • And009@lemmynsfw.comEnglish
                                        2 years

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

                                          • Lightfire228@pawb.social
                                            2 years

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

                                            Especially for things like filenames

                                              • bitwolf@lemmy.one
                                                2 years

                                                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()
                                                
                                            • kunaltyagi@programming.dev
                                              2 years

                                              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

                                                • Ziglin (it/they)@lemmy.world
                                                  2 years

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

                                                  C programmers don’t like that.

                                                  • _g_be@lemmy.world
                                                    2 years

                                                    Insert xkcd about 15th format

                                                      • Rainb0wSkeppy@lemmy.worldEnglish
                                                        2 years

                                                        https://xkcd.com/927/

                                                  • rekabis@lemmy.ca
                                                    2 years

                                                    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 years

                                                        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
                                                            2 years

                                                            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.

                                                              • deadbeef79000@lemmy.nz
                                                                2 years

                                                                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.

                                                              • redfellow@sopuli.xyz
                                                                2 years

                                                                I put all those in different files

                                                                compont/functions/foo.ext etc.

                                                                  • deadbeef79000@lemmy.nz
                                                                    2 years

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

                                                                • Static_Rocket@lemmy.worldEnglish
                                                                  2 years

                                                                  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

                                                                  • 33550336@lemmy.world
                                                                    2 years

                                                                    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.

                                                                  • morrowind@lemmy.ml
                                                                    2 years

                                                                    Where’s file_dialogue_open

                                                                      • xmunk@sh.itjust.works
                                                                        2 years

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

                                                                        • verstra@programming.dev
                                                                          2 years

                                                                          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

                                                                            • MonkCanatella@sh.itjust.works
                                                                              2 years

                                                                              literally spanish lol

                                                                              • funkless_eck@sh.itjust.works
                                                                                2 years

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

                                                                                So - French?

                                                                                  • lunarul@lemmy.world
                                                                                    2 years

                                                                                    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.

                                                                                      • ddh@lemmy.sdf.orgEnglish
                                                                                        2 years

                                                                                        And “red big car” is wrong.

                                                                                        • deadbeef79000@lemmy.nz
                                                                                          2 years

                                                                                          That’s because they are romance languages. They come from Latin where word order is irrelevant as each “word” has a different form for the specific use.

                                                                                            • lunarul@lemmy.world
                                                                                              2 years

                                                                                              Yes, that’s what I said. My native language is a romance language too. And after speaking it her whole life, my wife has trouble getting the grasp of how in English swapping two words completely changes the meaning of what she’s saying (especially when it’s two nouns, like e.g. “parent council”)

                                                                                        • dohpaz42@lemmy.worldEnglish
                                                                                          2 years

                                                                                          Heathen! You must alphabetize all the things!

                                                                                          Like seriously. It makes scanning code much easier.

                                                                                        • janAkali@lemmy.oneEnglish
                                                                                          2 years

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

                                                                                        • Caveman@lemmy.world
                                                                                          2 years

                                                                                          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

                                                                                            • sudo@programming.dev
                                                                                              2 years

                                                                                              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

                                                                                              • Bruno Finger@lemm.ee
                                                                                                2 years

                                                                                                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.

                                                                                              • evatronic@lemm.eeEnglish
                                                                                                2 years

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

                                                                                                  • livingcoder@programming.dev
                                                                                                    2 years

                                                                                                    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.

                                                                                                      • evatronic@lemm.eeEnglish
                                                                                                        2 years

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

                                                                                                        • OutsizedWalrus@lemmy.world
                                                                                                          2 years

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

                                                                                                            • locuester@lemmy.zipEnglish
                                                                                                              2 years

                                                                                                              Agreed. This type of fun is good for the team. Trying to stamp it out, when it impacts very little, is just a buzzkill to the team.

                                                                                                          • nikaaa@lemmy.world
                                                                                                            2 years

                                                                                                            This sounds like the typical plot of a story from The Codeless Code.

                                                                                                            Edit: How about this story specifically?

                                                                                                          • Hazzia@discuss.tchncs.de
                                                                                                            2 years

                                                                                                            Can’t remember which is which but if it’s organized in a top-down way (broad category first) that’s just easier to look at and find stuff in the file system. I don’t want to have to actually read and mentally process the names of every single file to figure out if it’s the one I need. Sure, the “human readable” names are fine and good when you don’t have hundreds of them you’re trying to look through, but big projects I find are way easier to parse with the category naming.

                                                                                                              • ooterness@lemmy.worldEnglish
                                                                                                                2 years

                                                                                                                US Army logistics catalogs are organized this way. “Cookies, oatmeal” instead of “Oatmeal cookies” because it’s a lot easier to find what you need an a giant alphabetical list.

                                                                                                                • BlanketsWithSmallpox@lemmy.worldEnglish
                                                                                                                  2 years

                                                                                                                  How any large organization gets away with not using YYYY-MM-DD format is beyond me.

                                                                                                                  Taking over some of my previous directors files is like chaos.

                                                                                                                  How anybody publishing entire internet memos without a date being on the first page is beyond me. Like wtf am I reading a PDF from 15 years ago or last month?

                                                                                                                • Fish [Indiana]@midwest.socialEnglish
                                                                                                                  2 years

                                                                                                                  Variety is the spice of life.

                                                                                                                  • Todd Bonzalez@lemm.ee
                                                                                                                    2 years

                                                                                                                    Mmmmmmmm… Lexicographical Endianness.

                                                                                                                    • onlinepersona@programming.devEnglish
                                                                                                                      2 years

                                                                                                                      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

                                                                                                                        • gandalf_der_12te@discuss.tchncs.de
                                                                                                                          2 years

                                                                                                                          I agree with you especially on the definition order of functions. I, too, define main() first.

                                                                                                                        • katy ✨@lemmy.blahaj.zone
                                                                                                                          2 years

                                                                                                                          the people who chose the first one…who hurt you?

                                                                                                                            • habl@lemmy.world
                                                                                                                              2 years

                                                                                                                              I will

                                                                                                                              • MechanicalJester@lemm.ee
                                                                                                                                2 years

                                                                                                                                No one, it just makes sense.

                                                                                                                                You must be one of those “Throw your mother downstairs, the box of tissues” types.

                                                                                                                                Yoda sounded normal to you I bet.

                                                                                                                                  • LoudWaterHombre@lemmy.dbzer0.com
                                                                                                                                    2 years

                                                                                                                                    It makes sense until you write 30 methods to manipulate the data layer.

                                                                                                                                      • Lifter@discuss.tchncs.de
                                                                                                                                        2 years

                                                                                                                                        Fuzzy search solves this pretty good

                                                                                                                                      • Swedneck@discuss.tchncs.de
                                                                                                                                        2 years

                                                                                                                                        reverse polish notation time

                                                                                                                                      • lightnsfw@reddthat.com
                                                                                                                                        2 years

                                                                                                                                        Powershell

                                                                                                                                      • dariusj18@lemmy.world
                                                                                                                                        2 years

                                                                                                                                        Be php, mix and match

                                                                                                                                          • gandalf_der_12te@discuss.tchncs.de
                                                                                                                                            2 years

                                                                                                                                            let the chaos reign

                                                                                                                                          • jjjalljs@ttrpg.network
                                                                                                                                            2 years

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

                                                                                                                                              • ShortFuse@lemmy.world
                                                                                                                                                2 years

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

                                                                                                                                                • Terrasque@infosec.pub
                                                                                                                                                  2 years

                                                                                                                                                  I worked on one where the columns were datanasename_tablename_column

                                                                                                                                                  They said it makes things “less confusing”

                                                                                                                                                • roon@lemmy.mlEnglish
                                                                                                                                                  2 years

                                                                                                                                                  Powershell has a lint warning for functions that don’t follow Verb-Noun format, and verbs here are a list of approved verbs lol

                                                                                                                                                  • Goodie@lemmy.world
                                                                                                                                                    2 years

                                                                                                                                                    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.

                                                                                                                                                    Programmer Humor@programming.dev

                                                                                                                                                    programmer_humor@programming.dev

                                                                                                                                                    Subscribe from remote instance

                                                                                                                                                    Create post

                                                                                                                                                    Report community

                                                                                                                                                    Modlog
                                                                                                                                                    You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

                                                                                                                                                    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
                                                                                                                                                    Visibility: Public

                                                                                                                                                    This community is visible to everyone.

                                                                                                                                                    • 388 users / Day
                                                                                                                                                    • 572 users / Week
                                                                                                                                                    • 586 users / Month
                                                                                                                                                    • 14.5K users / 6 months
                                                                                                                                                    • 2.33K posts
                                                                                                                                                    • 89.9K comments
                                                                                                                                                    • 2 local subscribers
                                                                                                                                                    • 31.9K subscribers
                                                                                                                                                    • UI: 1.0.0-beta.0
                                                                                                                                                    • BE: 1.0.0-alpha.20
                                                                                                                                                    • Modlog
                                                                                                                                                    • Instances
                                                                                                                                                    • Docs
                                                                                                                                                    • Code
                                                                                                                                                    • join-lemmy.org