Sujet : Re: Should I write building blocks?
De : tp_wallace (at) *nospam* yahoo.com (Tim Wallace)
Groupes : comp.lang.tclDate : 25. Jan 2025, 01:51:22
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vn1cia$2fopb$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 1/24/25 18:34, Luc wrote:
I am usually so well rewarded for asking questions here so what the hey.
Might as well try again.
I have personal issues. For that reason, my coding habits are spotty
at best. I don't really abandon my projects. I just postpone them when I
am not feeling well. But one wouldn't be able to tell the difference. I
postpone them for very long periods.
On top of my personal problems, the long periods of inactivity make
me very unfamiliar with my own code. Picking up where I left off is
hard. I have to read everything again and make heads and tails of the
whole thing and know where to look when the code throws an error.
It's so bad I sometimes decide to just start over, from scratch.
The awareness of the wasted effort hurts, but at least I will know
what I'm doing and where I'm going with the code.
It's all quite tiresome and discouraging. So I postpone. Again. Again
and again.
I like to associate this problem with an old idea of mine: functional
programming. I'm sure I've seen that term before but probably with a
different meaning. I mean writing blocks of code, likely procs (I know you
lot are going to tell me to write classes) that can be fitted in most of my
projects so well that I just need to copy-paste them and put the whole
machine together almost like magic.
I already do a little bit of that. I find myself copying blocks of
code from one old project to a new one quite often (and my IDE has a very
useful "snippets" feature), but there is always the problem of adjusting all
the variable names and perhaps even proc arguments and parameters. But I
often crave something richer than that. I fancy much better building blocks
that will help me produce stuff with a lot less effort, on use and reuse.
Maybe I should pause all the projects (even more so) and spend some
time focused on writing such blocks? Is that a good idea? Should
that wheel be reinvented?
Elders of the Code Church, what is your wisdom?
Write comments before you write the code--explaining your thinking and plans. In grad school I had to write in Fortran and C, and half my lines were comment lines (especially in Fortran). Made it easier to go back!
I also wrote it top-down, the main program first and various subroutines and functions as needed. Kind of paralleling the thinking.
--Tim