Timothy Weber wrote: > Gratuitous metric: On one 270,000-line desktop app, I have 209 test > cases that run in under 8 minutes that cover nearly every feature to > some degree, and are run before each check-in. Wow. I've never worked on a project of this magnitude. How long does it take to compile this beast? :) > This has got me thinking... I wonder whether it would be practical to > set up automated unit tests using MPSIM? Getting the output in an > automated way is the main hurdle, I think. > > Wouldn't be quite as good as testing the hardware, but a lot better than > no tests at all. I think this warrants a new thread: [EE] Test driven design for embedded applications >> Do you use a naming convention that identifies a funciton as belonging to >> a >> particular module? I started prepending module name to the function name, >> and found this technique to be quite useful. For example, you can tell >> that >> Uart_Putc() is in uart.c, Adc_GetValue() is in adc.c, and so on -- >> withouth >> having to Ctrl-Shift-F for it. > > Yes, I tend to do that. Though sometimes I'll tend more toward names > that sound like English phrases when available, so the name may not go > first. E.g., in buttons.h: > > void InitButtons(void); > void CheckButtons(void); > byte GetButton(void); > > or in uiTime.h: > > void ResetUITimer(void); > void InitUiTime_Timer0(void); > void InitUiTime_Timer1(void); > void InitUiTime_60Hz(void); > void UiTimeUpdate60(void); > unsigned char UiTimeInterrupt(void); > > Always prepending the module name has the advantage that you can type it > and then ask for auto-completion. But somehow I still prefer "verb" or > "verbNoun" (but the above examples show I'm not consistent about it). I think of it this way: I'm not performing the action, I'm telling objects to do whatever it is I want them to do. So in a normal scenario, it goes like this: - Hey, UART! Send this out for me: "Hello World". Or, - Hey, ADC! Give me a reading on channel 1. In C++, you would say: Uart.Send("Hello World"). C doesn't have classes, but you can say: Uart_Send("Hello World"). In your example, I would name the functions thus: UiTime_ResetUiTimer() UiTime_InitTimer0() UiTime_HandleInterrupt() etc... Yes, it takes some time to get used to. :) By the way, what do these function do? > void InitUiTime_60Hz(void); > void UiTimeUpdate60(void); Regarding initialization code, I came to the conclusion that a program needs to have a separate object, Initializer, that is responsible for initializing all the other modules. As tempting as it is to have a Uart_Init() function, doing so creates too much coupling b/w the Uart module and the code that is using its functions. IMHO, it's better to say Initializer_InitializeUart(). >> Private functions are declared static in a >> module, and prepended with a p_. > > I appreciate all of those Hungarian-style conventions... but I don't > tend to use them. First, because it makes it less English-like (I hear > all the p's in my head); second, because it can get broken. But I don't > feel strongly about it. Initially, I hated p_ so much that I just used two underscores instead. But as Tamas, Olin and others have pointed out, it's not a good idea. I just feel that it helps me to have a clear distinction which functions in a module are public, and which ones are private. Vitaliy -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist