[tuxdroid-user] Naming functions
Status: Beta
Brought to you by:
ks156
From: neimad <ror...@gm...> - 2007-06-24 15:21:05
|
Hello, The naming of functions is currently very inconsistent: some are verbs (orders), some are nouns; some have a prefix, some have a suffix -- some have both, and some have neither. For example: tux_connection() is a noun but connect_to_tux() is an order, id_request() is prefixed while wakeup_tux() is suffixed. These last two functions both take an id but one has "id" in its name and the other has "tux"... Imo, all functions should be _verbs_ in the imperative form: functions are *orders* given to the machine. It's the usual naming scheme for english code. I think a good convention is also to prefix functions with the type of object they act upon. Say I have a type dongle_t; then, connecting to a dongle would be done with dongle_connect(). What about send_usb_tux_cmd() ? Does it "send a 'usb tux' command" ? If so, what does that mean ? I have a really hard time trying to figure out what functions do from their name. We really need to define some consistent naming conventions for types, variables and functions... Damien |