Using namespace - valuable, but limited

Hey everyone,
In lesson 17, we’ve been given some extremely helpful information regarding namespaces, namely, their primary usecase vs the function "Using namespace ". Both have their place, however the limitations to Using namespace cannot be understated. This function, if used improperly, can lead to confusing clashes in your code, specifically if a function shows up in multiple namespaces, it can confuse the compiler or your program as it won’t know which to call. This, of course, can be particularly noticeable if you have numerous instances of the function, but don’t know which namespace you intended to call from.

While it may be faster for the programmer in the present, mistakes with Using namespace can wreak havoc down the road, slowing down not only the programmer but entire teams, so if you are going to use it, make sure to watch which library or namespace you intend to pull from, and comment every step of the way to make sure you know what you were trying to accomplish at the time of writing.

Being a bit of a clumsy programmer, I’ll probably call the namespace more often than not, just to prevent running into issues where I typed faster than I thought!

  • Adam

Privacy & Terms