How to name things in programming?

Поділитися
Вставка
  • Опубліковано 24 гру 2024

КОМЕНТАРІ • 21

  • @godsonprogrammer2807
    @godsonprogrammer2807 3 роки тому +13

    1. Use correct grammer (Classes, variables, packages are nouns. Methods and functions are verbs)
    2. Avoid abbreviation & acronyms
    3. Invest time in picking names (will pay off in the future)
    4. Follow a coding style (eg. Google style guide)
    5. Don't re-use variables to optimize (compilers are smart enough to do that on its own)
    6. Avoid tongue-twisters (like HWNDsck, mCustRpt_ptr etc)
    7. Avoid "not" prefix (for example you won't know what *!notDeletable* means at a glance)
    8. Never use Hungarian Notation (like szFirstName). The name should suggest the type:
    isRed, hasChildren = boolean
    totalAmount, userCount = int
    firstName, simpleLabel = string
    startDate, signedOn = date
    firstNames = string[], List
    9. Avoid prefixes if possible
    10. Length: 1 is fine for iterators. For others 64 characters
    11. If a function needs more longer name, then the function is most likely too big
    12. Keep things explicit but short
    13. If there is a shorter name for explaining what the function does then rename it
    14. Include side-effects in function names
    15. Split your code by single concerns
    16. Avoid weasel-words (like helpers, handlers, managers etc). Alternatives: Decorator, Producer, Consumer, Selector, Grouper, Collecter, Persister, Loader, Streamer, Orchestrater, Store
    17. Look for ambiguity

    • @Tomersss222
      @Tomersss222 3 роки тому +1

      Classes are only singular*

    • @ChrisAthanas
      @ChrisAthanas Рік тому

      16 is the path to doom
      That’s not OOP
      That’s CLASS Oriented programming
      See Yegor Bugayenko
      Most devs have not seen true Alan Kay style OOP

  • @ChrisAthanas
    @ChrisAthanas Рік тому +1

    No
    There are only 2 problems in programming:
    1. Cache invalidation
    2. Naming things
    3. Off by one errors

  • @nimamohamadian6057
    @nimamohamadian6057 5 років тому +4

    Thank for your sharing your knowledge.

  • @michaelhabibau
    @michaelhabibau 3 роки тому

    Great video. The point about prefixes is really important.

  • @sunuv2guns
    @sunuv2guns 4 роки тому +1

    Great comprehensive video. Definitely going to send this to my team!

  • @Radarsu
    @Radarsu 5 років тому +5

    There were some choose-between-names cases that I've tried to solve and stay consistent at. I ended up with my standard approach to those:
    & vs And - prefer "and", leave "&" for brand names and programming actions.
    Add vs Create - prefer "add". It's more intuitive for non-programmers.
    Attribute vs Property - attribute for xml, properties for objects.
    Change vs Modify vs Update - prefer "update". It's more standard.
    Common vs Partials vs Shared - common for library names, shared for directory name, don't use partials.
    Configuration vs Options vs Preferences vs Settings
    Configuration - for internal system (for example: webpack.config.js, ecosystem.config.js).
    Options - for others choices (especially other developers, for example: ).
    Settings - for system-administrating end-user (for example: admin dashboard)
    Preferences - for end-user (for example: website visitor).
    Controller vs Resolver vs Route - controller for REST, resolver for GraphQL, route for analysis of url, query and params, possibly pointing to one of previously listed.
    createdAt vs creationDate - prefer "createdAt" over "creationDate". It's shorter and more common.
    Delete vs Remove - prefer "remove". It's more intuitive for non-programmers.
    Entity vs Model - for ORM model names use model, as it's more common and part of MVC naming.
    Module vs Package - module for internal stuff, package for external libraries.
    Page vs View - use view, as sometimes one page/view may be part of another one (also it's part of MVC).

    • @SmokCode
      @SmokCode  5 років тому

      Thanks for sharing! In my dictionary Model is after going through ORM, Entity is on the DB side, before going though mapper.

  • @lpdc9767
    @lpdc9767 5 років тому +2

    Super solid info. Background music is relaxing but it might be too relaxing; it made me a bit sleepy.

  • @javieru5871
    @javieru5871 3 роки тому

    Excelent, worth my time, Thanks man!!!

  • @kluchtube7042
    @kluchtube7042 3 роки тому

    Bro keep it up the good work! Appreciateed!

  • @mahdiakbarizarkesh5603
    @mahdiakbarizarkesh5603 4 роки тому

    Thank you for sharing your knowledge, I like them.

  • @Sebo810
    @Sebo810 4 роки тому +1

    Great video :) I'm a software developer myself and I found it very interesting :) although the music did make me a bit sleepy . :)

  • @aero83pl
    @aero83pl 5 років тому +2

    Vehicle wymawia się bardziej w stylu "wiekl".

  • @insydium7385
    @insydium7385 2 роки тому

    Pretty good video but why are you talking down to your audience? It's quite annoying

  • @MrKret87
    @MrKret87 5 років тому +1

    But... but... I like hungarian notation :(

    • @SmokCode
      @SmokCode  5 років тому +1

      Everyone does! That's why you shouldn't use it ;)

    • @MrKret87
      @MrKret87 5 років тому

      @@SmokCode You know nothing, Jon Snow. I think you say such things because you don't want us to be pro programmers! :p