< Previous | Contents | Next >

Understanding When to Employ

using

Okay, youve seen two ways to make elements from a namespace local to your program. But which is the best technique?

A language purist would say you shouldnt employ either version of using and that you should always prefix each and every element from a namespace with its identifier. In my opinion, thats like calling your best friend by his first and last name all the time. It just seems a little too formal.

If you hate typing, you can employ the using directive. A decent compromise is to employ using declarations. In this book, Ill employ the using directive most of the time for brevitys sake.

Rea l Worl d

image

I’ve laid out a few different options for working with namespaces. I’ve also tried to explain the advantages of each so you can decide which way to go in your own programs. Ultimately, though, the decision may be out of your hands. When you’re working on a project, whether it’s in the classroom or in the professional world, you’ll probably receive coding standards created by the

Using Arithmetic Operators 13


person in charge. Regardless of your personal tastes, it’s always best to listen to those who hand out grades or paychecks.

image