19

Why is naming stuff so difficult? 🤬😡
Spent the last hour thinking of an appropriate name for an enum

Comments
  • 15
    "You should name a variable using the same care with which you name a first-born child.” — Robert C. Martin
  • 0
    @Anchor sorry mate, trade secrets.

    No well writing an enum for a schedule type. We have start of month and middle of month.
    And then we also have monthly and one-off payments. So the name schedule type was already taken by this.
  • 0
    @zlice true that. There's only one other guy working on this with me and both of us have a good mutual understanding of the coding standards and so far, we have been able to keep them to a good enough level. Lucky about that!
  • 4
    Ditto. What I usually run into is spend hours/days to name a class/enum/etc, think "Ahhh...perfect", then in a code review (within a few minutes) "Why did you name the class Foo? Would make make more sense if you called it Bar?"

    Thought bubble over my head: "YEEEESSSS! Where were you 3 days ago!!!"

    What comes out the pie hole: "Oh, yea, that might make it easier to understand. Let me work that into the next change set. Thanks"
  • 3
    @soull00t Me be like:

    public class Thingy extends Oof inplements BrainDamageMonitor
  • 1
    Only for the Italian average Serie A fan.
  • 0
    @A4Abhiraj The first or mid month enum looks like a StartDayOfMonth unsigned byte or a startTime datetime to me. And monthly or one-off looks like PaymentIntervalMonthly and PaymentIntervalPrepaid to me. But i also might have completely misinterpreted what you are trying to implement...
  • 1
    @Oktokolo oh you're right! Haven't created the PR yet. Thanks 🙌🙌
  • 0
    especially in JS, you don't even have enums in js. what do you call it then
  • 0
    @useVim well in JS, we just do an Object.freeze.
  • 1
    @useVim with TypeScript you can
  • 1
    I love it when there's a long discussion in a pull request about the naming of a class/enum. Epic way to kill time and still be doing actual work.
  • 2
    I once had a coworker that named his methods and variables, I kid you not, after the fucking Jira ticket that required their creation.
    And that is why we had a fuckload of "fix_pd39851" and similarly stupid sounding terms in our codebase.
  • 3
    try naming a kid
  • 1
    @A4Abhiraj either they should be tied to a different namespace (package/class) so you can have a nice consistent name in different context; or you can add the context to the name (less preferable as it implies usage info although that can be fine for now) PaymentSchedule and XSchedule.

    Also try to avoid over generic words like type unless you need to differentiate (like both XType and XValue). If you have a clash with setting the schedule and these schedule options I would say call them ScheduleOption but not ScheduleType.

    Hope this makes sense and helps you in the process.
  • 1
    @hjk101 yo! Thanks mate
  • 0
    The 3 hardest things in computer science are
    1) naming variables, functions, etc.
    2) off-by-one errors
  • 0
    I've found that many times is easy if the problem at the domain level is clearly defined. After that many questions are answered automatically. And that's because the code is solving a problem of the domain, then it's not just variable names but domain terms.
  • 0
    When I can't come up with a name for a variable/function, I just name it "temp" or something like it, then use the variable and continue with the code... Most of the time, a good name will pop in my head while using it contextually.
Add Comment