? How do you decide on what arguments to accept?
You may gain some versatility by accepting different types like ename, elist or object.
Those are easy to test and have the subroutine convert to what it needs. Else the overhead
of converting is on the calling routine. If you have a large application and the routine is
called many times from many places it may be more efficient to convert the variable in the subroutine.
That said I usually don't as all my routines are small.
? What about output?
I assume you are referring to the returned value(s).
Seems to me that the function of the subroutine would dictate the return value(s)
? Do you put a lot of emphasis on error checking?
Ah the 'What IF' game.
i think the user input need a lot of error checking but not so much on the subroutine level.
I think you have to ask what are the consequences of the error. If the error just dumps the user
and no harm to the drawing then a simple error trap with a message is fine. If a lot of user input is
going to have to be re-entered it would be a good thing to trap & correct the error else the user
will be miffed at the program.
? Do you try a recursive approach first?
No, last. For me it's hard to program, hard to debug, hard to understand when i come back.
But it's a fun exercise at times.
? Is creating a separate function a last resort when designing an application?
I usually look at how many times the subroutine is used and how large the subroutine is and how
if affects readability of the routine.
If the routine will be used 3 or more times
Or if the routine is larger than 10 lines of code, my code not MPs
(sorry I have this condense idous disease and can't seem to shake it.)
Or if the chunk of code when removed to a subroutine makes the Main routine read more clearly
I sometimes will move it to a subroutine.
That said, I always break my own rules.
I look back at some of my older code, last month is older, and see it need some cleanup but
who has the time? If it ain't broke.
I only wish I could write like MP, and Mark and Stig & John and others but I don't think it's in me.
I guess we have our own basic style & it's hard to change that.
So I guess the answerers are subjective to some degree.
My 2 cents.
Wow that got long winded