|
Because VB isn't such smart on number representations
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: Unfortunately I have no VB6 at hand
Unfortunately
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
In fact I like a lot of weird things...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: Unfortunately I have no VB6 at hand.
You're lucky!
|
|
|
|
|
|
This kind of thing is standard shortcut syntax in COBOL (or was when I last used COBOL many years ago):
IF X = 1 OR 2 THEN...
is the same as
IF X = 1 OR X = 2 THEN...
The big gotcha comes when you add a NOT into the mix. All new COBOL programmers would at some point write a statement like:
IF X NOT = 1 OR 2 THEN..
which unfortunately expands to
IF X NOT = 1 OR X NOT = 2 THEN..
so the condition is always satisfied.
Some of those beginners learn from the experience and don't make the mistake again. Others, however....
|
|
|
|
|
Member 2560472 wrote: Some of those beginners learn from the experience
...and quicky abandon COBOL .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
SalarSoft wrote: VB.NET
That is why it is Very Bad.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
some if else my colleagues are using..can't say much but just went blank..
If strHeader.Substring(0, 1) = ">" Then<br />
ElseIf strHeader.Substring(0, 1) = "<" Then<br />
Else<br />
strColumn = -1<br />
strOrder = Nothing<br />
strHeader = Nothing<br />
End If
|
|
|
|
|
That makes me happy. It's so nice to see code where there is such an in depth understanding of efficiency, eligance and maintainability.
Give your colleagues a *special* reward.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Don't forget expressiveness.
|
|
|
|
|
Look on the bright side... at least if the specs change in the future and you actually DO need to do something when those conditions are true, the structure is already in place...
|
|
|
|
|
Scott Barbour wrote: Look on the bright side... at least if the specs change in the future and you actually DO need to do something when those conditions are true, the structure is already in place...
Sounds like somebody might have been thinking ahead...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
I have never really posted on code project, but this just made me angry that someone would put this into a production code base! I tried to drop the entire sample into here, but I think there is a limit so I snipped out repetitive parts (which is pretty much all of it). Anyways, the guy also indented the thing so it was like 200 characters wide at the last nested if!
If intColumnnum = 1 Then
crDField(pcounter).Width = 2475
crDField(pcounter).Left = 240
intColumnwidth3 = 2475 + 240
intColumnwidth3 = intColumnwidth3 + 60
Else
If intColumnnum = 2 Then
crDField(pcounter).Width = 990
crDField(pcounter).Left = intColumnwidth3
intColumnwidth3 = intColumnwidth3 + 990 + 60
Else
*SNIP*
If intColumnnum = 38 Then
crDField(pcounter).Width = 2400
crDField(pcounter).Left = intColumnwidth3
intColumnwidth3 = intColumnwidth3 + 2400 + 60
End If
*37 more End Ifs*
|
|
|
|
|
Why does the choice of language here not surprise me..
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
I think I have said before, its not the language that's at fault, its the ability of the developer in question that wrote these lines of code! You could do exactly the same thing in any programming language..
However unfortunately the fact is that most developers of a questionable ability develop in that language!
|
|
|
|
|
I agree it is not the language.
I think that Visual Basic was a marketing trap: the appealing smoothness of its learning step made it be considered the language for all, hence many, many people became at once programmers, very poor programmers, in fact.
I know (few) skilled guys using VB6 and also a bunch of pretty weird C++ coders.
Another reason maybe that, usually, skilled people like to challenge themselves with more complex (and powerful) languages, leaving VB to less skilled ones.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I know C# and VB, I have tended to code in the past using VB, but I do use the language properly and make use of all the features available. I do agree VB Was marketted as the language for all, unfortunately it has caused a minority (slowly becoming a majority) to market themselves as professional programmers when they are nothing more than hobbyists, and this reflects in the quality of code produced.
I always ensure Option Strict is turned on when programming but again if VB was a proper language it should never allow you to turn it off! I have seen too many coding horrors where it has been turned off due to programmer laziness.
VB used to offer many advantages (disadvantage?) in being able to create applications quickly but this is being eroded by the likes of C# and other contempary languages. I am planning to move more of my development over to C# over the coming months and migrate legacy systems as and when required, mainly as I want my internal team to code properly!
|
|
|
|
|
( pretty much sums it up for me )
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
It depends what the life of the code is indended. If it was a short term piece of interim code then perhaps it might be justifiable (perhaps even on performance grounds)
|
|
|
|
|
I found this expression in our current source code:
int i;
(int)pow(2,i) This was in code written by a senior developer .
I replaced it with the following expression:
(1 << i)
Software Zen: delete this;
|
|
|
|
|
I'd have to see more of the code to decide if this really deserves to be a horror. It's possible that, as an optimization, "fixing" this has zero impact on real world performance while (slightly) obfuscating the code.
I'm a much bigger fan of readable code than optimizations with negligible performance improvements. (Not that "2 << i" is that unreadable, but you get the idea.)
Faith is a fine invention
For gentlemen who see;
But microscopes are prudent
In an emergency!
-Emily Dickinson
|
|
|
|
|
Shift left is way cooler than pow any day. And in the end it's all about how good the code looks, eh?
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
words to live code by!
|
|
|
|
|
Words of wisdom, I can often spend hours getting my comments and keywords in the right places to make the code look good and colourful
Paul
|
|
|
|