← Back to team overview

kicad-developers team mailing list archive

Re: Miscellaneous stuff

 

On Sun, Apr 28, 2013 at 11:19:02PM -0500, Dick Hollenbeck wrote:
> Can you name the class where setangle, the interface, cannot successfully
> set an angle of any degree, without talking about client code?

No, I didn't look for it, but the compiler flagged that (innocuous) swap
so there *could* be others, but *proving* that would be difficult. Also
it's a moot point if *some* implementation inside truncates it to an
int.  That is what I meant. In some embedded application such kind of
analysis is mandated so I'm pretty paranoid about it (there are extremes
too: in MISRA C you *can't* use pointers at all to avoid indirection
errors; good luck passing parameters out from functions)

You can talk about interfaces and implementation as much as you want,
but if the code is wrong, is wrong:P In fact I think that hiding too
much behind an interface is dangerous *unless* it's so detailed that no
other implementation could implement it (happened to me, wasn't fun when
they changed the implementation). In short the black block approach
simply don't work (it's not useless, but it can't be trusted).

In fact, even if a dialog box doesn't accept a double (hypotetical,
since they already have to multiply by 10) your interface
would be fine but the *specification* (i.e. assigning a double to an
angle) wouldn't be met. Some could even argue that not accepting the
second digit would be a breach of specification, too (but, again, if
there is no rounding in the dialog code there shouldn't be any problem).

If you care so much about your interface the do programming by contract.
But then we decided to not overassert.

In this particular case probably most of the times angles are just
passed around or converted to radiants for trig so it's probably all OK;
in fact probably the only bug that could pop from this type change is
a rounding to one decidegree.

That said, I think that knowing that "angles in kicad are doubles
expressed as decidegrees" is a pretty important thing to know
(especially before it was "angles in kicad are ints expressed as
decidegrees"). That was the spirit of the question.

-- 
Lorenzo Marcantonio
Logos Srl


References