|
Unless you're an embedded developer trying to squeak out the quickest code on an underpowered processor. I was always getting projects with weenie processors and grandiose firmware requirements. It seems that the hardware engineer had a rather limited grasp on firmware development and how much space/speed would be required for the project. They eventually figured out that I should be involved in the processor and memory requirements selection.
|
|
|
|
|
I sure know that. My first computer had a hex keyboard and actually was very much like today's microcontrollers. And I still have it and use it, just to stay sharp.
Edit: Picture[^]
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I kind of wish I'd kept my first computer. It was a z80 S100 bus system where I wire wrapped all the boards except for the display card (16 lines by 64 character with a rf modulator to display on a TV). I had a 2kb monitor program (Zapple) that gave you the standard peek/poke memory, dump memory, input/output to I/O, run from an address and set break points. I use to knows most of the z80 instruction set by the numbers. Good times.
|
|
|
|
|
Great! The good old times never ended for me, partially because I would see it as a great loss if that old computer ever died, partially because such old tech is the is the only option to tinker around with as a hobby without getting poor. I'm certain you know what kind of equipment and knowledge is needed when you want to play around with the most modern stuff.
It's more interesting to overcome the limitations of the old stuff anyway. Modern chipsets do that for you, so where is the point in puzzling them together as intended? Why don't you grab a Z80 on ebay and build a new old computer to bring back the old times?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
There's actually some modern stuff that's inexpensive. Look at some of TI's Launchpads. They're on the order of $25 and the IDE they provide (Code Composer Studio) is free. It's based on Eclipse so it's pretty powerful. The last project I was working on before I retired (woohoo!!) was based off of one of their Launchpads. I was able to get a lot of the code working before we got our own hardware up and running.
|
|
|
|
|
sasadler wrote: Eclipse So we meet again, my old enemy!
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Yeah, there is that. So far, I've only found 1 version of Code Composer Studio (CCS) that worked reliably for me (version 7.4), all the later versions I tried would work for a bit and then would stop letting me reliably debug my code through the jtag device. I'd have to close CCS and restart it to be able to reconnect to our hardware. Sometimes had to unplug the (USB based) jtag device and plug it back in to get it to start working again.
I only used CCS for compiling and debugging, the rest of the time I used my own favorite editor to write the code.
|
|
|
|
|
That is the best advice I have seen from re-sharper and I've seen it show some bad alternatives
one was and only know it was re-sharper as the Dev stated it was what re-sharper advised him to use
public bool someMethod(int valueA, bool Valueb, bool ValueC)
{
var output = DoSomethingElse(ValueA, ValueB) ? RunAnotherMethod(ValueA, output.SOmething) :
DoAnotherMethod(ValueB, ValueC) ? RunAthoerMethod(ValueB, output.SomethingElse) :
DoYetAnotherMethod(ValueA, ValueC) RunAnotherMethod(DoYetAnotherMethod(ValueA, ValueC), output.AgainSomethingElse);
}
This horrid IF ELSE statement contains 16 if's
Footnote: I don't like using Resharper
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Layout can help a lot:
public bool someMethod(int valueA, bool Valueb, bool ValueC)
{
var output = DoSomethingElse(ValueA, ValueB)
? RunAnotherMethod(ValueA, output.SOmething)
: DoAnotherMethod(ValueB, ValueC)
? RunAthoerMethod(ValueB, output.SomethingElse)
: DoYetAnotherMethod(ValueA, ValueC)
...etc.
}
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Still: Yuck!
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
agreed. that is just a nasty example of embedded logic.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
|
That would depend on whether I return a value or not.
On a related note, K&R or Allman?
|
|
|
|
|
Whitesmiths.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I did expect that answer.
|
|
|
|
|
You're a monster
Allman ftw.
|
|
|
|
|
Under most circumstances, a single return is best. But ... I much prefer this:
void MyFunc ()
{
if (!ValidateUserInput(ATextBox.Text))
{
TellUserAboutTheProblem();
return;
}
if (!ValidateUserInput(AnotherTextBox.Text))
{
TellUserAboutTheProblem();
return;
}
...
} To this:
void MyFunc ()
{
if (!ValidateUserInput(ATextBox.Text))
{
TellUserAboutTheProblem();
}
else if (!ValidateUserInput(AnotherTextBox.Text))
{
TellUserAboutTheProblem();
}
else
{
...
}
} And sometimes the best thing to do is just return, particularly from a nested loop:
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
if (myArray[i, j] == value) return true;
}
}
return false; Any other mechanism is just making it more complicated, not less.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's the longer and much better version of what i couldn't bother to write down.
|
|
|
|
|
I thought you were joking when you said Whitesmiths!
for()
{
for()
Really hurts my eyes
for()
{
for()
I like.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
You are welcome to your opinion*, but I like the way it's consistent: the indentation is the whole of the relevant block of code:
if (a)
b;
if (a)
{
b;
c;
} Instead of the inconsistent Allman:
if (a)
b;
if (a)
{
b;
c;
}
* As long as your opinion doesn't include using 1TB, of course.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have been brainwashed to NEVER do:
if (a)
b;
I think the preference is a matter of taste. I don't find either alternative more "consistent". "Consistent" depends on how you define that word (and the words "relevant code"). When skimming over large blocks of code the braces are - for my eyes - easier to find Allman style.
And the b; is very slightly easier on my eye in your Allman example. My guess is that we prefer what we were exposed to when we started walking... coding...
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
|
OriginalGriff wrote: void MyFunc ()
{
if (!ValidateUserInput(ATextBox.Text))
{
TellUserAboutTheProblem();
}
else if (!ValidateUserInput(AnotherTextBox.Text))
{
TellUserAboutTheProblem();
}
else
{
...
}
}
One of my first program was this. Luckily I started coming here and learned how to do it better
|
|
|
|
|
sort of depends on what I call the "story"
if the story says "if X is null or is [example] an empty list then stop processing" = in my mind early return.
if the story says "do thus-ad-that to the contents of X" - to save on errors naturally check X for null/empty makes sense - then of course it's if (X != null) ...
Forogar wrote: ntroduces an execution statement (return) on the same line as the "if" which is bad coding practice
?????????????? bad coding practice ????????????????? huh?
Nothing is wrong, nor bad, nor unsafe with that code, it is perfectly good code.
you confuse practice with style: style is subjective, "bad practice" increases the chance for error or failure.
personally I dislike code that runs too many pages, so I often put short single statements and opening braces on the same line as the if (), while () etc. (Coming from K&R style C background.) and I like ....
AND SO, before you say it, I'll say it for you:
--- you think my style is ugly.
Well guess what:
---- I think your style is ugly.
AND WHO CARES!!
1. it's the code that matters, NOT THE STYLE,
2. different style IS NOT BAD PRACTICE weather you like it or not.
(please don't bring up "readability" bullshit, I find more compact more readable, please don't bring up "industry standard" - my K&R background, and I'm not the only one doing it that way.)
3. you can have the editor re-format [to your preferred] style on one keystroke, so even more WHO CARES.
nuff said.
Message Signature
(Click to edit ->)
|
|
|
|
|
If you have dealt with Unix fanboys, you'll now doubt have encountered the stupid "which hacky character shall we use for white space: spaces or tabs?". The correct answer is "whatever the team is using, I format it to that before committing".
As for consistency, I only really am a stickler with f***ing braces. I've seen too many recurrent bugs because a programmer is cute and makes a braceless if. Then the next one comes in, adds one more call and doesn't realise the braces are gone. Ooops, billion dollar bug introduced. Nasty and no need.
|
|
|
|