Skip Navigation
106 comments
  • 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.

     py
        
    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

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

  • Both:

     
        
    dialog_error = Dialog_plain.create_modal(error_text)
    
      

    Variable and class names go from more general to more particular, functions begin with a verb.

    Global functions are either "main", or start with one of "debug", "todo", or "shit".

  • in general, adjectives and verbs after nouns because it's more organized/easier to search/filter. as god intended.

106 comments