Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 12: Commanding SharePoint through Code and can command it as you see fit. As a SharePoint programmer, you become the wizard and SharePoint becomes the wonderful world of Oz. 267 Introducing Object-Oriented Programming An Object Model (OM) can often be a difficult concept to wrap your head around. There are many prerequisites to master before you can get an Object Model to do your bidding; fortunately, you don't need most of them to start writing SharePoint code. For example, you should already understand the concepts behind object-oriented programming (nicknamed OOP -- or OO if you don't want to sound like you just dropped something), but you don't have to be an expert. Object-oriented programming is a way to break apart the pieces of a program you're developing into the functional "objects" that each piece represents. For example, if you're creating a simple gas mileage program, then you might develop a piece of code that represents a car. In the code that represents a car, you might have variables for the amount of gas it can hold, the current level of fuel, the speed, and the distance traveled. This piece of code that rep- resents a car is called an object; object-oriented programming creates, manip- ulates, and arranges such logical objects. When you're programming your application, you don't need to think about all the components of a car as you build your program. You just instantiate (create a new instance of) a car object when you need it -- and then work with the components of that car object throughout the program. For example, if you create two cars in your program and then assign a value to a variable to rep- resent the gas level for each car, you might easily get confused which variable goes with which car. Instead you can simply know that car A has a variable that can be accessed as a property of that car object -- code such as carA. fuel = 100 might reference the fuel tank within the car A object. This simple example explains the very basics of how object-oriented programming works. Complete volumes of books and complete college degrees cover the subject, so if you don't feel like an expert, don't worry. You can still get by just under- standing the basics and learning about the SharePoint Object Model as you go. Discovering the SharePoint Object Model The easiest way to understand the SharePoint Object Model is to imagine taking an entire SharePoint installation and breaking it down into small functional pieces. Some of the functional pieces, or objects, you might have include site collections, sites/sub-sites, lists, libraries, and fields, as shown in