|
I love how one branch of Microsoft evangelists preach accessors for every single class property (which I actually like), and the other one, preaches the most inflexible total hard binding of everything to the database schema
With the big advantage of automatically generating the joins
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I was exposed to a similar situation but it didn't involve an auto generated tool so much as a terrible programmer. We had a stored procedure that used 13 parameters to be used as filters for a set of data that we would return to the users. After getting a complaint that the filter was acting strange I was told to review the procedure to find the bug. When I opened the procedure I noticed that an if then else chain of about 3000 combinations of variations of the select statement had been hand written to account for every scenario that could exist. The only problem was that we figured that this was only a small fraction of the coverage of code needed to work correctly we also noticed when coping the procedure it was more the 5 megs in length. We were able to shorten the script to about 12 lines of code when we finished it.
nothing
|
|
|
|
|
I've seen some long stored procedures in my day. Perhaps 100 or 200K. But nothing like what you describe. Though, there was one grouped stored procedure that was composed of a hundred or so individual stored procedures (e.g., procedure;1, procedure;2, procedure;100, procedure;101, and so on). Still, that was due to decades of hopelessly complicated business logic and workarounds, not one very simple but bloated function, like the one you described.
Driven to the ARMs by x86.
|
|
|
|
|
icestatue wrote: We were able to shorten the script to about 12 lines of code when we finished it.
How long these lines were?
Greetings - Jacek
|
|
|
|
|
SET @value = SUBSTRING(@sText, 1, CHARINDEX(@sDelim, @sText) -1)
BEGIN
INSERT @retArray (idx, value)
VALUES (@idx, @value)
END
...but why have a BEGIN in the first place?
Driven to the ARMs by x86.
|
|
|
|
|
Probably, the guy copied part of a code that belonged to an IF statement and forgot to remove the BEGIN.. END , he must have thought 'why disturb the code if it compiles well?'
|
|
|
|
|
Our contractor just discovered a piece of code in a new project written in C# this year (2011) that doesn't use the date validator.
And... why would you use three text boxes to collect a date (one each for day/month/year) and then use Javascript to validate it?
Oh, and the home grown validation code will accept 14 as a month
function checkMonth(oMonth) {
if (parseInt(oMonth.value) != NaN) {
if (parseInt(oMonth.value) > 12) {
oMonth.value = parseInt(oMonth.value) - 12;
}
}
else {
oMonth.value = "";
}
}
and 62 as a valid day
function checkDay(oDay) {
if (parseInt(oDay.value) != NaN) {
if (parseInt(oDay.value) > 31) {
oDay.value = parseInt(oDay.value) - 31;
}
}
else {
oDay.value = "";
}
}
Obviously, this person needed a vacation
P.S.
It is just a standard LOB application that doesn't need to accept weird dates.
|
|
|
|
|
Not knowing that a date validator is available is one thing, but writing such a poor validator is really a coding horror!
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Yeah I could easily have written the 'primary WTF' (not using the date validator ... I'd probably have used DateTime.TryParse or something), but writing client side validation and then doing it wrong are definitely worthy of this forum.
|
|
|
|
|
Our coding standards say "Use Visual Studio validator controls whenever possible to ease maintenance."
|
|
|
|
|
looks fine to me!
written on 58-15-6831
regards Torsten
I never finish anyth...
|
|
|
|
|
What if the month is 25. (25-12=13)
|
|
|
|
|
fine to me - I can handle a 13. pay check
regards Torsten
I never finish anyth...
|
|
|
|
|
|
We had this very issue the other day on my team. And several other issues on my previous project related to data binding. Yes, the DGV seems to have been written by an idiot.
|
|
|
|
|
This is what I got from my director/president of IT department of our company, I'm not sure if he wrote it or not.
It's a formula in an excel cell:
=(1-(K11-L11)/K11)*100
i mean seriously, wtf?
I've also seen a code/formula than spans a whole line includes several variables which equals to 1 no matter the variables, i pointed it out to the "developer" he laughed his ass off and got embarrassed that was kind of funny.
|
|
|
|
|
What is it supposed to do?
My guess is it solves "L11 = x% of K11" for x.
I fail to see what's wrong with it to be honest.
Giraffes are not real.
|
|
|
|
|
well yea, basically. It works, it just should have been.
=L11/K11*100
|
|
|
|
|
Maybe not; if K11 is the price you get, and L11 is the cost, then it will give you the revenue in percent
|
|
|
|
|
A little maths :
(1 - (K11 - L11)/K11) * 100
= (1 - (K11 / K11) + (L11 / K11)) * 100
= (1 - 1 + (L11 / K11)) * 100
= (L11 / K11) * 100
|
|
|
|
|
Yeah... I think I'm going to bed early tonight.
Giraffes are not real.
|
|
|
|
|
No - it's (K11 - L11) !!!
And also you should check operator precedence !
You should take another base course in math
|
|
|
|
|
Just prove what you say and I'll look for a maths course...
|
|
|
|
|
>(1 - (K11 - L11)/K11) * 100
> = (1 - (K11 / K11) + (L11 / K11)) * 100
Where did the + came from ?
(K11 - L11)/K11 is the same as (K11 / K11 ) - (L11 / K11)
Besides, the parentheses signifies that it should be evaluated first.
the formula is evaluated to;
K11 - L11 then divided by K11, subtract the answer from 1 then multiplied by 100 to represent as a percentage.
This is a valid income formula.
if L11 = 100, K11 = 200, this will result into a 50% answer.
|
|
|
|
|
Two minuses make a plus. So yes, as you got, (k-l)/k is k/k-l/k. But the expression is 1-(k-l)/k = 1-(k/k-l/k) = 1-k/k+l/k. The post you were replying to brings the fraction inside and resolves the brackets in one step. (As described earlier, it then further simplifies 1-1+l/k = l/k.)
|
|
|
|