|
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
|
|
|
|
|
Hi Peter,
PeterTheGreat wrote: Outsourcing Contrators
I'm curious. Where did you get your contractors or the firm with which you are contracting?
Jeff
|
|
|
|
|
PeterTheGreat wrote: compiled a project from our Outsourcing Contrators...
That kind of tells something. I'll just keep my Soapbox thoughts about outsourced contractors to myself
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
happened to me today: (in C++)
if (condA ||
condB ||
condC ||
condD,
condE)
{
...
}
Of course I wanted to "or" all conditions, but at some point I must have figured to be in a list or something. For anyone not familiar with the comma operator, its worth looking at. I didn't make use of it except e.g. int x=3, y=5; until now (and thats a couple of years).
-- modified at 11:52 Monday 26th November, 2007
|
|
|
|
|
So what's the result? In C# it just says that the comma is invalid there.
|
|
|
|
|
"Consider the expression
e1 , e2
The type and value of the expression are the type and value of e2; the result of evaluating e1 is discarded."
From MSDN[^]
Information at you fingertip.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Steve Hansen wrote: In C# it just says that the comma is invalid there.
yah
|
|
|
|
|
Unless there are side effects of the other conditions, your example is the equaivant of this:
if (condE)
{
...
}
|
|
|
|
|
Right. One can probably do awful things using commas given the right modulation of commas and semicolons - even outside variable declarations and for-statements.
|
|
|
|
|
Doc Lobster wrote: One can probably do awful things using commas
... such as implementing an assignment library[^]
|
|
|
|
|