Click here to Skip to main content
15,889,462 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: try-catch code convention Pin
Hired Mind22-Jul-10 7:19
Hired Mind22-Jul-10 7:19 
GeneralMy turn on MS Bashing PinPopular
peterchen1-Jul-10 0:59
peterchen1-Jul-10 0:59 
GeneralA whole day wasted on one stored procedure Pin
ChrisC(@ncmail)28-Jun-10 12:29
ChrisC(@ncmail)28-Jun-10 12:29 
GeneralRe: A whole day wasted on one stored procedure Pin
J4amieC28-Jun-10 21:59
J4amieC28-Jun-10 21:59 
GeneralRe: A whole day wasted on one stored procedure Pin
David Skelly28-Jun-10 22:36
David Skelly28-Jun-10 22:36 
GeneralRe: A whole day wasted on one stored procedure Pin
ChrisC(@ncmail)29-Jun-10 8:16
ChrisC(@ncmail)29-Jun-10 8:16 
GeneralRe: A whole day wasted on one stored procedure Pin
PIEBALDconsult9-Jul-10 10:47
mvePIEBALDconsult9-Jul-10 10:47 
GeneralStupid Naming Consequences with LINQ Pin
Member 269131324-Jun-10 22:45
Member 269131324-Jun-10 22:45 
Here's another good reason not to use reserved names.

I'm working on a LINQ project with a series of tables that manage user roles. As a result, I have table names like Systems, Roles and Users.
My trouble started when I would add the objects to the Designer, hit Save and then suddenly Visual Studio would say things like

System.Data.Linq.Mapping.DatabaseAttribute is not defined

or

System.Nullable is not defined


In short, stopping me dead in my tracks. Now that I look back, I don't know why I didn't see the reason earlier.

When using the Object Relational Designer, Visual Studio wants to be smart and changes any words that are plural to singular so they make more sense when dealing with data.


That way, your code looks like
<br />
oUser = New User<br />
oUser.UserName = "John"<br />

instead of
<br />
oUser = New Users<br />


This is really nice because it does make the code a little more legible except in this situation:

Plural (singular)
Users (User)
Roles (Role)
UserRoles (UserRole)
Systems (System)


See the gotcha? Visual Studio translated the "Systems" table into a "System" object which immediately negated all of the main namespaces in the project.

The renaming feature for the objects in LINQ-to-SQL is great - but be warned, when you start getting errors like this, take a look at your source tables.
GeneralRe: Stupid Naming Consequences with LINQ Pin
whatrevolution25-Jun-10 2:49
whatrevolution25-Jun-10 2:49 
GeneralRe: Stupid Naming Consequences with LINQ Pin
User 274316225-Jun-10 23:59
User 274316225-Jun-10 23:59 
GeneralMessage Closed Pin
28-Jun-10 8:59
_beauw_28-Jun-10 8:59 
GeneralRe: Stupid Naming Consequences with LINQ Pin
David Skelly28-Jun-10 22:38
David Skelly28-Jun-10 22:38 
GeneralRe: Stupid Naming Consequences with LINQ Pin
whatrevolution3-Jul-10 17:28
whatrevolution3-Jul-10 17:28 
GeneralRe: Stupid Naming Consequences with LINQ Pin
Hired Mind13-Jul-10 10:00
Hired Mind13-Jul-10 10:00 
GeneralRe: Stupid Naming Consequences with LINQ Pin
Marcelo Ricardo de Oliveira8-Jul-10 6:50
Marcelo Ricardo de Oliveira8-Jul-10 6:50 
GeneralJavaScript Conditional Pin
Andres Martin23-Jun-10 12:05
Andres Martin23-Jun-10 12:05 
GeneralRe: JavaScript Conditional Pin
Luc Pattyn23-Jun-10 12:17
sitebuilderLuc Pattyn23-Jun-10 12:17 
GeneralRe: JavaScript Conditional Pin
oggenok6423-Jun-10 20:48
oggenok6423-Jun-10 20:48 
GeneralRe: JavaScript Conditional Pin
Kevin Drzycimski24-Jun-10 0:14
Kevin Drzycimski24-Jun-10 0:14 
GeneralRe: JavaScript Conditional Pin
Viorel.24-Jun-10 3:52
Viorel.24-Jun-10 3:52 
GeneralRe: JavaScript Conditional Pin
Electron Shepherd27-Jun-10 22:43
Electron Shepherd27-Jun-10 22:43 
GeneralRe: JavaScript Conditional Pin
Jeroen De Dauw24-Jun-10 3:54
Jeroen De Dauw24-Jun-10 3:54 
GeneralRe: JavaScript Conditional Pin
Tsuda Kageyu24-Jun-10 17:38
Tsuda Kageyu24-Jun-10 17:38 
GeneralRe: JavaScript Conditional Pin
whatrevolution25-Jun-10 2:54
whatrevolution25-Jun-10 2:54 
GeneralRe: JavaScript Conditional Pin
Lutosław27-Jun-10 1:12
Lutosław27-Jun-10 1:12 

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.