|
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)
|
|
|
|
|
|
KarstenK wrote: But using a name like HWND_MAINWINDOW is also
Yeah, it looks like someone is defining window's handles. Which I don't get.
|
|
|
|
|
Just compiled a project from our Outsourcing Contrators... Now this apparently works according to them and they feel its ready to be deployed.. Got 10 Fatal Errors and 200 Warnings
Its not that thats got me though, the code snippet below kinda flies in the face of logic and good practice.. Couple of questions here then... Firstly Why is it a function? And secondly why doesnt it return a value.. Bear in mind this code snippet is run on every page on page_load and has been copied and pasted across the site.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)<br />
Validsession()<br />
End Sub<br />
<br />
Public Function validSEssion()<br />
<br />
if session("username")="" then response.redirect("\Logout.aspx")<br />
<br />
End Function
On going through the code a bit more I noticed that 90% of it is Function's that dont return any values.. There are no Subs!!
|
|
|
|
|
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
PeterTheGreat wrote: There are no Subs!!
They got something right then :-P
Russ
|
|
|
|
|
Unfortunately this is a misfeature of VB.NET that's inherited from VB6. If you declare a Function , but omit the type of the return value, it is implicitly Object (Variant in VB6).
The other misfeature is that in Classic VB, the return value of the function was set by assigning to the name of the function - there was no Return statement. The last value set was the return value, but it didn't return straight away when set. This was very confusing. You could easily forget to set it (in which case it would be defaulted, I think, to the default value for the type, in this case Nothing ).
Option Strict fixes many problems in VB code (or, rather, turns them into compile-time errors, forcing you to fix them), and thankfully failing to define the return value of a function is one of them, at least as of VB 7.1 (.NET 2003). You will have to fix all the type-coercion errors if you turn it on, though, using explicit casts. I try to use DirectCast where possible (where I know that the object is already of the type I'm asking it to convert to).
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
That's some pretty bad naming for the functions. According to the naming conventions of .NET, I believe it should be ValidateSession() or at least something with a verb. ValidSession is something I'd use for a boolean value.
ROFLOLMFAO
|
|
|
|