Thread: Defensive programming?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> The main point here is to put using something to make the code a little cleaner and easier to read.

    My main point is "don't do that" and "don't advise people to do that". If somebody prefers to explicitly put std:: in front of everything, why advise the more dangerous solution? You think the code is cleaner and easier to read. I disagree. I think putting std:: in front of everything makes the code easier to read.

    There have been multiple posts on this site and others where the issue was solved simply by switching from a using directive to explicitly typing std::. It may be rare but it does happen.

    If your preference is to use using declarations or directives, fine, but I strongly disagree that the alternative is in fact worse.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    If they fixed the problem by explicitely qualifying the name then what's the problem? In those specific cases, it was required, but 99.999% of the time it doesn't matter which way you go. The using declaration was added to make life easier. You can shoot yourself in the foot with any tools, but that doesn't mean you should stop using them.
    If you do run into a problem, then by all means, go ahead and fully qualify the name, but otherwise just use the tools available to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help please.. linkedlists/classes
    By swayp in forum C++ Programming
    Replies: 10
    Last Post: 01-18-2005, 05:14 PM
  2. Segmentation fault with structs and char pointers
    By Keybone in forum C++ Programming
    Replies: 20
    Last Post: 01-17-2004, 01:36 PM
  3. Bowling for Columbine
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 97
    Last Post: 09-09-2003, 07:48 PM