|
Timely post - I made this point in my codeproject article which highlighted that web developers have resorted to passing complex business data as strings because there is no industrial strength mechanism to do what more mature development platforms have. Data is really key to making line of business (LoB) web applications, but unfortunately the industry currently has the tail wagging the dog: we are trying to retro-fit robust business data services onto a scripted/markup platform. The two don't mix. We are forced to compromise, and this ain't good as we will find out with an enormous number of broken legacy web apps in the near future. The current methods of building cross-platform LoB web applications is simply not good enough.
|
|
|
|
|
Sounds like a consulting opportunity to me!
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
For business needs strings are fine.
I've programmed in Pick for over 20 years.
Its only data type the multivalued variable length array is just a delimited string.
So I don't have a problem at all with Web provided data being text.
|
|
|
|
|
Names changed to protect the innocent...
I'm working with some VB.net projects and I decided to turn on Option Strict. It threw an error for this line:
If someProp Is Nothing OrElse String.IsNullOrEmpty(someProp.Value OrElse someProp.Value = "0") Then
This is what was intended:
If someProp Is Nothing OrElse String.IsNullOrEmpty(someProp.Value) OrElse someProp.Value = "0" Then
for option explicit! for the fact that I have several projects to go and I'm working in the order of best code to worst code.
|
|
|
|
|
That's good entertainment. You just have to laugh.
|
|
|
|
|
eh, this is a garden-variety typo bug. I wouldn't count it as a horror as it doesn't look intentional. Even so, I can feel a sympathetic headache building...thanks
|
|
|
|
|
Yeah, the real horror is that VB.net allows that at all.
|
|
|
|
|
Allowing OrElse inside of an IsNullOrEmpty is a bad thing? On the contrary, that could be very useful.
|
|
|
|
|
The bad part is that the OrElse is between a string and a boolean, which is returning a boolean, which then gets passed as a parameter to String.IsNullOrEmpty.
|
|
|
|
|
True object-oriented programming allows it because they are all objects. It doesn't care.
|
|
|
|
|
Using a string as a boolean has nothing to do with object-oriented programming. If the code were directly comparing the boolean and the string, that might be considered something near valid (what with operator overloading), but that was not the case here. This code is basically like doing this:
If "Dragons" Then
Else
End If
It doesn't make any sense.
|
|
|
|
|
You are right, the code did not make any sense. That you are right about.
|
|
|
|
|
Someone doesn't use PHP.
Don't forget to rate my post if it helped!
"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
|
|
|
|
|
That's because somebody read a PHP book, puked in his mouth, and is still trying to wash away the filth.
|
|
|
|
|
God I really...REALLY hope that you're just trolling.
|
|
|
|
|
AspDotNetDev wrote: The bad part is that the OrElse is between a string and a boolean, which is
returning a boolean, which then gets passed as a parameter to
String.IsNullOrEmpty.
Uh, that's WHY there is an Option Strict: to allow relaxed type checking on certain operations. Though here it is certainly annoying, and one of the reasons I tend to use Option Strict pretty consistently.
|
|
|
|
|
I have never programmed in VB without Option Strict and Option Explicit turned on. That is the only way that VB doesn't turn into an absolute nightmare.
|
|
|
|
|
I agree. (VB is a nightmare anyways, but point well taken)
|
|
|
|
|
Slight disagreement. The real horror is that the developer has to specify, "Yes, please use short-circuit boolean logic" by using OrElse instead of that being the default behavior.
|
|
|
|
|
You mean like it is in every other language? The way it should be?
|
|
|
|
|
And the IIf function doesn't even have a short-circuit version! If you're used to writing code like this in C#:
int count = list == null ? 0 : list.Count;
and you try to translate to VB:
dim count as integer = iif(list is nothing, 0, list.Count)
you will wind up with a NullReferenceException when list is null/nothing!
|
|
|
|
|
Actually, since VB 2008, that's no longer true.
The If Operator (without the extra I)
The 3 parameter form act like the C# ternary operator ? : , while the 2 parameter form would be the C# coalesce ?? .
But yes, TRWTF is VB.
|
|
|
|
|
Wow, you learn something new every day
Funny how the documentation lists the 2-parameter form's arguments as argument2 and argument3, though...
|
|
|
|
|
Computers should be used for what they are good at: systematic consistency checks. Because this is where they can help preventing bugs early. Static analysis.
If I were God, I would make the Strict mode compulsory. And enhance the programming languages to help computers help us. For instance by introducing dimensional analysis on the data.
Dim Meters as Unit
Dim Side As Integer in Meters, Area As Integer in Meters^2, Count(0 To 5) As Integer
Area = 3 * Side
Count(Side) = Count(Side) + 1
|
|
|
|
|