But Will It Fly?

OO enthusiasts are usually eager to point out the big ways in which OOP is superior to procedural programming, through capabilities such as inheritance, for instance. True enough, but probably of more importance is the fact that once you have a class, providing that the basic design is sound, you can easily add to its functionality. If it doesn't do something you want it to do, the simplest and often the best solution is to add a method to create additional behavior.

For example, you could easily add a method modeled on the method checkAllImages that would check for other types of files. Or, suppose some of the files in the directory passed to the constructor are not image files, and you don't want your program to attempt to display them. This could be remedied with a filter method. I'm sure you can think of other ways in which this class can be improved. The next chapter will improve on this class so that it can be used in a variety of ways, but the focus will be on its use with a directory of image files.

Furthermore, some of the shortcomings of this class suggest the creation of additional classes rather than additions to the DirectoryItems class. First, images are of varying sizes. This not only affects the aesthetics of a web page, but, if the images are large, this can significantly slow the rate at which a page downloads. Second, if there are a considerable number of files in one directory, a single web page that displays all of them will be unacceptably long. In later chapters we'll follow up on both of these ideas.

At the beginning of this chapter I promised that we wouldn't create a dog class, and perhaps instead, we've created an ugly duckling. In any case, you'll want to stick around for another chapter not only to see if our fledgling can fly but also to see whether our ugly duckling turns into a swan.

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

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