[Ktechlab-devel] bad news, everyone...

Alan Grimes agrimes at speakeasy.net
Fri Mar 6 23:36:24 UTC 2009


My contract has been renewed! =\

Therefore I'll be spending my time desperately trying to restart my
financial pumps which have been running dry for the last two months. =(

Attached is a circuit which shows what happens when you put a voltage
into a cube with a voltage source on one corner, a sink in the other,
and a resistor along each edge...

It's obviously quite glitchy....

It's there because I introduced a bug into the code a few days ago.

Why did I introduce the bug?

I'll tell ya, because I haven't been able to make heads nor tails out of
a whole mess of classes at the ragged edge between the UI and the
underlying calc engine!  (these classes include Pin, Node, ECNode, and
Wire)

True enough, you could revert some of my changes, but please don't. We
need to get to the heart of the deeper issue, that the code's a mess..

These are the things that should be done to help move the code towards
maintainability, what I've been worknig on myself this past week.

1. Continue the hunt for worthless class variables. There are many cases
in the code that a class variable will be used to cache a value that
should properly be maintained by another class, these are idiot's
optimizations, they destroy code readability and should only remain
where a good case could be made for them. Every variable is a potential
bug!

2. Find and remove unused or redundant methods. In NonLinear there was a
function that found the diode current, a slightly different function
that found the voltage, and a slightly different function that found
both! The major problem with this is that if you fix a bug in one of
them, it remains in the other three. Furthermore, the diode current and
voltage functions were heavily redundant, and were almost always called
at or near the same time. Therefore I converted the entire project to
use the calc diode junction function and discarded the other two.

3. Make classes bulletproof. Class variables should almost always be
either protected or private, unless it's total overkill. Also, no class
should perform any algorithm on another classes variables, instead the
algorithm should be written as a method in that target class. (TESTING
FRAMEWORK NEEDED!!!)

As the code approaches readability and maintainability, start with method:
void CircuitDocument::calculateConnectorCurrents()

in circuitdocument.cpp and go through it line by line to make sure it's
doing the right thing in the right way and all of the variables and
methods it calls are pretty sane. That should clear out the bug I
introduced and move ktechlab well down the field towards being a robust
piece of software.


-- 
New president: Here we go again...
Chemistry.com: A total rip-off.
Powers are not rights.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cuberesistance.circuit
Type: application/x-circuit
Size: 8643 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/ktechlab-devel/attachments/20090306/844a3260/attachment.bin>


More information about the Ktechlab-devel mailing list