Author: sebastien.lelong
Date: Thu Oct 9 12:38:17 2008
New Revision: 382
Modified:
wiki/JallibStyleGuide.wiki
Log:
init called by user, not in the lib
Modified: wiki/JallibStyleGuide.wiki
==============================================================================
--- wiki/JallibStyleGuide.wiki (original)
+++ wiki/JallibStyleGuide.wiki Thu Oct 9 12:38:17 2008
@@ -151,6 +151,13 @@
Ex: a i2c hardware library (using built-in PIC i2c) may refer to `SCK` and
`SDA`. Those pin names are set into the device include file (prefixed with
the portname!).
+== Let the user initialize the library ==
+
+Most of the time, a library needs to configured (you define
variables/constants before including the file), then initialized (you call
`<libname>_init()`). While having the init step automatically called when
the library is called can be convenient, this results in a lack of
flexibility. Indeed, you may want to initialize one library or the other,
or initialization step can take quite a long time, so you want to have
control about when you can "waste" such time.
+
+So, *a library must never call its own init procedures, the user will*.
And the init procedure must be named either as *`<device>_init`* or
*`<function>_init`*, whether you want to avoid namespace collision, or on
the contrary, if you want to have different implementation for the same API
(see rules about naming convention above).
+
+
== Avoid weird default values in library ==
*Don't put default values* in your library, someone may (will) have a
different opinion about what's a _default value_. Even if it's tempting
because it can save time writing the same value again and again. Remember,
your library is to be shared, nasty default value can be a real obstacle
using it...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---