A mathematical foundation of reflexion?

Laurent Martelli martelli@iie.cnam.fr
14 Jan 2000 01:32:39 +0100

>>>>> "Massimo" == Massimo Dentico <m.dentico@teseo.it> writes:

  Massimo> Laurent Martelli wrote:


  Massimo> [remember that a colon definition is a procedure
  Massimo> difinition] As a metric I did some analysis of code
  Massimo> examples Chuck has provided.  The numbers I find most
  Massimo> interesting is that the length of the average colon
  Massimo> definition is 44 characters.  The length of the longest
  Massimo> colon definition was 70 characters.  This is a sign that he
  Massimo> has factored, factored, factored.  How big are the average
  Massimo> definitions in your code?  Smaller definitions are easier
  Massimo> to code, easier to test, etc.

  >>  And harder to understand when there are too many of them. It is
  >> easier to understand a program made of a single 10 lines function
  >> than one made of 10 function of one line.  [...]

  Massimo> On what is it based your judgment?  

With one function, you read the program sequentially. As long as you
can remember the first line you are reading the last one, it's OK. 

With 10 functions, you'll have to mentally emulate the call stack each
time you encounter a function call. This requires more concentration,
I think. Especially when you have big depth of the call tree. 

It may not be a problem if the function is well known to you (`sinus'
for instance), because you don't have to inspect it's code to know
what it does : you know this just by seeing the name if the
function. But if the function was only introduced in order to increase
code reuse, I think it does not help understanding the program. At
least at first sight. But I admit that if you look at a lot of
programs which happen to use the same functions, those functions will
become familiar to you.

Laurent Martelli