[erlang-questions] Why do we need modules at all?

Tim Carpenter amphibian.ltd@REDACTED
Tue May 24 15:33:35 CEST 2011


(am sending again as this did not seem to get through)

Hi all,

I am sticking to the request to not comment on other solutions but  
present my own thoughts...

1. Some units of code only make sense as a collection. who would use  
part of gen_server in isolation? Well, you could,but to have it  
separate exposes it to modification that could distort the focused  
purpose of the unit.

2. some functions have intentionally hidden aspects, private calls etc  
and these again are best left hidden or considered as a logical whole  
otherwise side effects or bloat may occur.

3. I see no reason why we cannot logically group functions into  
modules but not have the code in there...i.e. the module contains  
references to functions that make it up. this allows logical handling  
of groups of functions for code management and can allow one function  
to appear in multiple modules without code duplication. it also allows  
one to add/delete/replace a function in a module knowing that the  
source code for the other functions have not been touched!

4. naming conventions should be given great thought for simplicity and  
intuitiveness. functions could be in n sets, so a strict hierarchy may  
not suit.

5. if functions are named as being in modules, the need to provide  
abstraction to the full name may be advantageous, so modulename.sort/3  
can be used and the module definition translates this to a unique  
longhand which can change over time. The programmer should also be  
able to use the longhand at will using the module as a convenient bulk  
import/compile vehicle that will break at compile time (one would  
hope). Some form of 'expects...' notation could allow a form of  
protection against inadvertent swapping of functions in shared modules  
altering behaviour.

6. we may want 3 elements to naming of functions: shorthand, longhand,  
and version, so one can use the latest version of a longhand named  
function, lock to a specific version of a longhand named function or  
use the shorthand latest version or other such combinations.

7.  n- tier modules - modules of modules? possibly.

Tim
Tim Carpenter
Amphibian Ltd
London
ENGLAND
+44(0)7900 888826
amphibian.ltd@REDACTED






More information about the erlang-questions mailing list