justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: Hey Justin, hope youre having a nice weekend. Do you have any naming conventions or style standards you are adamant about? Thanks :)
Asked by jack (185.213.154.x) on October 9 2022, 1:44pm
Reply on October 9 2022, 4:38pm:
    One I really care about is if you have a struct/class with a nontrivial amount of member function code, to prefix the data members of that class with m_ -- both to avoid accidental collisions with local variables, and also to make it obvious from reading the code that the variable in question is a member.

    There are other things that are handy, e.g. making functions that are used only in one file static, which when you're editing you can then rest assured that you don't need to grep the rest of the codebase (just the current file) to see if it is used elsewhere.


Comments:
  • Posted by jack (185.213.154.x) on October 9 2022, 4:59pm:
    Any reason you prefer m_ instead of a more modern 'this->'? I think that removes the collision and ambiguity in member functions; a quick grep of your WDL stuff seems that you rarely, if ever, use 'this->', (nor do I).

  • Posted by jack (185.213.154.x) on October 9 2022, 5:05pm:
    Somewhat related - am I insane for thinking about using 'typedef char CHAR', I use fixed-width types typedefd to shorter-hand, e.g 'typedef uint8_t U8', and I prefer them as uppercase, so to be consistent I feel like I should use 'CHAR', seems kinda crazy, no?? haha

  • Posted by Gio (94.70.19.x) on October 10 2022, 12:11am:
    For me WDL [member] function naming makes sense at first glance, everything is good and crystal clear: WDL_TypedBuf::Add() - never understood what was the deal with the STL equivalent std::vector::push_back

  • Posted by Justin on October 10 2022, 11:49am:
    this-> is too tedious to type and you could still accidentally access a member via the implicit this without it.

  • Posted by Justin on October 10 2022, 11:50am:
    re: CHAR, whatever floats your boat? it's rarely an issue, the only real advantage I can see is if you made it typedef signed char CHAR; since arm defaults to unsigned char :/

  • Posted by jack (141.98.255.x) on October 10 2022, 4:16pm:
    Thanks for the replies :)


Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2022 Justin Frankel. | RSS