|
Haroon Sarwar wrote: well the class has been named CrapClass...was the developer in question trying to write bad code??
but i guess u must have renamed it urself...
Real names have been changed to protect the innocent (and the guilty).
|
|
|
|
|
Hi
You know I am really wondering why people actually posting questions in this forum? It should not be of the name, I mean how can someone think that coding horrors is a kind of help page???
And as I can see in the last posts they are getting more and more.
I just hope that they are coding better then reading instructions or names.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
And what be the coding horror in this "question"?
|
|
|
|
|
yes you're right. the coding horrors forum is definitely not the place to post programming questions and it's getting more and more. but you know.. your post is not a coding horror either and would be more appropriate in the soapbox or maybe in the lounge
Fatbuddha 1 wrote: I just hope that they are coding better then reading instructions or names.
do you?
|
|
|
|
|
Sorry for that I just was wondering!
You are right!
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
In part I would blame the forum's name.
"Coding horrors" can be taken for something horrible about programming, such as a coding task
one does not like, does not understand, etc.
To reduce wrong posts, I suggest "Horrible Code", which more clearly suggests it is about
existing bad code.
|
|
|
|
|
Or change to "I do not read that's why I am posting questions here" forum.
|
|
|
|
|
I say we go back to the WTF forum.
|
|
|
|
|
Page 1 - good
Page 2 - good
Page 3 - I see at least 5 programming mistakes in the sample code...
http://www.devx.com/DevX/Article/36196/0/page/1[^] Not bad, but that last page really spoilt it for me
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
You'd think that he could have at least tried to compile the code. How hard could it be?
|
|
|
|
|
nothing happens, C# is just as Java (i bet u can learn it with in 3 hrs excepts advance), and a programmer goes for concepts not the mistakes u done in syntax, of course if u compiled, it means u don't have syntax error. and also data structure/algorithm r independent to language, so conclusion = nothing happens
programming is just like poetry
|
|
|
|
|
Rizwan Yasin wrote: C# is just as Java
If you are happy with comparing apples to pears, and coding like a absolute beginner, then thats up to you. Please note, I said mistakes, not errors.
Rizwan Yasin wrote: and also data structure/algorithm r independent to language
Thats why I considered page 1 and 2 as good content.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
I have to say I can't see that many problems. Discarding every other random number is a bit weird in the first example. Throughout there's a reliance on the low-precision system clock returned with DateTime.Now and TimeSpan.Milliseconds returns the milliseconds part only, you should use TotalMilliseconds if you want it to tell you how many seconds elapsed. For more accurate timing results use a System.Diagnostics.Stopwatch .
At this point any collection which doesn't support generics is pretty stupid, the whole thing should be parameterized on T with a restriction that T derives from IComparable<T> or allows you to supply an IComparer<T>.
I'd like to see a comparison with inserting into a sorted ArrayList or List<T> and using BinarySearch. A lot of emphasis is put on the computational algorithmic complexity of data structures and algorithms, but these days practical algorithm performance is based on memory speed hierarchies, and cache locality is very important. Further, an array typically represents a lower load on the garbage collector than a deeply-linked data structure (fewer pointers to follow). There is a reason why Microsoft didn't and still don't supply linked list or binary tree structures with the .NET Framework.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
I inherited a website project from another agency who got sacked for being very slow. I was going through the nasty table layout site and found this gem in the site css.
.pbot10 TR TD TABLE.floatl TR TD TABLE TR TD TABLE TR TD TABLE TR TD.darkRed {<br />
BORDER-RIGHT: red 0px solid; BORDER-TOP: red 0px solid; VERTICAL-ALIGN: top; BORDER-LEFT: red 0px solid; BORDER-BOTTOM: red 0px solid; HEIGHT: 37px<br />
}<br />
.pbot10 TR TD TABLE.floatl TR TD TABLE TR TD TABLE TR TD TABLE TR TD.imgHorse {<br />
BORDER-RIGHT: red 0px solid; BORDER-TOP: red 0px solid; VERTICAL-ALIGN: top; BORDER-LEFT: red 0px solid; BORDER-BOTTOM: red 0px solid; HEIGHT: 77px<br />
}
and
.mleft5 {<br />
MARGIN-LEFT: 5px<br />
}<br />
.mleft10 {<br />
MARGIN-LEFT: 10px<br />
}<br />
.mleft15 {<br />
MARGIN-LEFT: 15px<br />
}<br />
.mleft20 {<br />
MARGIN-LEFT: 20px<br />
}<br />
.mleft25 {<br />
MARGIN-LEFT: 25px<br />
}<br />
.mleft30 {<br />
MARGIN-LEFT: 30px<br />
}<br />
.mleft35 {<br />
MARGIN-LEFT: 35px<br />
}<br />
.mright5 {<br />
MARGIN-RIGHT: 5px<br />
}<br />
.mright10 {<br />
MARGIN-RIGHT: 10px<br />
}<br />
.mright15 {<br />
MARGIN-RIGHT: 15px<br />
}<br />
.mright20 {<br />
MARGIN-RIGHT: 20px<br />
}<br />
.mright25 {<br />
MARGIN-RIGHT: 25px<br />
}<br />
.mright30 {<br />
MARGIN-RIGHT: 30px<br />
}<br />
.mright35 {<br />
MARGIN-RIGHT: 35px<br />
}
It had entries exactly the same as above for all possible options - mleft, mtop, mbottom, pright, pleft, ptop, pbottom etc as well as verdana9, verdana10, verdana11 etc. I think they missed the point of css somewhat. This is just the surface at first glance, I dread to think whats to come
|
|
|
|
|
Talk about inelegance… There are much better ways of accomplishing the above.
ROFLOLMFAO
|
|
|
|
|
hehe, I think they just invented the 'defactoring' programming style
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
I'm really not sure which is the worst bit - the fact they're using tables or the really dodgy right margin versions. Where's the IE hack version?
sdix wrote: I inherited a website project from another agency who got sacked for being very slow
They weren't slow. They produced 600MB of CSS file.
|
|
|
|
|
Hi all,
I was 3 days trying to find out why my vc++ project didn't compile. I always got an error while compiling resources. I also thought it could be a visual studio bug, so I installed the new version, but the problem was still there. When I was about to surrender I had the resources.h file opened, and I watch to the screen a few seconds and saw this:
...
#define HWND_MAINWINDOW 15000
#define HWND_NAMEEDIT HWND_MAINWINDOW + 1
#define HOTKEYF8 HWND_MAINWINDOW + 2
#define HOTKEYF9 HWND_MAINWINDOW + 3
...
It deserves a very big
But Visual Studio wasn't too helpful either, the error only appeared when compiling resources.
Enjoy.
rotter
|
|
|
|
|
Sorry, but I don't get it, why wouldn't it compile?
|
|
|
|
|
I didn't know it could generate any problem either but it seems that the compiler gets streaky with this kind of definitions. I made this change and the project compiles perfectly:
...
#define HWND_MAINWINDOW 15000
#define HWND_NAMEEDIT 15001
#define HOTKEYF8 15002
#define HOTKEYF9 15003
...
A solution using "static const" definitions instead of "#define" would also worked.
rotter
|
|
|
|
|
rotter512 wrote: A solution using "static const" definitions instead of "#define" would also worked.
Yes, but they waste precious bytes. (Well, I suppose that still matters in a few cases.)
|
|
|
|
|
That isnt true. AFAIK clever compiler are knowing this case.
Greetings from Germany
|
|
|
|
|
Using a #define constant like
#define foo 1234
#define bar foo+1 will often work, but may cause problems if foo is used in another expression. For example, "bar*2" will yield 1236 [i.e. 1234+(1*2)] rather than 2470 [i.e. (1234+1)*2]. Rather than using numeric literals for everything, though, it's usually best to write
#define bar (foo+1) to ensure correct evaluation.
I should mention another issue: when coding multi-statement macros that look like void function calls, they should be written as:
#define pseudofunction() do {whatever; you; like;} while(0)
There is no semicolon after the (0). Writing multiple statements in a macro without the enclosing while() will cause it to break if the macro is used as a single statement in an if() statement. The 'while' statement avoids this; the semicolon following the macro invocation will terminate the 'if' clause.
Incidentally, another formulation with similar effect is
#define pseudofunction() if (1) {whatever; you; like;} else
I think that will work everywhere the former one does, but if the semicolon is omitted after the macro invocation it will generate bogus code (the 'while(0)' version will generate a compile error in that case).
|
|
|
|
|
It's important to remember that #define is a text replacement mechanism and that the HWND_MAINWINDOW + 3 get resolved where HOTKEYF9 is used in the code. This can lead to compile or logic errors. Another common mistake is this:
x = HOTKEYF9 * 2 will be expanded to x = HWND_MAINWINDOW + 3 * 2. x would be 1500 * 6 and not 1503 * 2 as you would expect.
Solution:
#define HWND_MAINWINDOW 15000
#define HWND_NAMEEDIT (HWND_MAINWINDOW + 1)
#define HOTKEYF8 (HWND_MAINWINDOW + 2)
#define HOTKEYF9 (HWND_MAINWINDOW + 3)
|
|
|
|
|