[ Pobierz całość w formacie PDF ]
.You do need to worry about an object type prefix.Objectscome in a variety of types, and you indicate that an entity isan object and the kind of object it is through the prefix.Table13.2 shows the prefixes you can use for some of the more commonlyencountered objects.Table 13.2.ActiveX control object prefixes.PrefixControl Object TypeExamplechkCheck boxchkOrderPlacedchtChart or graphchtStockPricescmdCommand buttoncmdPlaceOrderlblLabellblHeartRateFeedbackobjGeneric ObjectobjWindowDocumentoptRadio button (also called option button)optSmallSizeprePreloadpreCompanyLogotmrTimertmrPulseRateMeasurementDurationtxtText boxtxtShoeSizeThese prefixes provide descriptive, meaningful names for yourobjects.You should give the objects descriptive names that arecombined with their prefixes.Notice that the names for some objects,such as the command button object, should be descriptive of anaction, as in cmdCalculate.Other objects that contain user-supplied information but are notdirectly associated with an action, such as a text box control,should have descriptive names similar to those of variables, asin txtShoeSize.You shouldmake your own customized object-naming convention list a partof your standards because this is one part of your standards inparticular that is likely to evolve.Over time, more and morecontrols of various types will probably become part of your programmingrepertoire as more controls become available.You will want toexpand your standards to make sure to include standard prefixesfor any controls you purchase in the future for your development.Table 13.2 includes the subhead "Prefix," but the definitionsinclude those for intrinsic HTML elements that are automaticallydefined, such as text box and check box controls, in additionto those that you explicitly define with the objects tag.Theseare a special type of object, and conceptually, your code treatsthem the same.The obj tag is a generictag that can be used to refer to any object.There is a virtuallyunlimited number of types of objects that you may encounter.Eachnew control created by vendors is a new kind of object.You mayfind that if you try to come up with a new meaningful prefix foreach control you use, your code soon becomes filled with variableprefixes that confuse and befuddle you rather than serve the intendedpurpose of clarifying your code! For that reason, it is a goodstrategy to prefix the many objects under the spectrum that aren'taddressed in Table 13.2 as obj.If you couple that with a meaningful name, then at a glance youcan tell everything you need to know about the identifier.Youknow from the prefix that it's an object, and you know what kindof object from the remainder of the name.This can encompass ActiveXcontrols; browser objects such as windows, documents, frames,and the navigator; Java applets; and more.On the other hand,if you use one specific type of object frequently, it may warrantdesignating a standard prefix for it to help it stand out in yourcode.Remember, the overall goal is that you want prefix paybackwithout prefix clutter!Good naming conventions for objects are just as important as-andin some instances, more important than-naming conventions in otherareas.This is because you can declare objects in many differentplaces throughout a script.Keeping them straight can become abit of a maintenance challenge as your Web pages grow larger.If you use good naming conventions, you have immediate feedbackabout exactly which types of objects the code is using and whetherthey are implicit or explicitly declared.Consider the followingline where neither prefixes nor descriptive names are used inreferring to an object:feedback="normal"This statement doesn't tell you too much without additional digging.A little dose of conventions makes it more descriptive even withoutlooking further into the source code:lblHeartRateFeedback.caption="normal"This line tells you that a label object is used and provides moredetails on the type of information displayed in that label.Justthe application of standard naming conventions to this statementis enough to tell you that the line fills a label with heart ratefeedback
[ Pobierz całość w formacie PDF ]