Are you talking about how programming often involves sitting down and
pissing and twiddling with the code until it does approximately what you set
out to do, without too many bugs?
In my earlier years, I did a lot of that. I wrote a ray caster pseudo-3D
walkthrough program, even with textures (okay, so 8x8 isn't much for a
texture, but still), and today I look at the QuickBasic code I wrote and I
just think
Huh?
I know I did it basically by iterating a line, segment by segment (yeah,
slow) from the viewpoint until it intersects a wall, and that the decimal
fraction of where it intersects determines what column of pixels to draw
from the texture in memory, and that distance times the cosine of the ray's
angle determines drawn height on screen, but damned if I can read the code
and figure out exactly how I did it.
And not only that, but once a piece of code is down, whether or not it works
"well", it works, so you're not apt to change it ("if it ain't broke don't
fix it").
I think this compares well to electronics. Maybe you haven't figured it out
yet, but you're new, too.
I don't know what anyone else calls it, but I'd like to call it "simulator
syndrome". You start with a basic pretense of a circuit, maybe some
theoretical setup that forms the heart of your project. Then you
crystallize parts around that, twiddling until it works to your
satisfaction. So now you have a circuit, that works, in the simulator. The
problem is, the simulator is an idealized reality, and like so many
philosophies[*], it can just crumble to a stinking bucket of shit when you
print it with real components.
[*] Homer Simpson quote:
"In theory! In theory, communism works. In theory!"
Even without a simulator, you can still fall into this fallacy. I
personally have built a preamplifier, that worked, by using single base bias
resistors from +V to base. You're supposed to use a voltage divider, so
bias current is set by that voltage and the emitter resistor. It'll work
either way, but my way won't work very well with different transistors (even
from the same batch) or across a temperature range, or across much time for
that matter!
I think these situations are analogous to the mindless programming I
described earlier. It's like using, well hell, anything QBasic at all -- I
don't think I've *ever* compiled an .EXE under 30 kilobytes! What
bloatware. And you can print "Hello World!" with probably about one
thousandth that of just machine code (compiled ASM), a large percentage of
that being the message itself. They accomplish the exact same tasks, so
clearly you can say they both "work", so what's the difference, who cares if
it's 29,970 bytes bigger?
On the other hand, the methodical approach to programming and electronics
involves laying things out in convienient blocks and working each relatively
discrete unit seperately. Recently (last year) I made a delve into
programming, writing a 3D-point-placing program (again, still in QB) to go
with a fly-through-space program I made years ago. I started with the
original program's engine, but because I need two seperate systems, edit and
test, I chucked that in a subroutine, copied its control loop (IF Keyboard$
= "A" THEN ...) and changed, added and removed keypress functions.
Since all the type defs need to be there, plus a few extra, I kept that on
the main module. I added a bunch more shared variables, as is required.
QBasic sucks at memory (one could argue it is I who doesn't know how to use
it, fair enough
so for the main data storage I initialized an array using
all remaining available memory, about 36kB, and then I merely adjust the
maximum index value according to how many points are in the loaded file.
When initializing a new point, its value is reset to default (0,0,0) so,
although the old data remains in memory, you can never access it.
Since the screen fonts suck on a graphical display, I already planned to add
a font I created some time ago. To keep the main module *relatively* neat,
I put the display redraw under a sub, which erases, draws all the lines and
windows and stuff, then adds text bits (menu, vital information, etc.) and
finally places dots representing the verticies in view of each window (all
three of which can be scrolled and zoomed individually). Mouse was a
required part so I dropped that in...actually I didn't since the program had
it to begin with.
I did add a function that selects the nearest point
when you click the mouse on a viewing pane, not to mention all the clickable
areas for entering data. BTW, 657 lines, about 22kb file, 70KB compiled.
The 3D viewer alone (which I started from, and which is contained within
said) is 9KB code.
But for all of the immense complexity, I completed it in record time, a few
months maybe. The progression of 3D programs I've made took years of
on-and-off tinkering and twiddling. Likewise, of my electronics, two of my
tube amplifiers...
http://webpages.charter.net/dawill/tmoranwms/Elec_Frankenhouse.html
http://webpages.charter.net/dawill/tmoranwms/Elec_Revision3.html
(See, there's a reason the latter is named what it is
....have been subject to a range of tinkerings. The pages above should be
the latest model, while back schematics may be under my schematic
collection. But my most recent project, the induction heater, has been a
logical progression: theory model, large theory model, switching model,
model sized prototype, final prototype. And in that, I've been keeping the
more complicated circuit down to more basic elements.
For example:
http://webpages.charter.net/dawill/Images/Induction_Heater_Draft1.gif
- It's like, what the **** is this? Besides my habit of drawing tight,
confusing schematics, it's hard to see what's going on because there's just
so much going on. It doesn't even fit on one screen! (Shut up Jim ;-)
This, on the other hand:
http://webpages.charter.net/dawill/tmoranwms/Elec_IndHeat6.html
is broken into five seperate images, and most of them (especially #3)
include a lot of air between sections, letting you see much easier the
further discrete circuits: transistor switches, comparators, amplifiers,
followers.
The first one I drew as a composite of six sheets of paper I scribbled my
first draft on. The second [set] I drew after a few suggestions and
revisions, but I think represents the block theory better than the first,
which represents chaos rather than the order it's supposed to be.
If you should take any class at all, I suggest a high level math course,
with a good professor. Learn problem solving tactics. The thing about math
is, you can only do so many things with an equation, so think about it,
consider which tool fits the nut the best, then give it a twist. And
everything in math is derived from everything else: calculus seems
intimidating yet is so wholly intuitive and can be expressed in terms of the
most basic theorems and arithmatic. The only thing hard about it is
remembering all the identities and how to derive them, but if you think
about them you can cover those too. A lot applies to electronics: analyze
the situation, figure out what functions you need to perform, then figure
out which circuit elements can be combined to serve that function.
I could go on and on, happily because it's such a pleasure to make things
and use logic, but alas, I've more or less hit the stopping point of what I
wanted to say. If it makes any sense at all...
Tim