Exploring the Code
In this chapter, we are going to pick apart the code of the online community application, seeing how it works. We will not be covering every last code file in this chapter (it would be a very long chapter indeed if we did). However, we will cover all the fundamentals here and will return to the other code in later chapters.
We will look at
Terminology that is used to refer to parts of the application
The overall structure of the application and its code
How the application uses a persistence service to make data access simpler and more efficient
The basic code that executes with each page request to the application
How the application provides a flexible search system
An overview of how security is handled
Before we get started with the code, it is worth defining some terms that are used throughout the code and this book:
UserAny human who is viewing the online community.
MemberA user who is logged in as a member of the community.
VisitorA user who is not logged in.
AdministratorA member who has permission to access administration options.
ModuleA collection of controls and database tables that provides a feature of the site. The modules in the starting-point application are Blog, ImageGallery, and News. Modules are key features of the application. It is the modular approach that makes the application easy to extend. Using modules also enables us to offer members choices about what features they use.
Module instanceA particular example of a module, created by a member. Each member can have many module instances, even more than one of the same module. For example, I might have an ImageGallery and a News module, whereas you might have two ImageGalleries. All the instances of a particular module will share the same basic functionality but will have their own data.
Global instanceA module that is being displayed without a specific instance. Data is collected from all instances of that module that are marked for inclusion in the global module. The global instance of each module enables the community application to collate the information that all the members have added. Therefore, the information from my News module might be combined with all the other news that members have added to create a set of headlines for the home page.
Module viewA way of displaying a module. For example, the News module includes views for Latest Headlines and Latest Summaries, and the ImageGallery includes views for Latest Images and Random Images. Module views enable us to offer options to members about how their information is displayed.
SectionAn area of the community, created by a member. (The term section, rather than page, was used to avoid confusion with ASP.NET pages.) Each member can have a number of sections. Each section can contain a number of section items.
Section itemA combination of a module instance and a module view, placed in a section. The module instance defines which data to display, whereas the module view defines how it should be displayed. A section item without a module instance will display the global instance of the module the view is for.
Don't worry if you are not totally clear about all of these terms right now; we will look at each of these things in more detail later in this chapter.