|
The guy's got a point, though. I'm looking at my code here (which is written according to received standards), and the rightmost 2/3 of my IDE's code editor is pure black, because the text is just in a tiny strip down the left.
|
|
|
|
|
Yeah! The stone age is over. However, non-superhumans get very confused when lines contain more than 60 characters.
|
|
|
|
|
this is so yesterday!
the new 1920x1200 is 1366x768
|
|
|
|
|
And on laptops the stone age isn't over, really. Try getting a laptop nowadays with that resolution. Luckily I got mine 2 years ago.
Wout
|
|
|
|
|
Function GotoSleep(Milliseconds As Long)
Sleep (Milliseconds)
End Function
|
|
|
|
|
I say this developer had brilliant foresight and should be given both a raise and a promotion! They must have known that VB's built-in functions would be transitioned to the .Net Framework at some point. Now, they only have to change a single line of code to make sure their entire code base uses System.Threading.Thread.Sleep() .
They have also created a function rather than a sub, a clever trick in case they ever decide to return a value (e.g., a bool indicating whether or not the sleep operation was successful). Ingenious!
|
|
|
|
|
Not to mention the magnificent documentation this programmer provided! It's better documented than most code I know
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Surely, they should return the value while the thread is asleep, and stop returning it when it wakes up?
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Just a little change will allow for multi-threaded sleeping, i.e. create a new thread which does the sleep thus not blocking the main application . Imagine you'd have to do that when you used the built-in function everywhere...
|
|
|
|
|
And he even included a "Goto" in there somehow. Awesome.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
You get VB?
Wout
|
|
|
|
|
Good Time to all, Amici(Friends).
Here, i'd like to discuss how to reduce conditional branches in the code. 1st of the all, i would like to share some tricks. Their description is here.
-----------------------
Thanks in Advance for attention of Yours.
|
|
|
|
|
The readability of the if-less code is bad. What do you have against conditional branches? I would much rather have readable code with conditional branches instead of less readable code with out them.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
yes, readability is worse but superfluous IFs make code slower. Actually, it will be extremely helpful, if new compilers shall be able to generate such blocks of IFs.
|
|
|
|
|
SarK0Y wrote: superfluous IFs make code slower. That isn't necessarily true. Modern processors use a variety of tricks that reduce the 'cost' of unused branches. One of the problems of 'computed conditional' logic is that you incur the cost for all cases, not just the unused branch. Your overall performance actually decreases.
Software Zen: delete this;
|
|
|
|
|
Especially with moores law hitting the ceiling lately (until someone finds a trick to break through and go up another 100 floors). Can't make it go any faster -- so add more cores. Can't utilize all the cores -- so add more microcode parallelism. Soon they might end up having CPUs that can follow dozens and dozens of branch path pipelines at the same time (until it can prune unused ones). Of course, the information that can be saves during context switches may limit that technique.
On a side note.. Some languages (like Smalltalk) don't actually use branching in "if"'s (well, their equivalent to an if).. what may seem a condition check/branch is really an expression returning a boolean object, and then when asked to _run_ the "ifTrue" conditional code block it either does, if it is a "true" object, or doesn't if a "false" object, without any checks/branching. And the same for the "ifFalse" (aka "else") code blocks, only reversed.
|
|
|
|
|
Are you aware of the 90/10 law?
90% of the time is spent in 10% of the code,
and only 10% of the time in the remaining 90% of the code.
If you are attempting to optimize code in the 90% of execution time, great. Otherwise leave optimizing alone.
Use macros with good names to do optimizations, and it will *hopefully* make your code clearer.
If you were targeting code for the ARM cpu then eliminating branches is totally pointless because..
ARM cpu has conditional branching on almost every cpu instruction, but doesn't cost extra cpu time to fetch a separate branch instruction like on many CISC cpus.
|
|
|
|
|
Actually, modern compilers do a very good job of optimization. They've come a long way over the years. You probably won't see enough of a change to notice.
|
|
|
|
|
in OOP use duck typing as means to avoid using if's and case statement to invoke objects of different classes.
[^]
|
|
|
|
|
RonDsz wrote: duck typing
Quack, Quack!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
|
That's a little iffy.
Sorry
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
With this code you are a winner of obfuscated C contest.
|
|
|
|
|
Monaco.Bavarian wrote: you are a winner of obfuscated C contest
Thanks, I generally dislike reading C++ because its nature seems to be obfuscated = better.
That one was so hard to read, I couldn't understand the point. From comments it looks like the point is that using if tests to branch to another location is a bad practice.
Everything I've read leads to not using spagetti code. IE branching is good.
I just read an article about bubble sorting and someone reading the article believing it was efficient. I was just going to leave the article thinking it was written by a beginner, leave him alone, but when a reader believes it is efficient. I couldn't just drop it. On initial tests, just 200K takes over 2.5 minutes. I calculated 20M would take 70 weeks. I built a less readable set of code that sorts 50M records in 14+ seconds.
Less readable = much greater efficiency to me is a good thing. (At least when comparing weeks to seconds.) I didn't see the benefit of his code in the article.
|
|
|
|
|
If you use constructs like this below (or with more if else) there are much combinations to test.
It would give a bad software metric if you use a test tool. We have to use test tools for our
tests of space applications.
But the way the guy wrote his code is more bad. A construct like below written in his if free
style would be unreadable for someone else and I bet the performance would be very bad too.
if ( expression1) {
if ( expression2) {
if ( expression3) {
...
} else {
...
}
} else {
if ( expression4) {
...
} else {
...
}
}
}
else {
if ( expression5) {
if ( expression6) {
...
} else {
...
}
} else {
if ( expression7) {
...
} else {
...
}
}
}
|
|
|
|