Skip to content

The Weird and The Wonderful

It was the best of code, it was the worst of code. Coding Horrors, Worst Practices, and flashes of brilliance

This category can be followed from the open social web via the handle the-weird-and-the-wonderful@forum.codeproject.com

1.8k Topics 20.7k Posts
  • A "New" Way to practice TDD

    java oracle com testing debugging
    3
    0 Votes
    3 Posts
    5 Views
    R
    Tell him that if it was supposed to be that way they would have called it Development Driven Test (DDT) instead :) FFRF[^]
  • Informative Comments

    c++ question
    8
    0 Votes
    8 Posts
    6 Views
    D
    What? You mean you don't have the audio/visual integration tool based on the Apache weapons officer helmet that tracks your eye movement and interprets you verbal commands? Man, life became much easier when I put on the helmet. I can't wait until they finish getting the jack put in my cerebelum so I can just think code. ;P
  • UNUSED functions

    help tutorial question
    12
    0 Votes
    12 Posts
    34 Views
    D
    Ahh just start ignoring those harmless warnings... That way lies madness! I'm pretty sure I would not like to live in a world in which I would never be offended. I am absolutely certain I don't want to live in a world in which you would never be offended. Dave
  • Rewriting CString

    csharp visual-studio
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • 0 Votes
    3 Posts
    6 Views
    A
    Paddy Boyd wrote: forget to turn off debugging code Yep, sloppy. Makes a stronger case for specifically scheduling code-reviews a while after initial development. Paddy Boyd wrote: pretty stupid stuff around your storing of connections OK, so apart from this potential scenario, what reason would you give me for NOT storing a connection string in the application state? (Bear in mind it has to call Server.MapPath.. so ConfigurationSettings.AppSettings is no good - and I'm talking .NET 1.1 here). Paddy Boyd wrote: Subtle. Yes it is. Especially for traditional ASP programmers - you just don't expect your Application variables to ever be visible to the public like that. "For fifty bucks I'd put my face in their soup and blow." - George Costanza CP article: SmartPager - a Flickr-style pager control with go-to-page popup layer.
  • DataView - GetEnumerator

    data-structures question
    13
    0 Votes
    13 Posts
    25 Views
    S
    PIEBALDconsult wrote: Or they can work but not look good. That's me ;P --> Applied Knowledge Group - linking the knowledge of people
  • Help! NHibernate data saving problem.

    help c++ java database sysadmin
    14
    0 Votes
    14 Posts
    19 Views
    H
    Dear Richard, That is what the problem is. I really appreciate to what you did. It has been tough time for me. You saved me. Thank you again. Harry
  • 0 Votes
    39 Posts
    126 Views
    S
    You don't say, "I write programs good!" You say, "I write programs well."
  • Webservice!!!!

    help
    4
    0 Votes
    4 Posts
    21 Views
    V
    jchigg2000 wrote: a senior system's analyst He might be a senior system analyst just by virtue of his experience in date and time calendar. But adjudging him through his wise (pros) and vices (cons) in programming, he should truly be classified as a junior most crap :wtf: . Vasudevan Deepak Kumar Personal Homepage Tech Gossips A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
  • 0 Votes
    6 Posts
    13 Views
    P
    PIEBALDconsult wrote: To where did they outsourse their development? America. Deja View - the feeling that you've seen this post before. My blog | My articles
  • IF ELSE PRO

    5
    0 Votes
    5 Posts
    17 Views
    P
    Scott Barbour wrote: Look on the bright side... at least if the specs change in the future and you actually DO need to do something when those conditions are true, the structure is already in place... Sounds like somebody might have been thinking ahead... "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
  • Worderful object names

    wcf design tutorial question
    24
    0 Votes
    24 Posts
    104 Views
    R
    I should work with tons of code like THAT. Fantastic, isn't it? More like Craptastic... Could be worse though. I knew a guy who only used the characters Q,O,0,1,I,l in his variable names. He evidently believed they should be hard to understand as well as hard to type.... 'droid
  • A little tiny horror

    35
    0 Votes
    35 Posts
    150 Views
    N
    That is the first thing I thought of when I saw this. The thought of converting floating point to integers using casts keeps me awake at night. I am actually currently working on a project at work that has a few of these. I just started here at the time I noticed them. For fun, I thought it would be neat to try compiling this project (which was developed in VC++ 6.0) with VC 2005, and VC 2005 choked on these instances. Good job to the compiler team on that one. It also choked on a few things that I thought VC++ 6.0 should have, such as assigning an int literal to a CString. A few more bonus points to the team there, although 6.0 definitely should have caught that. Of the pow(int,int)s, at least one could've used the x *= 2 form, as it was in a loop, and the others the shift form. In the end, I decided not to touch any of them, because for all I know the truncation does mess things up but somebody spent a bunch of hours putting in "fixes" to work around this. The routines in question don't seem to have any bugs for now, but since a lot of the other ones do, I decided to focus my energy on those.
  • VBA GoTo Hell

    17
    0 Votes
    17 Posts
    25 Views
    V
    GuyThiebaut wrote: To code in C# you have to have a relatively good understanding of programming methodology(am I wrong?). True. VB family supports unstructured error handling like On Error Resume Next but such constructs are totally not supported in C#. Vasudevan Deepak Kumar Personal Homepage Tech Gossips A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
  • You need a flag? Why not create a file for that!

    csharp com question
    5
    0 Votes
    5 Posts
    7 Views
    P
    "complex", in the context of above post, meaning "anything you may not do in DLL Main" (such as loading other DLLs). How would creating an "access list" make the decision when to run some initialization "extensible and compartmentalized"? Please provide a sample. Alaric_ wrote: And "private global flag" would imply....well....an improper implementation for a "complex" solution The initialization may be complex, but the decision where to call it may be very simple. Alaric_ wrote: declaration of anything with global scope is incorrect If you said "questionable", I could follow you - while still arguing that it depends on the scenarion. But with such a blatant statement... do you know what "global" means? In what way would a file be "more" or "less" global than a variable in a private data segment? Can you argue for your point? the gist of it: global flag not always bad. We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP My first real C# project | Linkify!| FoldWithUs! | sighist
  • What does it do?

    question
    8
    0 Votes
    8 Posts
    16 Views
    C
    True... the return type was boolean. But I posted the example to see how much code and runtime overhead you need to return true from a function that does nothing. Nuclear launch detected
  • Anyone have a clue what this code does?

    question
    18
    0 Votes
    18 Posts
    53 Views
    T
    :) I wish I could claim it as my own original line, but I got it from my son. He found it somewhere online, and I loved it. :) WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated.
  • Do it only once please

    28
    0 Votes
    28 Posts
    17 Views
    C
    Tony Wesley wrote: The goto doesn't figure into that. Just above it in the thread is another snippet of my code that doesn't use a goto. Same issue. What happens to the code after the while loop when an exception is thrown? It doesn't get executed. Once could argue that the problem is with exception. As I pointed out elsewhere, Joel Spolsky argues that exceptions [...] create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's: (emphasis added) I don't quite agree with Joel. But there was a time, when I was debugging an app that another programmer had written, that I understood that completely. It was spaghetti exception handling. I never knew where I had come from. I'm not saying you shouldn't use exceptions. But they can be abused as badly as gotos. I'm talking about the case where coders like to put a block of cleanup code at the bottom of a method and "goto" it when something goes wrong or fall into it in a non-error situation. If you are depending on blocks of cleanup code, an exception will bypass it completely. This worked back in C, but not in OO design. That's why I use objects that clean themselves up when destroyed -- automatically. I am far too lazy to try to figure out every possible error situation, catch exceptions from anything that might throw them, and ensure that there is an appropriate goto. I disagree completely with Joel Spolsky. He suggests using return codes instead of exceptions. Return codes and exceptions are completely different things. Exceptions are not meant to be return codes. They are "exceptional" situations where usually the app cannot continue. And exceptions have the major advantage of unwinding the stack, which he fails to mention. They are not "an abrupt jump from one point of code to another." It seems like OO programming has really failed to catch on with a lot of developers. modified on Sunday, December 16, 2007 12:10:46 AM
  • 0 Votes
    5 Posts
    8 Views
    M
    I have to say I can't see that many problems. Discarding every other random number is a bit weird in the first example. Throughout there's a reliance on the low-precision system clock returned with DateTime.Now and TimeSpan.Milliseconds returns the milliseconds part only, you should use TotalMilliseconds if you want it to tell you how many seconds elapsed. For more accurate timing results use a System.Diagnostics.Stopwatch. At this point any collection which doesn't support generics is pretty stupid, the whole thing should be parameterized on T with a restriction that T derives from IComparable<T> or allows you to supply an IComparer<T>. I'd like to see a comparison with inserting into a sorted ArrayList or List<T> and using BinarySearch. A lot of emphasis is put on the computational algorithmic complexity of data structures and algorithms, but these days practical algorithm performance is based on memory speed hierarchies, and cache locality is very important. Further, an array typically represents a lower load on the garbage collector than a deeply-linked data structure (fewer pointers to follow). There is a reason why Microsoft didn't and still don't supply linked list or binary tree structures with the .NET Framework. DoEvents: Generating unexpected recursion since 1991
  • How NOT to reverse a list [modified]

    question
    6
    0 Votes
    6 Posts
    19 Views
    P
    CurtD wrote: nothing like data where the bits are still warm Souldn't he have done it twice then - just in case the first wasn't heated through warmly enough. Deja View - the feeling that you've seen this post before. My blog | My articles