Thread: RE: [Doxygen-users] [Large] Algorithmics comments or comments ins ide body functions.
Brought to you by:
dimitri
|
From: Prikryl,Petr <PRI...@sk...> - 2001-09-26 08:45:45
|
Hi Jose and others,
Jose Luis Zabalza wrote:
>
> Petr Prikryl wrote:
> >
> > Jose Luis Zabalza wrote:
> > > I come back again about the idea of ** what ** do
> > > a function or ** how ** do the function his work.
> > > I believe is important the documentation show two
> > > things.
> >
> > On the other hand, any function should be on a
> > bit higher level of abstraction than the things
> > inside the body. [...] While
> > you may want to extract some points about how the
> > function works, for me it is much easier to
> > sketch the idea more roughly in the comment
> > outside the body.
>
> OK. I think so. It's all right. But, when you have
> hurry up is very easy forget the generic abtract
> comment but it's easy to write a little coment
> near the for keyword, or near the if keyword or
> near the return keyword.
I think that this is quite important point. My
view is that you should never hurry so much ;-)
Otherwise, it finally takes more time than going a
bit more slowly.
One more notice here; when I wrote about higher
level of abstraction, I was not thinking only
about describing the existing commands in human
language. I meant also to decrease "the complexity
of the description" by, say, collapsing loops and
branches, etc.
See other comments below.
> > If you want even more details, you can use
> > INLINE_SOURCES = YES
> > SOURCE_BROWSER = YES
> > in your Doxyfile.
>
> Yes, but this is very noisely, it is more descriptive :
>
> - This.
> - If this
> - this.
One problem is that when polishing the approach,
you may finish with another (description) language
with your own syntax -- i.e. something that
increase the complexity of your work. Look at your
indentation notation, for example.
# A algorithmic comment has the format :
#
# // <(.*)> Algorithmic comment.
# // comment continuation.
# until a no init comment line.
#
# Where (.*) can to be :
#
# <> : Algorithmic comment init.
# <+> : Algorithmic comment init indent +1 position.
# <-> : Algorithmic comment init indent -1 position.
# <-n> : Algorithmic comment init indent -n position.
You have to type more characters, and (what is
more important) you have to think about what you
are expected to type. You have to take care to
get the good result. Rather exagerating, you are
writing another program in parallel.
> When you design a program. What is the first think
> you do ?
I think about "the problem". ;-)
An algorithm is only a part of the solution. Data
structures (also the dynamic ones) are another
part. The cooperation between the parts of the
application is also important. When you are fixed
to some algorithmic view at very early stage, you
may loose the global view to the solution.
The object oriented programming and design is the
result of also such observations. One should
decompose the problem very carefully, not thinking
about implementation details at the beginning.
Each change in the abstract view may cause changes
of those details. If you put too much work into
designing the details, you may feel sorry later to
throw it away, and this, in turn, may break the
search for better solution.
One should start to decompose the problem from the
top to the bottom, hierarchically (once known as
top-down design, but mainly from the algorithmic
point of view). One should preserve clean
interfaces between the parts (no dirty dependences
on some internals of the solution) -- I am
thinking about the abstract view here, not about
typing the source.
One should continue to decompose until you reach
some level where you know that the part is
implementable, self-contained. In other words,
you do NOT know ** how ** excactly it will be
implemented, but you are somehow convinced that it
is possible to implement it. You must know
** what ** it should do.
... and this is the key point. This should be
documented. This gives you some some global view
of the problem. And this should also be the case
when documenting functions, especially the member
functions (i.e. object or class methods).
The ** how ** is not that much important here if
you know that it is possible ** somehow **.
> I think in a algorithm. After I encode this
> algorithm. And if I have some time, I document the
> program. This is wrong. Doxigen help me to write
> the documentation near the code, so I write the
> documentation at same time.
I have observed many times that programmers
(students in my case) often tend to explain their
project in say "algorithmic way" like:
"If this holds, I do that. Then if this is the
result, I do this..."
It's because they think this way when implementing
the solution. They know ** what ** they are implementing.
But for other people---and even for other programmers
(students) who do not work on the same project---this kind
of explanation brings too much details and do not
give some global overview of the problem. My
personal experience also is that after 2 or so
months (doing other things) you will be in a
position of "the other" person. You will look at
the code that you wrote and you will try to
understand "Why is this done this way?".
In my opinion, writing good comments inside
function body is necessary to avoid such problems in
future. But the question is whether you want to
extract them to the documentation. Usually, you
need the comments inside the function body only if
you are really interested in understanding
details. Probably, you are going to modify the
function. Probably, you do it when you are
programming, looking inside sources. It is
unlikely that you will want to do it through
looking at the generated documentation.
The documentation must be much more brief
and somehow much different. We should
take advantage of the human ability to
understand also rather not mathematically-precise
descriptions. The long, machine-oriented (or
mathematically accurate) descriptions are not
always better for humans.
When you extract the steps from the function body,
it is likely that the result will look very machine
oriented. It will never be one sentence that will
describe the problem being solved.
> > Once your project and documentation gets bigger,
> > you will appreciate other features than digging
> > out as much details as possible. The opposite
> > may be desired. If the printed documentation
> > would have 2000 pages, nobody would ever read and
> > study it.
>
> OK. It is posible, hide or show algorithm coments.
Then, if you finally hide it, why do you want to
generate it? Only to work with "sources" through
the documentation?
> > I went through the
> > same stage as you are going through now -- so I
> > think that I can speak about having such
> > experience.
>
> OK ;-) I am a newbie.
;-) Don't take me wrong. I am not your teacher,
and you are not my student. We are absolutely equal
here. I am also learning by reading the ideas
like yours.
Regards,
Petr
--
Petr Prikryl, SKIL, spol. s r.o., pri...@sk...
|
|
From: Prikryl,Petr <PRI...@sk...> - 2001-09-26 10:03:29
|
...one more comment ;-)
Jose Luis Zabalza wrote:
>
> Petr Prikryl wrote:
> >
> > [...] any function should be on a
> > bit higher level of abstraction [...]
> > for me it is much easier to
> > sketch the idea more roughly in the comment
> > outside the body.
>
> OK. I think so. It's all right. But, when you have hurry up is very easy
> forget the generic abtract comment but it's easy to write a little coment
> near the for keyword, or near the if keyword or near the return keyword.
I see. You are not the only one to forget this.
Often, the final form of the comment is known
only after the final implementation. In such case,
I use \todo command, like here:
/*! \brief This is brief description.
This is the abstract comment describing less briefly
the functionality. But it is not finished!
\todo Update the comment.
*/
int f()
{
return 42; // i.e. solving the same problem in constant time ;-)
}
HTH,
Petr
--
Petr Prikryl, SKIL, spol. s r.o., pri...@sk...
|
|
From: Jose L. Z. <jlz...@ca...> - 2001-09-26 17:14:19
|
El Mié 26 Sep 2001 11:40, escribiste:
> ...one more comment ;-)
>
> > OK. I think so. It's all right. But, when you have hurry up is very easy
> > forget the generic abtract comment but it's easy to write a little coment
> > near the for keyword, or near the if keyword or near the return keyword.
>
> I see. You are not the only one to forget this.
> Often, the final form of the comment is known
> only after the final implementation. In such case,
> I use \todo command, like here:
>
> /*! \brief This is brief description.
>
> This is the abstract comment describing less briefly
> the functionality. But it is not finished!
>
> \todo Update the comment.
> */
> int f()
> {
> return 42; // i.e. solving the same problem in constant time ;-)
> }
>
This is the first step to don't write the documentation ;-)
Regards
--
José Luis Zabalza
jlz...@ca...
Linux User 172551
|
|
From: Jose L. Z. <jlz...@ca...> - 2001-09-26 17:11:33
|
El Mié 26 Sep 2001 10:35, escribiste: > Hi Jose and others, > > You have to type more characters, and (what is > more important) you have to think about what you > are expected to type. You have to take care to > get the good result. Rather exagerating, you are > writing another program in parallel. **** Yes **** this is the question. If doxigen scan inside the functions and recongize the keywords (for, if, while, switch) I don't need worry about the indentation. > > > An algorithm is only a part of the solution. OK. ¿ It is not importat to show it in documentation ? >Data > structures (also the dynamic ones) are another > part. The cooperation between the parts of the > application is also important. When you are fixed > to some algorithmic view at very early stage, you > may loose the global view to the solution. OK. I agree. But ** also ** is important. > > The object oriented programming and design is the > result of also such observations. One should > decompose the problem very carefully, not thinking > about implementation details at the beginning. 100 % OK But when you have problems any help is good. > Each change in the abstract view may cause changes > of those details. OK but the "details comments" are just near the code. You need to be a beast to no correct the situation and comment the changes. > In other words, > you do NOT know ** how ** excactly it will be > implemented, but you are somehow convinced that it > is possible to implement it. You must know > ** what ** it should do. > OK but when you have problems... You need see the code. And I don't want this. > The ** how ** is not that much important here if > you know that it is possible ** somehow **. are you sure ? > > > I think in a algorithm. After I encode this > > algorithm. And if I have some time, I document the > > program. This is wrong. Doxigen help me to write > > the documentation near the code, so I write the > > documentation at same time. > > I have observed many times that programmers > (students in my case) often tend to explain their > project in say "algorithmic way" like: > > "If this holds, I do that. Then if this is the > result, I do this..." > > It's because they think this way when implementing > the solution. They know ** what ** they are implementing. > But for other people---and even for other programmers > (students) who do not work on the same project---this kind > of explanation brings too much details and do not > give some global overview of the problem. If you have documented ** what ** and ** how ** you don't need see ** how **. But if you have problems you need ** how ** If you are a teacher, ask this questions to your students? What happen if you have a undocumented or insuficient documented code ? Result = Smoke in head by reading the code. > > Then, if you finally hide it, why do you want to > generate it? Only to work with "sources" through > the documentation? Because the comments inside the functions are important * only * when I have problems and read the code is a waste time if the code are writed by a programmers team. > > > > OK ;-) I am a newbie. > > ;-) Don't take me wrong. I am not your teacher, > and you are not my student. Why not? I like learn. > We are absolutely equal > here. I am also learning by reading the ideas > like yours. I am a experience programer and I find doxigen after write many code lines and many unlinked documents. I like doxygen. It is also I search. Thank you very munch. It is very instructive. -- José Luis Zabalza jlz...@ca... Linux User 172551 |