Click here to Skip to main content
15,885,216 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Evolution of a stored proc Pin
Stefan_Lang16-Jul-12 21:55
Stefan_Lang16-Jul-12 21:55 
GeneralRe: Evolution of a stored proc Pin
yiangos16-Jul-12 22:43
professionalyiangos16-Jul-12 22:43 
GeneralRe: Evolution of a stored proc Pin
Jan Holst Jensen217-Jul-12 1:01
Jan Holst Jensen217-Jul-12 1:01 
GeneralRe: Evolution of a stored proc Pin
yiangos17-Jul-12 9:16
professionalyiangos17-Jul-12 9:16 
GeneralRe: Evolution of a stored proc Pin
Florin Jurcovici17-Jul-12 1:31
Florin Jurcovici17-Jul-12 1:31 
GeneralRe: Evolution of a stored proc Pin
Harley L. Pebley17-Jul-12 4:47
Harley L. Pebley17-Jul-12 4:47 
GeneralRe: Evolution of a stored proc Pin
krumia17-Jul-12 20:20
krumia17-Jul-12 20:20 
GeneralWhen to check for null ? Pin
Sasha Laurel10-Jul-12 6:19
Sasha Laurel10-Jul-12 6:19 
Another project from our "star" developer who is apparently beyond contempt in every way.

I was given this website (an ASP.Net Webforms project written in VB10) to add some additional metrics. To my horror I found that even though written very recently (within the last 2-3 years) and then updated to use a new Linq-to-Entities data source, there was no regard for architecture, and all of the data access code was written directly in the code behind of the aspx pages.

That's not even the real horror. I was getting (seemingly) random errors while trying to run it/understand it, and found that through-out all of the loads of Linq statements that all of the nullable types (e.g. Integer?, Double?, DateTime?, etc.) were being treated as if they were not nullable at all!

Here is an example to help you understand (table/field names changed slightly to protect the guilty):
VB
Dim partTransactionTypeThingsQuery As IQueryable(Of SomeTransactionRelatedItem) = _
            From t In baseQuery
            Join tji In dataContext.OtherTransactionItems _
                On tji.SomeTransactionID Equals t.ID
            Where (t.LastUpdatedDate >= startDate _
                   And t.LastUpdatedDate < endDate) _
                And (tji.Type = "Part") _
                And (tji.TotalDue <> 0)
            Select tji


LastUpdatedDate is a Nullable(Of Date) and TotalDue is a Nullable(Of Double) and when it translates to SQL it will work just fine.. The problems come about when the context switches from Linq-To-Entities to Linq-To-Objects (I have to watch closely for a .ToArray() or .ToList() or anything else that executes the SQL and fetches results) and much of the aggregation is doing exactly that.

I don't even know how many of these problems there are... Anyways, thanks for letting me rant a bit. Any suggestions? Is suicide a viable alternative to fixing thousands of lines of VB Linq statements of this nature?
GeneralRe: When to check for null ? PinPopular
Brisingr Aerowing10-Jul-12 13:55
professionalBrisingr Aerowing10-Jul-12 13:55 
GeneralRe: When to check for null ? Pin
Sasha Laurel10-Jul-12 18:59
Sasha Laurel10-Jul-12 18:59 
GeneralRe: When to check for null ? Pin
Brisingr Aerowing11-Jul-12 4:37
professionalBrisingr Aerowing11-Jul-12 4:37 
GeneralRe: When to check for null ? Pin
CDP180210-Jul-12 22:25
CDP180210-Jul-12 22:25 
GeneralRe: When to check for null ? Pin
Julien Villers10-Jul-12 23:24
professionalJulien Villers10-Jul-12 23:24 
GeneralRe: When to check for null ? Pin
CDP180211-Jul-12 0:26
CDP180211-Jul-12 0:26 
GeneralRe: When to check for null ? Pin
Julien Villers11-Jul-12 0:47
professionalJulien Villers11-Jul-12 0:47 
GeneralRe: When to check for null ? Pin
Sasha Laurel11-Jul-12 4:52
Sasha Laurel11-Jul-12 4:52 
GeneralRe: When to check for null ? Pin
CDP180212-Jul-12 1:28
CDP180212-Jul-12 1:28 
GeneralRe: When to check for null ? PinPopular
Sasha Laurel12-Jul-12 4:55
Sasha Laurel12-Jul-12 4:55 
GeneralRe: When to check for null ? PinPopular
CDP180212-Jul-12 14:26
CDP180212-Jul-12 14:26 
JokeRe: When to check for null ? Pin
Sasha Laurel12-Jul-12 16:10
Sasha Laurel12-Jul-12 16:10 
GeneralRe: When to check for null ? Pin
CDP180212-Jul-12 23:18
CDP180212-Jul-12 23:18 
GeneralRe: When to check for null ? PinPopular
Andrei Straut11-Jul-12 5:04
Andrei Straut11-Jul-12 5:04 
GeneralRe: When to check for null ? Pin
CDP180211-Jul-12 5:11
CDP180211-Jul-12 5:11 
GeneralRe: When to check for null ? Pin
Jasmine250111-Jul-12 5:06
Jasmine250111-Jul-12 5:06 
GeneralRe: When to check for null ? Pin
Sasha Laurel11-Jul-12 5:08
Sasha Laurel11-Jul-12 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.