Click here to Skip to main content
15,920,704 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: How to Use Member Variables Pin
Anna-Jayne Metcalfe22-Jul-10 7:54
Anna-Jayne Metcalfe22-Jul-10 7:54 
GeneralRe: How to Use Member Variables Pin
Gary Wheeler22-Jul-10 8:08
Gary Wheeler22-Jul-10 8:08 
GeneralRe: How to Use Member Variables Pin
Anna-Jayne Metcalfe22-Jul-10 8:56
Anna-Jayne Metcalfe22-Jul-10 8:56 
GeneralRe: How to Use Member Variables Pin
Gary Wheeler22-Jul-10 9:02
Gary Wheeler22-Jul-10 9:02 
GeneralRe: How to Use Member Variables Pin
Anna-Jayne Metcalfe22-Jul-10 11:20
Anna-Jayne Metcalfe22-Jul-10 11:20 
GeneralRe: How to Use Member Variables Pin
Member 422705822-Jul-10 14:28
Member 422705822-Jul-10 14:28 
GeneralRe: How to Use Member Variables Pin
Nagy Vilmos24-Jul-10 21:52
professionalNagy Vilmos24-Jul-10 21:52 
GeneralRe: How to Use Member Variables Pin
Anna-Jayne Metcalfe24-Jul-10 21:55
Anna-Jayne Metcalfe24-Jul-10 21:55 
GeneralRe: How to Use Member Variables Pin
Rob Grainger20-Jul-10 1:21
Rob Grainger20-Jul-10 1:21 
GeneralRe: How to Use Member Variables Pin
RugbyLeague20-Jul-10 4:09
RugbyLeague20-Jul-10 4:09 
GeneralRe: How to Use Member Variables Pin
leppie20-Jul-10 20:23
leppie20-Jul-10 20:23 
GeneralRe: How to Use Member Variables Pin
S. Senthil Kumar25-Jul-10 9:15
S. Senthil Kumar25-Jul-10 9:15 
GeneralString.Format??? PinPopular
Not Active8-Jul-10 13:04
mentorNot Active8-Jul-10 13:04 
GeneralRe: String.Format??? Pin
User 27431628-Jul-10 20:50
User 27431628-Jul-10 20:50 
GeneralRe: String.Format??? Pin
oggenok649-Jul-10 0:33
oggenok649-Jul-10 0:33 
GeneralRe: String.Format??? Pin
User 27431629-Jul-10 0:44
User 27431629-Jul-10 0:44 
GeneralRe: String.Format??? Pin
oggenok649-Jul-10 1:06
oggenok649-Jul-10 1:06 
GeneralRe: String.Format??? Pin
User 27431629-Jul-10 1:17
User 27431629-Jul-10 1:17 
GeneralRe: String.Format??? [modified] Pin
PIEBALDconsult9-Jul-10 5:15
mvePIEBALDconsult9-Jul-10 5:15 
GeneralRe: String.Format??? Pin
T M Gray9-Jul-10 9:38
T M Gray9-Jul-10 9:38 
GeneralRe: String.Format??? Pin
User 27431629-Jul-10 13:14
User 27431629-Jul-10 13:14 
GeneralRe: String.Format??? Pin
hairy_hats13-Jul-10 0:35
hairy_hats13-Jul-10 0:35 
GeneralRe: String.Format??? Pin
PIEBALDconsult9-Jul-10 9:39
mvePIEBALDconsult9-Jul-10 9:39 
GeneralRe: String.Format??? Pin
_Maxxx_15-Jul-10 18:33
professional_Maxxx_15-Jul-10 18:33 
So you're working in a large financial institution where they won't let you create a stored procedure but give you direct update access to tables !!!!!!!!

Tell me which one so I can change my accounts Smile | :)

seriously - the most sensible advantage of SPs over inline code is security - you can give the application(s) access ONLY to stored procedures (and only to certain stored procs if you want) and then easily manage the changing of those stored procedures to avoid someone accidentally or deliberately stuffing something up.

In any decently secured DB the application should never have direct access to the tables (certainly not to update the tables) - as this doesn't prevent the simplest mistake

Update AccountBalance Set Balance = 0;

for example - oops, forgot the 'where'

Making all updates tothe DB go via a stored procedure allows you not only to monitor changes to the processes, but also so make modifications without changing the application and redeploying, and allows you to add (for example) logging easily.

Granted your example was for implementing a reporting system - in that case you may have read-only access to tables and I guess it's a matter of taste as much as anything as to whether you code sql inline or not.

that said, you can unit test an SP, you can check it works independently, you can add logging if it is doing something strange, all without having to redeploy the damn application - so it can be very useful indeed to use them all the time.

Oh, and a nicely formatted SP is much easier to read than inline code - especially where that code is build up out of many strings, so the only way to work out what it actually dies is to run in debug and look at the runtime value...

Hmm - I sound like a SP evangelist, don't I?
___________________________________________
.\\axxx
(That's an 'M')

GeneralRe: String.Format??? Pin
PIEBALDconsult16-Jul-10 5:49
mvePIEBALDconsult16-Jul-10 5:49 

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.