Chapter 10. General Issues in Using Variables

cc2e.com/1085

Contents

Related Topics

It's normal and desirable for construction to fill in small gaps in the requirements and architecture. It would be inefficient to draw blueprints to such a microscopic level that every detail was completely specified. This chapter describes a nuts-and-bolts construction issue: the ins and outs of using variables.

The information in this chapter should be particularly valuable to you if you're an experienced programmer. It's easy to start using hazardous practices before you're fully aware of your alternatives and then to continue to use them out of habit even after you've learned ways to avoid them. An experienced programmer might find the discussions on binding time in Binding Time and on using each variable for one purpose in Using Each Variable for Exactly One Purpose particularly interesting. If you're not sure whether you qualify as an "experienced programmer," take the "Data Literacy Test" in the next section and find out.

Throughout this chapter I use the word "variable" to refer to objects as well as to built-in data types like integers and arrays. The phrase "data type" generally refers to built-in data types, while the word "data" refers to either objects or built-in types.

Data Literacy

Data Literacy

The first step in creating effective data is knowing which kind of data to create. A good repertoire of data types is a key part of a programmer's toolbox. A tutorial in data types is beyond the scope of this book, but the "Data Literacy Test" will help you determine how much more you might need to learn about them.

The Data Literacy Test

Put a 1 next to each term that looks familiar. If you think you know what a term means but aren't sure, give yourself a 0.5. Add the points when you're done, and interpret your score according to the scoring table below.

_____ abstract data type

_____ literal

_____ array

_____ local variable

_____ bitmap

_____ lookup table

_____ boolean variable

_____ member data

_____ B-tree

_____ pointer

_____ character variable

_____ private

_____ container class

_____ retroactive synapse

_____ double precision

_____ referential integrity

_____ elongated stream

_____ stack

_____ enumerated type

_____ string

_____ floating point

_____ structured variable

_____ heap

_____ tree

_____ index

_____ typedef

_____ integer

_____ union

_____ linked list

_____ value chain

_____ named constant

_____ variant

 

_____ Total Score

Here is how you can interpret the scores (loosely):

0–14

You are a beginning programmer, probably in your first year of computer science in school or teaching yourself your first programming language. You can learn a lot by reading one of the books listed in the next subsection. Many of the descriptions of techniques in this part of the book are addressed to advanced programmers, and you'll get more out of them after you've read one of these books.

15–19

You are an intermediate programmer or an experienced programmer who has forgotten a lot. Although many of the concepts will be familiar to you, you too can benefit from reading one of the books listed below.

20–24

You are an expert programmer. You probably already have the books listed below on your shelf.

25–29

You know more about data types than I do. Consider writing your own computer book. (Send me a copy!)

30–32

You are a pompous fraud. The terms "elongated stream," "retroactive synapse," and "value chain" don't refer to data types—I made them up. Please read the "Intellectual Honesty" section in Chapter 33!

Additional Resources on Data Types

These books are good sources of information about data types:

Cormen, H. Thomas, Charles E. Leiserson, Ronald L. Rivest. Introduction to Algorithms. New York, NY: McGraw Hill. 1990.

Sedgewick, Robert. Algorithms in C++, Parts I-IV, 3d ed. Boston, MA: Addison-Wesley, 1998.

Sedgewick, Robert. Algorithms in C++, Part V, 3d ed. Boston, MA: Addison-Wesley, 2002.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.35.122