Pop is a program built using the files listed below. In the first group we have C++ files for each of which there is a *.h header file and a *.cpp implementation file. To save space, we simply list each of these file names once, with the understanding that each name represents two files, the *.h and the *.cpp.
We can roughly group these files according to their purpose. The MFC Class files control things having to do with the program's standard Windows appearance. The Game files describe the different game modes that the Pop program allows. The Critter files specify the moving objects in the game programs and the Sprite files describe the appearances of these objects. The Physics files implement classes used to define the shape and the physics of the world. The catch-all category of Utility files includes a number of specially crafted files used, among other things, to make graphical animations run smoothly. There is no significance to the fact that some of the file names happen to be capitalized and some are not. This is simply an accident resulting from the ways the author typed in the new file names over the years. The Visual Studio compiler ignores the case of file names.
MFC Class files
childfrm
mainfrm
pop
PopDoc
popview
stdafx
Game files
game
gameairhockey
gameballworld
gamedambuilder
gamepicknpop
GameSpacewar
gamestub
gamestub3d
Critter files
biota
critter
critterarmed
critterwall
critterviewer
Sprite files
sprite
spritebubble
spriteicon
spritepolygon
spritemultiIcon
Physics files
VectorTransformation
realbox
force
Utility files
controller
listener
metric
Randomizer
timer
Graphics files
graphics
graphicsMFC
graphicsOpenGL
memorydc
RealPixelConverter
texture
glshapes
Dialog file
SpeedDialog
We also have a few files used for holding certain constants and parameters. These files do not appear in both the *.h and *.cpp format.
Parameter-holding files
static.cpp (and NO static.h )
graphicsconstants.h (and NO graphicsconstants.cpp )
RealNumber.h (and NO RealNumber.cpp )
In addition we have the Project files, which tell Visual Studio which files to compile and how to link them together.
In order to build an executable file from a collection of source code and resource files, we need a Project file to orchestrate how the files are to be combined. A Visual Studio project is described by two levels of files, a primary higher-level project file called a Workspace or Solution file, and one or more secondary lower-level files simply called project files. Generically any or all of these kinds of files may occasionally be termed 'project files.'
Microsoft changed the standard file extensions for their project files when they replaced the older Visual Studio, Version 6.0, by the newer Visual Studio.NET, also known as Version 7.0.
Table 3.1 will clarify the situation.
Version of Visual Studio |
High-level main project file extension, and name |
Lower-level project file extension, and name |
---|---|---|
.NET Version 7.0 |
*.sln, Solution file |
*.vcproj, Project file |
Version 6.0 |
*.dsw, Workspace file |
*.dsp, Project file |
Another essential part of the source code is the Resource files. In a Windows program, a 'resource' can be, among other things, a menu, a toolbar, a dialog box, a bitmap, an icon, a cursor icon, or a sound. resource.h and Pop.rc describe which resources to use, and the res subdirectory holds the digital information used in the resources themselves.
Don't forget that you need to keep the res subdirectory in order to be able to rebuild your executable; you must include it when you hand-off your source code to someone else.
Resource files
resource.h
Pop.rc
*.bmp Bitmap files, *.ico Icon files, *.cur Cursor files, *.wav Sound files, etc. [Note that these last files are located in the res subdirectory.]
One final file that we usually include with our source code is pop.clw, where CLW stands for 'CLass Wizard'. This file keeps track of the names of all your classes, and the class members and methods. You don't really have to keep this file, as Visual Studio can rebuild it if necessary. But it saves time to keep it around.
A UML component diagram shows the dependencies among a set of the physical components involved with your program build. In this section, we'll use 'physical component' to simply mean a file (or group of files) on your hard drive.
In a component diagram we draw nodes for different kinds of components and we draw dotted arrow-lines to indicate a dependency. An arrow from node A to node B means that A depends on B.
If you look at Chapter 20: Using Microsoft Visual Studio, you'll find quite a bit of detail about how the different kinds of files are combined to build an exe file. We can summarize some of that information with a component diagram (Figure 3.1) that shows how different kinds of files depend on each other when we build an exe file. In this figure, all the little names are kinds of file extensions.
The way we use these files is that we open the main Project file (sometimes called a Solution or a Workspace file) with the IDE (integrated development environment) program such as Visual Studio, use the IDE to edit the h and cpp files like text files, use the IDE to edit the rc file in a WYSIWYG fashion, and possibly create or import some additional resources of the types bmp, cur, and the like. If we like, we can use the IDE to change the build parameters of the Project files. Part of the Project file information is stored in a subsidiary Project file, though this is not something we normally notice.
As shown in Table 3.1 above, the extensions and names of the main and subsidiary 'project' files differ between Visual Studio Version 6.0 and Visual Studio.NET, also known as Version 7.0.
When you compile, the h and cpp are pulled together into obj files and the rc and resource files are combined into a res file. The linker wraps the obj together into an exe and then binds the res into the exe as well.
Another point to make about this diagram is that all of the files from cpp and rc up are text files, that is, simple ASCII files that we can edit with a simple text editor. (By the way if you ever happen to edit one of these files with a wordprocessor, be careful to save it in text-only format and make sure the file name gets the proper extension.) The obj, res and exe files, on the other hand, are binary files consisting of raw zeroes and ones.