Comment On Time for Consultants

Because consultants work on many different kinds of projects, they have the ability to produce large libraries of boilerplate code. "Hey, we did something like this before. Just a couple of tweaks and we're done!" Code reuse makes everyone happy, especially management on both sides. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Time for Consultants

2007-04-24 09:05 • by Quicksilver (unregistered)
oh wow ..

programmer not using standardlib episode number 5326

Re: Time for Consultants

2007-04-24 09:06 • by Dak (unregistered)
They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.

Re: Time for Consultants

2007-04-24 09:06 • by Rafael Larios (unregistered)


Ohh my god.... Why you punish me with this abomination??

Re: Time for Consultants

2007-04-24 09:15 • by Dave Smith (unregistered)
Just to make sure we're on the same page, that function is 700% longer than it needs to be.

Return EvaluationDate.AddMonths(-1)

Re: Time for Consultants

2007-04-24 09:18 • by snoofle (unregistered)
133287 in reply to 133286
Dave Smith:
Just to make sure we're on the same page, that function is 700% longer than it needs to be.

Return EvaluationDate.AddMonths(-1)

Not so sure - the way they did it, I think it winds up as the last date of the prior month. Of course, you did it the way it's named.

Re: Time for Consultants

2007-04-24 09:18 • by skington
133288 in reply to 133286
It also turns e.g. all dates between 2007-04-01 and 2007-04-30 into 2007-03-31 - possibly not what the caller of the function was expecting.

Re: Time for Consultants

2007-04-24 09:19 • by T$ (unregistered)
I may be pointing out the obvious, but I find it hilarious that they've written a function to subtract time and it's supposed to be saving the company time (in development) but is really adding time for the processing to complete. How ironic.

Re: Time for Consultants

2007-04-24 09:22 • by Matt (unregistered)
It was specifically coded this way to avoid handling the inevitable ThirtyDaysHathSeptemberException...

Captcha: muhahaha. I dont know why people find this entertaining, but here is the word i had to type. Enjoy!

Re: Time for Consultants

2007-04-24 09:25 • by H|B
Strings should be way more difficult to use and not as ubiquitous as they are.

.toString() is like a drug:
- you think you know how to use it harmlessly
- it leaves the impression that it makes everything easier
- soon you will be using it uncontrollably everywhere
- people who don't "do it" feel sorry for you and think you have deep problems

Re: Time for Consultants

2007-04-24 09:27 • by Someone (unregistered)
133293 in reply to 133288
skington:
It also turns e.g. all dates between 2007-04-01 and 2007-04-30 into 2007-03-31 - possibly not what the caller of the function was expecting.

I guess they wanted this alright, since they did also find and use the AddDay() method. But the string conversion is just wrong, not only is it inefficient, it can also easily break (no culture was specified, which then defaults to the current user's culture being used for formats). They maybe wanted something like
input.Date.AddDays(-input.Day)

Re: Time for Consultants

2007-04-24 09:28 • by mav (unregistered)
133294 in reply to 133291
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted - nevermore!

Re: Time for Consultants

2007-04-24 09:47 • by barf indeedy (unregistered)
hey, check it out... Maybe for some odd reason they were calling this function over and over and over, and realized the power of stringbuilder over string concatenation in the .net world... They just saved themselves a whole lot of needless GC!!

:P I know I know, not getting at the WTF in the post. And yeah, it's a pretty blatant WTF.

Hey guys, let's make a useless method more efficient!!! :D

Re: Time for Consultants

2007-04-24 09:49 • by marcello (unregistered)
133297 in reply to 133286
is 700% longer but the consultant used StringBuilder instead of String so he is a SENIOR consultant

Re: Time for Consultants

2007-04-24 09:52 • by Gsquared
133298 in reply to 133287
snoofle:
Dave Smith:
Just to make sure we're on the same page, that function is 700% longer than it needs to be.

Return EvaluationDate.AddMonths(-1)

Not so sure - the way they did it, I think it winds up as the last date of the prior month. Of course, you did it the way it's named.

Not sure how to do this in whatever language the original is in, but in T-SQL, if the desired result is the last day of the prior month (as opposed to actually a month earlier, as the name implies):

create function PriorMonth
(@Date datetime)
returns datetime
as
begin
return (select dateadd(day, -1 * datepart(day, @date), @date))
end

That avoids all the string conversions, etc. (For anyone who doesn't know, "@" is how you prefix variables in T-SQL. Having it in parens after the function name declares it as an input parameter.)

I'm reasonably sure most languages have some similar functionality to T-SQL's "dateadd" and "datepart". Might even have the same name. I've just never used any of them.

Re: Time for Consultants

2007-04-24 09:52 • by whoahman
Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))

... and get on with life.

Re: Time for Consultants

2007-04-24 09:54 • by Alex S. (unregistered)
pretty smart....

Re: Time for Consultants

2007-04-24 09:57 • by H|B
AFAIK, after Kurt Gödel (or Alan Turing?), there is no way of knowing the smallest possible program for any given task...

Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().

Re: Time for Consultants

2007-04-24 09:59 • by Steve (unregistered)
Just out of curiousity, in what language is this written?

Re: Time for Consultants

2007-04-24 09:59 • by EmmanuelD (unregistered)
133305 in reply to 133299
whoahman:
Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))

... and get on with life.

You're clearly a senior consultant too. But remember that being too good means that you'll never be featured here, and that's a terrible lack of publicity.

Re: Time for Consultants

2007-04-24 10:00 • by EmmanuelD (unregistered)
133306 in reply to 133304
Steve:
Just out of curiousity, in what language is this written?

Very Basic. I think.

Re: Time for Consultants

2007-04-24 10:00 • by anne (unregistered)
133307 in reply to 133292
H|B:
Strings should be way more difficult to use and not as ubiquitous as they are.

.toString() is like a drug:
- you think you know how to use it harmlessly
- it leaves the impression that it makes everything easier
- soon you will be using it uncontrollably everywhere
- people who don't "do it" feel sorry for you and think you have deep problems


this reminds me of something someone said at my last job: "Goto is like marijuana. It should be legal, as long as people use it responsibly."

Our manager replied, "So do you eat a bag of Doritos after you use a lot of gotos?"

Re: Time for Consultants

2007-04-24 10:02 • by RON (unregistered)
133309 in reply to 133287
snoofle:
Dave Smith:
Just to make sure we're on the same page, that function is 700% longer than it needs to be.

Return EvaluationDate.AddMonths(-1)

Not so sure - the way they did it, I think it winds up as the last date of the prior month. Of course, you did it the way it's named.


return (new DateTime( EvaluationDate.Year, EvaluationDate.Month, 1 ) ).AddDays( -1 );

Re: Time for Consultants

2007-04-24 10:15 • by Kai (unregistered)
133310 in reply to 133303
H|B:
AFAIK, after Kurt Gödel (or Alan Turing?), there is no way of knowing the smallest possible program for any given task...

Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().


Regarding the 10 chars, you must be confusing Perl with APL.

Re: Time for Consultants

2007-04-24 10:20 • by kimos
133311 in reply to 133306
EmmanuelD:
Steve:
Just out of curiousity, in what language is this written?

Very Basic. I think.


Every time see a post about something written in VB or whatever.NET I think that the language is the WTF.

Re: Time for Consultants

2007-04-24 10:22 • by H|B
133312 in reply to 133310
Kai:
H|B:
Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().


Regarding the 10 chars, you must be confusing Perl with APL.


No, those could do with 5!

Re: Time for Consultants

2007-04-24 10:22 • by RonaldRoss (unregistered)
133313 in reply to 133292
H|B:
Strings should be way more difficult to use and not as ubiquitous as they are.

.toString() is like a drug:
- you think you know how to use it harmlessly
- it leaves the impression that it makes everything easier
- soon you will be using it uncontrollably everywhere
- people who don't "do it" feel sorry for you and think you have deep problems



Wow, that's an amazing quote. Five Stars!!

Re: Time for Consultants

2007-04-24 10:28 • by PS (unregistered)
133315 in reply to 133305
EmmanuelD:
whoahman:
Return New DateTime(evaluationDate.Year, evaluationDate.Month, 1).Subtract(TimeSpan.FromDays(1))

... and get on with life.

You're clearly a senior consultant too. But remember that being too good means that you'll never be featured here, and that's a terrible lack of publicity.


This is not as bad as the original code so I think that makes him a junior consultant.

Re: Time for Consultants

2007-04-24 10:30 • by PS (unregistered)
133316 in reply to 133304
Steve:
Just out of curiousity, in what language is this written?


Unfortunately I know that it is VB.Net

Re: Time for Consultants

2007-04-24 10:34 • by packrat (unregistered)
It looks like the typical code put out by some of the vb "experts" I manage now.

Re: Time for Consultants

2007-04-24 10:39 • by akatherder
It appears to be for some sort of billing system or something similar where it doesn't matter what day it is. You only care about a month and a year when you're doing a report or something of that nature. I don't know why all the conversions, but it's not a complete disaster. It's more like a car crash than the Hindenburg.

Re: Time for Consultants

2007-04-24 10:42 • by akatherder
133319 in reply to 133317
packrat:
It looks like the typical code put out by some of the vb "experts" I manage now.


Hehe, there are some great VB programmers out there. Sounds like a bunch of losers swindled HR and you got stuck with the garbage. Look for another job or take part in the hiring process.

Re: Time for Consultants

2007-04-24 10:45 • by rgz (unregistered)
133321 in reply to 133294
mav:
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted - nevermore!



That's pretty neat! Did you made it?

I do support captcha reporting, but captchas are only funny when they funny (du'h) and when they are related to the subject or comentary.

This one was neither.

Re: Time for Consultants

2007-04-24 10:49 • by JamesKilton
133322 in reply to 133321
rgz:
mav:
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted - nevermore!



That's pretty neat! Did you made it?

I do support captcha reporting, but captchas are only funny when they funny (du'h) and when they are related to the subject or comentary.

This one was neither.


/sigh. What is happening to this country (yes, I'm assuming the person above is American)? People aren't taught who Poe is? Or at least this, his most famous poem?

Re: Time for Consultants

2007-04-24 10:52 • by rgz (unregistered)
133323 in reply to 133311
kimos:
EmmanuelD:
Steve:
Just out of curiousity, in what language is this written?

Very Basic. I think.


Every time see a post about something written in VB or whatever.NET I think that the language is the WTF.


Excuse me but there is nothing basic about Visual Basic .NET, the shit is syntax hell. Intentional torture languages (INTERCAL, Brainfuck, Shakespeare etc) not withstantanding.

Re: Time for Consultants

2007-04-24 10:57 • by jread (unregistered)
Wow, I'm glad to finally see some VB.NET code on here.

Also, why does everyone think that VB is a "lesser" language? That gets really annoying. VB.NET and C# are (functionally) the same damn language.

Re: Time for Consultants

2007-04-24 10:57 • by SomeCoder (unregistered)
133325 in reply to 133322
JamesKilton:
rgz:
mav:
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted - nevermore!



That's pretty neat! Did you made it?

I do support captcha reporting, but captchas are only funny when they funny (du'h) and when they are related to the subject or comentary.

This one was neither.


/sigh. What is happening to this country (yes, I'm assuming the person above is American)? People aren't taught who Poe is? Or at least this, his most famous poem?



I'm hoping he just missed his sarcasm tags. If not well....... I weep for the future of our society.

Re: Time for Consultants

2007-04-24 10:58 • by rgz (unregistered)
133326 in reply to 133322
JamesKilton:
/sigh. What is happening to this country (yes, I'm assuming the person above is American)? People aren't taught who Poe is? Or at least this, his most famous poem?


Fortunately, I'm not American, nor a native speaker, and have never lived in an English speaking country. And I know who wrote the raven, even if I didn't study it in high school.

That should make you, us, feel better. Oh and the RWTF is the forum software.

Re: Time for Consultants

2007-04-24 11:07 • by Zygo (unregistered)
133327 in reply to 133322
JamesKilton:
rgz:
mav:
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted - nevermore!



That's pretty neat! Did you made it?

I do support captcha reporting, but captchas are only funny when they funny (du'h) and when they are related to the subject or comentary.

This one was neither.


/sigh. What is happening to this country (yes, I'm assuming the person above is American)? People aren't taught who Poe is? Or at least this, his most famous poem?


I'll admit that I only know this because it was used in a Simpsons episode.

But at least I do know it, and who originally wrote it...

Re: Time for Consultants

2007-04-24 11:08 • by ForcedSterilizationsForAll (unregistered)
133328 in reply to 133288
Maybe they wanted the last day of the previous month. I've seen SQL functions that do the same thing.

Re: Time for Consultants

2007-04-24 11:14 • by Eduardo Habkost (unregistered)
People really love strings. When they don't know how to do some operation with the data, they just convert it to a string and perform the operation on the string representation.

Re: Time for Consultants

2007-04-24 11:16 • by Freddy Bob (unregistered)
133330 in reply to 133298
[quote user="Gsquared"][quote user="snoofle"]
I'm reasonably sure most languages have some similar functionality to T-SQL's "dateadd" and "datepart". Might even have the same name. I've just never used any of them.[/quote]
Languages, no.
Libraries, maybe.

Re: Time for Consultants

2007-04-24 11:16 • by Freddy Bob (unregistered)
133331 in reply to 133298
Gsquared:

I'm reasonably sure most languages have some similar functionality to T-SQL's "dateadd" and "datepart". Might even have the same name. I've just never used any of them.

Languages, no.
Libraries, maybe.

Re: Time for Consultants

2007-04-24 11:19 • by Joon (unregistered)
This is hilarious!

They must have run FxCop on the code, it complained about the string concatenation (using + on strings in .NET has a huge overhead), and then they "Fixed" the code so that FxCop does not complain: Brilliant

Re: Time for Consultants

2007-04-24 11:23 • by Derrick Pallas
133334 in reply to 133322
JamesKilton:
rgz:
mav:
And the raven, never flitting, still is sitting, still is sitting
On the pallid bust of Derrick Pallas just above my chamber door;
...

That's pretty neat! Did you made it?
/sigh. What is happening to this country? People aren't taught who Poe is? Or at least this, his most famous poem?


If it makes you feel better, I had "the pallid bust of Pallas" as the caption for a photo on my home page a couple of years ago.

Re: Time for Consultants

2007-04-24 11:35 • by rgz (unregistered)
133335 in reply to 133324
I apologize for the incoming spelling mistakes, because apologizing is easier than reaching a dictionary.

jread:
Wow, I'm glad to finally see some VB.NET code on here.

Also, why does everyone think that VB is a "lesser" language? That gets really annoying. VB.NET and C# are (functionally) the same damn language.


Yes but in VB you have Subrutines, Functions, and Functions that not return a value, and you can asign the return value to the function name, or not. It has class less methods which is not a wtf, but an inconsistency with c#.

And is awfully verbose, you have to write 'Dim mfoo as Foo' when 'Foo mfoo' could sufise and 'new Foo()' instead of 'Foo()' and of course that means that you would have to write 'Dim mFoo as Foo = new Foo()'! then to cover up for this insanity shortcuts are invented and you end up with more syntax like 'Dim mfoo as new Foo()' which is still too long, 'mfoo as Foo()' could be a perfect declare+initialize idiom.

It's deciving, 'Dim foo, bar, baz as String' declares to generic object variables and a String variable. The ternary operator works different across versions, operating buzyly or lazyly with unspected results. And when it works lazily it makes even less sense since it uses the syntax of function calling. Array indexing is indistiguible from function calling.

Casting is cumbersome. Initializing Arrays is cumbersome

No multiline string means you have to concatenate long messages, inserting new line objects in between since it doesn't understand about \\n.



The ide fills in this for you but you have to put 'ByVal' and 'ByRef' for each parameter in the function declaration, and yes it is the function and not the caller who decides if it works on objects or only their values.

No intelligent line wraping means you can't breakup a complicated instruction into several lines with a continuation character that must be placed correctly for it to work right.

I haven't learn how to do templating, but i bet it will be full of wtf. I have the language and I hate that I have to code it for a living.

Still looking for a Pythonist job. Might as well start a Python shop myself.

Re: Time for Consultants

2007-04-24 11:35 • by whalemangler
133336 in reply to 133283
myDate.AddDays(myDate.Day * -1)

/Consultant
/Certified
/HaveTheTShirt

Re: Time for Consultants

2007-04-24 11:45 • by Boink (unregistered)
133340 in reply to 133324
and the WTF comment is...
Wow, I'm glad to finally see some VB.NET code on here.

Also, why does everyone think that VB is a "lesser" language? That gets really annoying. VB.NET and C# are (functionally) the same damn language.


Re: Time for Consultants

2007-04-24 11:45 • by JUST ANOTHER WTF (unregistered)
133341 in reply to 133284
Dak:
They should have serialized to XML somewhere in there. Then the circle of insanity would be complete.


"Have you tried Javascript?"

Re: Time for Consultants

2007-04-24 11:46 • by Izzy (unregistered)
133342 in reply to 133286
You forget, this is generated by consultants. Their design criteria include bloat, obfustification, and excessive use of resources. You wouldn't pay them lots of money if it was 12 pages and ran on a 386.

Re: Time for Consultants

2007-04-24 11:49 • by Imroy
133343 in reply to 133303
H|B:
Speaking of small programs, where are the Perl coders? I'm sure some of them could program 10-char PriorMonths().

Maybe not 10 characters...

use Date::Calc qw(:all);
sub subtract_month ($$$) {
my ($year, $month, $day) = Add_Delta_YMD(@_, 0, -1, 0);
$day = Days_in_Month($year, $month);
return ($year, $month, $day);
}
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment