print the dynamic input

B

Ben Bacarisse

arnuld said:
Okay guys, I have finally reduced the get_single_word() to less than 40
lines. Does anyone has his views on my refactoring method:

I am not keen on it. The division of labour between the get_ and
save_ functions seems to be quite arbitrary and not helpful in
understanding the code.

I would not even write the separate allocate_new_mem function. A
small function being passed that many pointers to variables in the caller
is not a good idea. It created too much "linkage". Rather than being
able to read and understand each function on its own, the reader now
has to see what allocate_new_mem does to all of its parameters in
order to understand get_single_word.

At the very least, the modification of word_begin does not belong
there. Also, please change the name of this variable. It points, to
the end of the word being saved, not the beginning (OK, initially
these are the same, but that is not the point).
 
A

arnuld

I am not keen on it. The division of labour between the get_ and
save_ functions seems to be quite arbitrary and not helpful in
understanding the code.


Thats what I have felt but I created them as that makes the functions
short enough.

I would not even write the separate allocate_new_mem function. A small
function being passed that many pointers to variables in the caller is
not a good idea. It created too much "linkage". Rather than being able
to read and understand each function on its own, the reader now has to
see what allocate_new_mem does to all of its parameters in order to
understand get_single_word.


yes, even myself, after 1 day, have to look for what (*pul)++ was doing in
save_single_word().


At the very least, the modification of word_begin does not belong there.
Also, please change the name of this variable. It points, to the end
of the word being saved, not the beginning (OK, initially these are the
same, but that is not the point).


okay, I changed the name to save_ele (means the position of saved element)

I am convinced on using the older 63 line version of get_single_word().
but still, 63 lines bug me a lot all the time. In the beginning, when I
created a function with 63 lines does it mean that my program design was
not good in the beginning ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,295
Latest member
EmilG1510

Latest Threads

Top