Quality of code is getting lower and lower?
do you think it's truth that the quality of the code is getting worst and worst by time?
the programming languages can really let you do stupid things...
lets say in VB, you can exit any loop, by typing "Exit LoopType", instead of programming in a right way, and just get your condition right, in QBasic (or basic) you couldn't do that...
in C++, break, goto and that kind of stuff, I never use them, I think it's wrong programming, is it allways was that way?
Frequently things like break make code much cleaner. Instead of:
if(a)
if(b)
if(c)
if(d)
DoSomething();
else
else
else
you could do:
if(!a)
break;
DoSomething();
goto is generally ugly, though I have seen a few occasions when it's a useful as an optimization (See Intel's X-Scale optimization code...it's seriously the most hacked-together, ugliest code I've ever come across, but it sure is fast...)
In general, though, yes, people do stupid things, and language designers let them. Oh well.
if(a)
if(b)
if(c)
if(d)
DoSomething();
else
else
else
you could do:
if(!a)
break;
DoSomething();
goto is generally ugly, though I have seen a few occasions when it's a useful as an optimization (See Intel's X-Scale optimization code...it's seriously the most hacked-together, ugliest code I've ever come across, but it sure is fast...)
In general, though, yes, people do stupid things, and language designers let them. Oh well.
Quote:Original post by OrcSlayer
do you think it's truth that the quality of the code is getting worst and worst by time?
The quality of the programmer determines the quality of the code.
Quote:
in C++, break, goto and that kind of stuff, I never use them, I think it's wrong programming, is it allways was that way?
How do you exit a loop? Do you use switch statement?
There's nothing wrong with break, continue, Exit...or even goto.
But one needs to be careful and deliberate about using them. Understand why you're breaking the control structure, and be aware of any side effects that may result.
But one needs to be careful and deliberate about using them. Understand why you're breaking the control structure, and be aware of any side effects that may result.
Quote:Original post by OrcSlayerFirst of all, things get "worse" (a description of continuing deterioration), not "worst" (which is final, and thus can't keep happening).
do you think it's truth that the quality of the code is getting worst and worst by time?
Second, your programming skills are negligible, given your lack of comprehension of the value of powerful flow control constructs. Not every loop is condition-controlled; sometimes you intentionally write what would seem to be an infinite loop and use a break or other exit statement to terminate it because that's the most logical, efficient and readable way to code it.
In summary, learn to program before speaking about global code quality. Don't be hasty to assess things you don't fully comprehend. If such features are popular in several languages, then maybe there's a good reason why. Let the evidence suggest the argument rather than finding evidence to support a pre-disposition.
Happy hacking.
I use break and continue all the time. Without those two wonderfull instructions, the code would be very, very bad.
Let's consider this code:
for(i=0;i<10000000;i++)
{
do_something();
if(i==a)break;
}
Now, please convert it to a non break version.
Let's consider this code:
for(i=0;i<10000000;i++)
{
do_something();
if(i==a)break;
}
Now, please convert it to a non break version.
Quote:Original post by Raduprv
for(i=0;i<10000000;i++)
{
do_something();
if(i==a)break;
}
Now, please convert it to a non break version.
i = 0;do{ do_something();}while(i != a && ++i < 10000000);
I still concur that break and continue are great constructs though.
for(i=0;i<10000000;i++)
{
do_something();
if(i==a)break;
}
well, I don't know if this is more efficient:
while (i < 100000000) && (i != a)
{
do_something();
i++
}
edit: someone beat me to it
{
do_something();
if(i==a)break;
}
well, I don't know if this is more efficient:
while (i < 100000000) && (i != a)
{
do_something();
i++
}
edit: someone beat me to it
Quote:Original post by Vasant56
while (i < 100000000) && (i != a)
{
do_something();
i++
}
edit: someone beat me to it
actually there's a subtle flaw with that code, in the original
code a is tested after do_something has been called giving the possibility that a is global and that do_something modifies it
hence the correct while would be:
i = 0;while (i < 100000000) && (i == 0 || (i - 1) != a){ do_something(); i++;}
and that doesn't look to pretty, that's why I translated it into a do while.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement