|
Public Const OH_OK As Boolean = True
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
Yeah, those comments just take up a line of screen space where code could be.
Consts, well that's just a convention from the old C days, to clearly differentiate #defined values from normal variables (C doesn't have const declarations if I remember right). In Java or C# where underscored names are generally not used anyway, constants could arguably be lower_case_with_underscores, which is less aggressive on the eye. In my own code (when I'm not subject to convention) I usually case them normally for publicly visible members (const int ThingumyWotsit = 42;).
|
|
|
|
|
Naerling wrote: Btw, what's the story with CONST_HAVING_UNDERSCORES_AND_CAPITOLS?
I am sure it had a good reason way back when, but I fail to see it now
Quite simply: Every time you see a VARIABLE_IN_CAPITOLS_AND_UNDERSCORES in the code, you simply KNOW that this is a constant and you can spare yourself the effort of trying to change it. Sure, the compiler might warn you about it, depending on your IDE - but for very long codes, you might have to look up the declaration of the variable to see it is a constant. So - Capitols, for CONSTANTS. The underscore is just there because you can't use CamelCase while using capitols only.
That seems to be a PEBKAC problem, Sir. Why don't you go and fetch a coffee while I handle the operation?
|
|
|
|
|
Sounds plausible, but what about READ_ONLY_PROPERTIES?
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
Hmmm... I use to write that the same way I write read/write-Properties.
But, hey, technically, from an using point of view, it is just like a constant: You can't write it. But it may be changing, depending on other properties.
That seems to be a PEBKAC problem, Sir. Why don't you go and fetch a coffee while I handle the operation?
|
|
|
|
|
witm55 wrote: I use to write that the same way I write read/write-Properties.
So do I
Just wanted to say that it is not really very different from a Const in a usage kind of way.
I think with todays tools the CAPITOLS_AND_UNDERSCORES is not necessary anymore. Visual Studio IntelliSense gives an icon saying something is a Const, it gives you text saying it is a Const, it gives the same if you hoover over it and with one "go to definition" you can see really everything you want to know about it.
But from a historic point of view it is sometimes good to know why certain things are as they are
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
not even 21.000 lines of code - but 21.000 lines of VB-code.
that's even more painful.
regards Torsten
I never finish anyth...
|
|
|
|
|
I have just found this piece of code in a "Common" class (original comments preserved)...
public static boolean openConfirmDeleteDialog() {
Display.getCurrent().beep();
Display.getCurrent().beep();
return Common.openQuestionDialog(ViewsMessages.H_CONFIRM, "Are you sure that you want to delete this record?");
}
Greetings - Jacek
|
|
|
|
|
Hey, wrong forum, you wanted to put this in Clever Code!
Or maybe a tips/tricks entry?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
Julien Villers wrote: Or maybe a tips/tricks entry?
It would rather be a TIP!!.
Greetings - Jacek
|
|
|
|
|
That's just genius!
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
This could be a good tip.... Clever code....
I quit being afraid when my first venture failed and the sky didn't fall down.
|
|
|
|
|
Recently reported a performance hit, hours later noticed this piece of code that caused it, further more the eventhandler was hooked to the event more than once!
bool canExecute = false;
ArrayList targetObjects = previousObject.TargetObjects;
for (int i = 0; i < targetObjects.Count; i++)
{
if (targetObjects[i].Equals(this))
{
canExecute = true;
}
}
if (canExecute)
{
}
At least there should be a break point when it is met!!
|
|
|
|
|
vallarasus wrote: At least there should be a break point when it is met!!
So true. I've used something similar, but also kept the last 'hit' as it was more likely to be the next one. Another version I've see is a linked list and whenever a target is hit, it's moved to the top of the list.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
That's a joke However in this case there should be no iterator!!
|
|
|
|
|
This really takes the biscuit, just wrong on so many levels...
Private Function utilCheckSecurity(recSet As DAO.Recordset, userSet As DAO.Recordset, fileNo As String) As Integer
On Error GoTo errorCUS
If fileNo = "3" Then GoTo utilCSUpdate
If IsNull(recSet![SecurityClass]) Then GoTo utilCSUpdate
If Len(recSet![SecurityClass]) = 0 Then GoTo utilCSUpdate
If recSet![SecurityClass] Like userSet![updateclass] Then GoTo utilCSUpdate
If recSet![SecurityClass] Like userSet![readclass] Then GoTo UtilCSRead
utilCheckSecurity = 0
Exit Function
UtilCSRead:
utilCheckSecurity = 1
Exit Function
utilCSUpdate:
utilCheckSecurity = 2
Exit Function
errorCUS:
If Err = 3265 Then Resume utilCSUpdate
message "Error " & Format(Err, "######") & " " & Error, "UtilCheckSecurity"
Exit Function
End Function
|
|
|
|
|
It's VB6, so it's bound to stink. But that is a real piece of spaghetti goto numpty code.
I hope it was 'a co-worker' and not you who produced it.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Not really a co-worker, he'd left by the time I joined the company - its actually VBA, but you're on the right lines.
I wonder when Microsoft will get round to beefing up VBA in Office app's to a parity with .NET, if ever.
The same dev was fond of bad names too. So a function called "CheckXXX" may actually end up updating XXX. Consequently, I have to actually look at every damn function to see what its really doing by studying the code. I'm working on a bit no-ones touched for years but a bug has surfaced - its probably got lots there, but nobody wants to touch the code on a "if its not broke don't fix it", but we get miscelleaneous data errors which lead me to suspect it is broke.
I'm strongly considering moving on.
To me, even use of VB doesn't excuse that sort of coding. That was considered bad when "Goto considered harmful" was written, and I was 1 year old then!!!
When you can fit so many no-no's into such a short function, imagine what its like when you hit one of his 1000-liners. My head hurts.
|
|
|
|
|
' We fail
Oh yeah... they certainly did...
(yes|no|maybe)*
modified 22-Sep-11 13:58pm.
|
|
|
|
|
At least that comment was making sense
|
|
|
|
|
Pfft. That's nothing I'm currently 'fixing' an email service in c# that was somewhat similar except the person who coded it was doing logical checks before data checks. They were checking a from address (in a nice if tree) to determine how it fit into the system and then checking the content of the email (the same code used multiple times).
Then to top that off there were goto statements so after certain sections of testing was completed then move on to the next 'step'. This also has no comments, documentation, etc so I'm having a fun time refactoring it.
|
|
|
|
|
I just had an opportunity to review a code of a small software organization operating out of Virginia with a couple of offices in Chennai and New Delhi.
Two major 'gems' in their code was:
1) Inventing their own App_Code folder as XYZApp_Code
2) SqlConnection objects sitting in Session directly. Also a good bunch of their code directly refers the objects and opens it without evening checking for NULL.
The app simply failed against our framework which needed SessionState in SQLServer for web farm requirements and when this was coming up to a meeting with their so-called president/CEO, the elite guy responded 'Our products are unique business workflow designers in the market. They are not like the usual Microsoft asp.net websites. We need to make ConnectionObjects that **never** close at all throughout the life-cycle of the application'
What would you respond to this type of attitude?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
kthxbye?
Sorry for 'text speak'!
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
|
|
|
|
|
Precisely. Why should we waste our time and energy on such jokers?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
You got to admit he's good at being a CEO. Who else could turn a blunder into a positive selling point.
"You get that on the big jobs."
|
|
|
|