11-03-2009 08:34 AM
Ray.R wrote:Thanks for(imstuck),
Glad you provided the example. I just finished reading a thread that ranted against threads like this one. The chap forgets that there are always 2 sides to a coin. The purpose of this thread and the Rube Goldberg is indeed to educate. Not to make fun. There are many people who are adament about wanting to use Locals at all costs and claimwed that it is a better way of programming. That's what brought up this thread.
So I'm glad that you are sharing your own experience, that way people learn that even the finest of programmers can get caught by using Locals. Do note that I did not use the term "abuse", because in your example, there was no abuse of it. I too post code examples and ask on how to improve it. It's good for everyone. 🙂
I wouldn't call myself the "finest of programmers" ;). Haha. However, great response Ray. Kudos.
11-03-2009 09:05 AM
Thanks for(imstuck),
Glad you provided the example. I just finished reading a thread that ranted against threads like this one. The chap forgets that there are always 2 sides to a coin. The purpose of this thread and the Rube Goldberg is indeed to educate. Not to make fun. There are many people who are adament about wanting to use Locals at all costs and claimwed that it is a better way of programming. That's what brought up this thread.
So
I'm glad that you are sharing your own experience, that way people
learn that even the finest of programmers can get caught by using
Locals. Do note that I did not use the term "abuse", because in your
example, there was no abuse of it. I too post code examples and ask
on how to improve it. It's good for everyone.
Ray R
I was not ranting on my post about people abusing other people on here. There are people on here that are here just to prove how smart they are at what ever cost. It was a simple statement. I also feel that some of these areas are more for making fun of people than show a better way of do something. As I said in my post I have no problem learning from poorly executed code but to put it in a forum and just laugh at it no one learns and the other person may never come back for help. So an example of the code and an example of the correct way. That is useful to everyone. Post code laugh at the person and never give a better way to do it is useful to no one, period.
I was always told that if the code works it works. There may be better ways to do something and I always try and learn better ways.
11-03-2009 09:35 AM
Thanks for posting aeastet,
We can all learn and grow from each other's posts, comments, etc. Actually, sometimes, we may even forget why we started a thread in the first place 😉
I agree with most of what you said with one exception :
aeastet wrote:
I was always told that if the code works it works.
That sounds like a bloody manager who never wrote code....
- sigh -
I come from days when memory was at a premium. Where you had to learn to fit as much algorithm in a tight space in the early days of DSP. My original background (biomed) had to make sure that the code architecture met reliability guidelines and could recover from different identifiable faults. Part of the software design included Fault Tree Analysis (FTA) and Failure Mode, Effects and Criticality Analysis.
Saying something like "... if the code works, it works..." is the farthest thing from reality. Having that mindset does not automatically make you a saavy programmer. On the contrary, it makes you look for faults and how to improve upon it.
As a consultant, it makes life crazy, because you always deal with clients that give you code which is so broken that it is not funny. The results are consistently wrong, so the client argues that because they are consistent, they must be correct. Even arguing that the instrument is wrong and that the original code is correct. Then they look at you (consultant) and call you all sorts of names because we claim to be some sort of expert and tell tem what they do not want to hear... That the code that works, never really worked. I see it all the time. And as recently as last week. It happens in any language.
If we don't start educating people that code has to be readable, maintainable, scalable and logically sound, then what will be the future of software? It seems that the Universities & Colleges are slacking off and letting their students get away with poorly written code that works and that it is good enough. Would you want your life or that of a loved one to depend on code that is "good enough" or "it worked, so it must be okay"? People do not spend enough time to test their code for all imaginable conditions. The easy way has become mainstream.
To me, that's what's sad. Everyone is an expert as soon as "Hello World" appears on the computer screen.
I'm not claiming to be an expert. I'd probably be shot down by many in the forum which are way better than I am in software. But I don't let that get me down. I thank those that know more because I learn from them and it's made me who I am today. << Thanks guys >>
If people, including myself are making fun of someone and not the code, I'm sure it's not intentional. It is most likely because the person made that very same mistake in the past. I'm sure no one became an expert without making a few mistakes along the way. 😉
My being a nemesis to Locals is a way of getting people to look for alternative solutions, solutions that will endure the test of time (or long running program).
Writing code that works is one thing... Writing code that does not come back to haunt you is a completely different beast.
RayR
11-10-2009 09:10 PM - edited 11-10-2009 09:12 PM
Oh boy...
Abuse of the Local variables is the least of the problems with this code.
Stopping the top loop might be difficult.. It might run 10 times faster than the other loops.. But there's no guarantee.. Race conditions? Which loop runs first? When do each loop execute? Can you get the same result twice? (ever?).
This is an interesting example. It's actually nice to follow the flow with and without highlight execution ON.
Found here: http://forums.ni.com/ni/board/message?board.id=170&thread.id=454922
I don't think the calculation is the cause of any lag.. 😉
11-10-2009 10:12 PM
Ray.R wrote:Can you get the same result twice? (ever?).
Well, the random and unpredictable results will be very, very accurate, because everything is done in EXT. 😄
11-11-2009 07:07 AM
11-30-2009 07:47 AM
See code here: http://forums.ni.com/ni/board/message?board.id=170&message.id=459258
It was suggested to get rid of the Local Variables and use Shift Registers.
12-18-2009 08:14 AM - edited 12-18-2009 08:14 AM
Spaghetti with local balls.
http://forums.ni.com/ni/board/message?board.id=170&thread.id=463491
12-18-2009 09:47 AM
OUTCH!!!
Looks like a numeric keyboard..
12-18-2009 10:40 AM
Or a messed up Keno board.
http://en.wikipedia.org/wiki/Keno
-AK2DM