ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡ÔĶÁ¹ý³Ì·¢ÏÖÈκδíÎóÇë¸æËßÎÒÃÇ£¬Ð»Ð»£¡£¡ ±¨¸æ´íÎó
ϲÊéÍø ·µ»Ø±¾ÊéĿ¼ ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ½øÈëÊé°É ¼ÓÈëÊéÇ©

VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ73ÕÂ

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡




previous¡¡examples£»¡¡we¡¡had¡¡control¡¡of¡¡every¡¡class£»¡¡interface£»¡¡and¡¡definition¡£¡¡This¡¡time£»¡¡we¡¡are¡¡¡¡

not¡¡in¡¡control£»¡¡and¡¡thus¡¡we¡¡need¡¡to¡¡use¡¡a¡¡defensive¡¡style¡¡of¡¡programming¡£¡¡This¡¡means¡¡we¡¡need¡¡¡¡

to¡¡write¡¡many¡¡tests¡¡and¡¡keep¡¡certain¡¡information¡¡private¡£¡¡¡¡



Defining¡¡the¡¡Interfaces¡¡



The¡¡core¡¡of¡¡the¡¡lighting¡¡controller¡¡is¡¡to¡¡control¡¡the¡¡lighting¡¡in¡¡a¡¡room¡¡that¡¡is¡¡part¡¡of¡¡the¡¡building¡£¡¡¡¡

We¡¡can¡¡define¡¡and¡¡organize¡¡the¡¡rooms¡¡by¡¡using¡¡interfaces¡£¡¡We¡¡need¡¡four¡¡interfaces£º¡¡¡¡



¡¡¡¡¡¡¡¡¡¡o¡¡¡¡IRoom£º¡¡A¡¡placeholder¡¡interface¡¡for¡¡the¡¡idea¡¡of¡¡a¡¡room¡¡



¡¡¡¡¡¡¡¡¡¡o¡¡¡¡INoRemoteControlRoom£º¡¡An¡¡interface¡¡for¡¡rooms¡¡that¡¡should¡¡not¡¡be¡¡controlled¡¡by¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡lighting¡¡controller¡¡



¡¡¡¡¡¡¡¡¡¡o¡¡¡¡IRemoteControlRoom£º¡¡An¡¡interface¡¡for¡¡rooms¡¡that¡¡should¡¡be¡¡pletely¡¡controlled¡¡by¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡lighting¡¡controller¡¡



¡¡¡¡¡¡¡¡¡¡o¡¡¡¡ISensorRoom£º¡¡An¡¡interface¡¡for¡¡rooms¡¡whose¡¡control¡¡is¡¡based¡¡on¡¡state¡¡£¨whether¡¡or¡¡not¡¡a¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡person¡¡is¡¡in¡¡the¡¡room£©¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡222¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

200¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡8¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡OU¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TO¡¡R¡¡IE¡¡N¡¡T¡¡E¡¡D¡¡¡¡AR¡¡C¡¡HI¡¡TE¡¡CT¡¡U¡¡R¡¡E¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡interfaces¡¡for¡¡the¡¡rooms¡¡where¡¡lighting¡¡may¡¡be¡¡controlled£»¡¡IRemoteControlRoom¡¡and¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ISensorRoom£»¡¡will¡¡depend¡¡on¡¡certain¡¡pieces¡¡of¡¡logic¡£¡¡The¡¡interfaces¡¡will¡¡need¡¡to¡¡provide¡¡input¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡data¡¡and¡¡accept¡¡output¡¡data¡£¡¡The¡¡logic¡¡might¡¡also¡¡seek¡¡input¡¡from¡¡other¡¡sources£»¡¡such¡¡as¡¡time¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡of¡¡day¡¡or¡¡amount¡¡of¡¡sunlight¡¡outdoors¡£¡¡It¡¡boils¡¡down¡¡to¡¡defining¡¡some¡¡type¡¡of¡¡logic¡¡that¡¡the¡¡kernel¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implements¡£¡¡This¡¡is¡¡key£»¡¡and¡¡it¡¡relates¡¡to¡¡the¡¡children¡­and¡­parent¡¡issue¡£¡¡While¡¡you¡¡accept¡¡your¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡children¡¡as¡¡being¡¡intelligent¡¡beings¡¡that¡¡can¡¡make¡¡decisions£»¡¡at¡¡the¡¡end¡¡of¡¡the¡¡day£»¡¡it¡¡is¡¡usually¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡parent¡¡who¡¡makes¡¡the¡¡final¡¡decisions¡£¡¡Likewise£»¡¡while¡¡your¡¡kernel¡¡might¡¡accept¡¡input¡¡and¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡potential¡¡decisions£»¡¡the¡¡kernel¡¡makes¡¡the¡¡final¡¡decisions¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Defining¡¡IRoom£»¡¡a¡¡Placeholder¡¡Interface¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡design¡¡purposes£»¡¡the¡¡simplest¡¡and¡¡base¡¡idea¡¡is¡¡the¡¡room¡¡itself£»¡¡which¡¡can¡¡be¡¡defined¡¡as¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡follows¡¡£¨in¡¡the¡¡controller¡¡library¡¡¡¡LibLightingSystem£©£º¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Interface¡¡IRoom¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Interface¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡interface¡¡does¡¡not¡¡have¡¡any¡¡methods¡¡or¡¡properties¡£¡¡It¡¡is¡¡called¡¡a¡¡placeholder¡¡interface¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡placeholder¡¡type¡¡serves¡¡no¡¡other¡¡purpose¡¡than¡¡identifying¡¡that¡¡the¡¡implementation¡¡is¡¡of¡¡a¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡certain¡¡type¡£¡¡Placeholder¡¡interfaces¡¡make¡¡it¡¡simpler¡¡to¡¡group¡¡objects¡¡that¡¡have¡¡certain¡¡capabilities¡£¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Imagine¡¡defining¡¡objects¡¡without¡¡a¡¡placeholder¡¡interface£»¡¡something¡¡like¡¡this£º¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Type1¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Type2¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Looking¡¡at¡¡Type1¡¡and¡¡Type2£»¡¡you¡¡cannot¡¡see¡¡any¡¡correlation¡¡between¡¡the¡¡two¡¡types£»¡¡there¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡is¡¡no¡¡way¡¡to¡¡say¡¡that¡¡Type1¡¡and¡¡Type2¡¡have¡¡anything¡¡in¡¡mon¡£¡¡£¨Well£»¡¡technically¡¡there¡¡is¡¡a¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡correlation¡¡in¡¡that¡¡both¡¡types¡¡are¡¡derived¡¡from¡¡Object£»¡¡but¡¡that¡¡type¡¡of¡¡correlation¡¡is¡¡like¡¡saying¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡that¡¡all¡¡people¡¡are¡¡humans¡££©¡¡Using¡¡a¡¡placeholder¡¡interface£»¡¡Type1¡¡and¡¡Type2¡¡can¡¡be¡¡correlated£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡as¡¡follows£º¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Type1¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IRoom¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Type2¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IRoom¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¡¡¡£¡¡¡£¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡rooms¡¡As¡¡IRoom£¨£©¡¡=¡¡New¡¡IRoom£¨£©¡¡£ûNew¡¡Type1£¨£©£»¡¡New¡¡Type2£¨£©£ý¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Having¡¡Type1¡¡and¡¡Type2¡¡implement¡¡the¡¡¡¡IRoom¡¡interface£»¡¡which¡¡means¡¡do¡¡nothing¡¡other¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡than¡¡subclass¡¡IRoom£»¡¡establishes¡¡a¡¡correlation¡¡between¡¡Type1¡¡and¡¡Type2¡£¡¡The¡¡correlation¡¡is¡¡that¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡both¡¡Type1¡¡and¡¡Type2¡¡are¡¡rooms¡£¡¡We¡¡have¡¡no¡¡idea¡¡what¡¡kind¡¡of¡¡rooms£»¡¡and¡¡we¡¡have¡¡no¡¡idea¡¡if¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡rooms¡¡are¡¡in¡¡the¡¡same¡¡building¡£¡¡We¡¡only¡¡know¡¡that¡¡they¡¡are¡¡rooms¡£¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡use¡¡of¡¡placeholder¡¡interfaces¡¡is¡¡very¡¡important¡¡in¡¡kernel¡¡design¡£¡¡Placeholders¡¡estab

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡lish¡¡that¡¡a¡¡type¡¡wants¡¡to¡¡be¡¡part¡¡of¡¡a¡¡grouping¡£¡¡The¡¡kernel¡¡can¡¡use¡¡that¡¡grouping¡¡to¡¡define¡¡a¡¡list¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡of¡¡elements¡¡that¡¡are¡¡all¡¡similar¡£¡¡It¡¡is¡¡like¡¡knowing¡¡the¡¡age¡¡of¡¡people¡¡to¡¡determine¡¡whether¡¡they¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡are¡¡eligible¡¡to¡¡drive¡£¡¡The¡¡age¡¡does¡¡not¡¡indicate¡¡the¡¡sex¡¡or¡¡intelligence£»¡¡nor¡¡if¡¡they¡¡are¡¡good¡¡or¡¡bad¡¡¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡223¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡H¡¡AP¡¡TE¡¡R¡¡¡¡¡¡8¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡AR¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡O¡¡U¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡T¡¡O¡¡R¡¡IE¡¡N¡¡TE¡¡D¡¡¡¡¡¡A¡¡R¡¡CH¡¡I¡¡TE¡¡C¡¡TU¡¡R¡¡E¡¡201¡¡



drivers¡£¡¡The¡¡age¡¡is¡¡a¡¡placeholder¡¡that¡¡says£»¡¡¡°Yes¡¡you¡¡are¡¡part¡¡of¡¡a¡¡grouping¡¡that¡¡is¡¡allowed¡¡to¡¡take¡¡¡¡

a¡¡driving¡¡test¡¡to¡¡give¡¡you¡¡the¡¡right¡¡to¡¡drive¡£¡±¡¡

¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡case¡¡of¡¡our¡¡lighting¡¡control£»¡¡defining¡¡the¡¡¡¡IRoom¡¡placeholder¡¡interface¡¡is¡¡saying¡¡that¡¡¡¡

whatever¡¡instance¡¡is¡¡associated¡¡with¡¡IRoom¡¡is¡¡indicating¡¡its¡¡interest¡¡in¡¡being¡¡part¡¡of¡¡the¡¡lighting¡¡¡¡

controller¡¡kernel¡£¡¡When¡¡you¡¡have¡¡identified¡¡a¡¡type¡¡using¡¡a¡¡placeholder¡¡interface£»¡¡you¡¡are¡¡saying¡¡¡¡

your¡¡type¡¡can¡¡be¡¡used¡¡in¡¡a¡¡certain¡¡context¡£¡¡The¡¡context¡¡is¡¡determined¡¡by¡¡the¡¡placeholder¡¡¡¡

interface¡£¡¡



Defining¡¡the¡¡INoRemoteControlRoom¡¡Interface¡¡



Although¡¡the¡¡purpose¡¡of¡¡the¡¡lighting¡¡system¡¡is¡¡to¡¡control¡¡the¡¡lighting£»¡¡some¡¡rooms¡¡should¡¡not¡¡¡¡

be¡¡controlled¡¡by¡¡the¡¡system¡£¡¡Perhaps¡¡the¡¡room¡¡is¡¡private£»¡¡or¡¡controlling¡¡its¡¡lighting¡¡would¡¡cause¡¡¡¡

problems¡£¡¡

¡¡¡¡¡¡¡¡¡¡For¡¡example£»¡¡should¡¡a¡¡bedroom¡¡in¡¡a¡¡house¡¡be¡¡controlled¡¡by¡¡the¡¡lighting¡¡controller£¿¡¡If¡¡the¡¡¡¡

lighting¡¡controller¡¡controls¡¡the¡¡lighting¡¡in¡¡the¡¡bedroom£»¡¡it¡¡might¡¡turn¡¡off¡¡the¡¡lights¡¡while¡¡a¡¡person¡¡is¡¡¡¡

reading¡£¡¡Or¡¡maybe¡¡it¡¡will¡¡turn¡¡on¡¡the¡¡lights¡¡when¡¡the¡¡person¡¡has¡¡decided¡¡to¡¡sleep¡¡in¡£¡¡Of¡¡course£»¡¡¡¡

the¡¡person¡¡could¡¡just¡¡switch¡¡the¡¡light¡¡on¡¡or¡¡off¡¡manually£»¡¡but¡¡that¡¡is¡¡disruptive¡£¡¡The¡¡inconve

nience¡¡of¡¡the¡¡controller¡¡getting¡¡it¡¡wrong¡¡outweighs¡¡the¡¡benefit¡¡of¡¡the¡¡controller¡¡getting¡¡it¡¡right£»¡¡¡¡

so¡¡the¡¡controller¡¡should¡¡not¡¡deal¡¡with¡¡this¡¡room¡£¡¡

¡¡¡¡¡¡¡¡¡¡The¡¡definition¡¡of¡¡an¡¡interface¡¡that¡¡indicates¡¡that¡¡the¡¡controller¡¡should¡¡do¡¡nothing¡¡is¡¡as¡¡¡¡

follows¡¡£¨in¡¡the¡¡controller¡¡library¡¡¡¡LibLightingSystem£©£º¡¡



Public¡¡Interface¡¡INoRemoteControlRoom¡¡

¡¡¡¡¡¡¡¡Inherits¡¡IRoom¡¡

End¡¡Interface¡¡



¡¡¡¡¡¡¡¡¡¡As¡¡you¡¡can¡¡see£»¡¡¡¡INoRemoteControlRoom¡¡lacks¡¡methods¡¡and¡¡properties£»¡¡like¡¡our¡¡placeholder¡¡¡¡

interface¡¡IRoom¡£¡¡However£»¡¡in¡¡this¡¡case£»¡¡there¡¡are¡¡no¡¡methods¡¡or¡¡properties¡¡because¡¡the¡¡kernel¡¡¡¡

system¡¡does¡¡not¡¡require¡¡them¡£¡¡The¡¡idea¡¡behind¡¡the¡¡INoRemoteControlRoom¡¡interface¡¡is¡¡to¡¡indicate¡¡¡¡

that¡¡the¡¡type¡¡implementing¡¡the¡¡interface¡¡is¡¡a¡¡room£»¡¡but¡¡a¡¡room¡¡that¡¡should¡¡not¡¡be¡¡managed¡¡by¡¡¡¡

the¡¡controller¡£¡¡Using¡¡the¡¡bedroom¡¡as¡¡an¡¡example£»¡¡the¡¡implementation¡¡is¡¡as¡¡follows¡¡£¨defined¡¡in¡¡¡¡

the¡¡Home¡¡project£©£º¡¡



¡¡¡¡¡¡¡¡Imports¡¡LibLightingSystem¡¡

¡¡¡¡¡¡¡¡Public¡¡Class¡¡Bedroom¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡INoRemoteControlRoom¡¡

¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡The¡¡definition¡¡of¡¡the¡¡bedroom¡¡allows¡¡the¡¡kernel¡¡to¡¡use¡¡an¡¡instance¡¡of¡¡a¡¡room£»¡¡as¡¡follows£º¡¡



Dim¡¡rooms¡¡As¡¡IRoom£¨£©=¡¡New¡¡IRoom£¨10£©¡¡£û¡¡£ý¡¡

rooms£¨0£©¡¡=¡¡New¡¡Bedroom£¨£©¡¡

¡¡¡£¡¡¡£¡¡¡£¡¡



If¡¡TypeOf£¨rooms£¨0£©£©¡¡Is¡¡INoRemoteControlRoom¡¡Then¡¡

¡¡¡¡¡¡¡¡'¡¡Take¡¡appropriate¡¡action¡¡

End¡¡If¡¡



¡¡¡¡¡¡¡¡¡¡This¡¡code¡¡creates¡¡an¡¡array¡¡of¡¡rooms¡¡and¡¡assigns¡¡the¡¡index¡¡0¡¡to¡¡an¡¡instance¡¡of¡¡Bedroom¡£¡¡The¡¡¡¡

If¡¡statement¡¡asks¡¡if¡¡the¡¡¡¡IRoom¡¡instance¡¡in¡¡index¡¡0¡¡is¡¡of¡¡type¡¡INoRemoteControlRoom¡£¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡224¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

202¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡8¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡OU¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TO¡¡R¡¡IE¡¡N¡¡T¡¡E¡¡D¡¡¡¡AR¡¡C¡¡HI¡¡TE¡¡CT¡¡U¡¡R¡¡E¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡öNote¡¡¡¡Using¡¡placeholder¡¡interfaces¡¡and¡¡inheritance¡¡sets¡¡up¡¡a¡¡very¡¡powerful¡¡architecture¡¡that¡¡allows¡¡you¡¡to¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡create¡¡groupings¡£¡¡You¡¡can¡¡then¡¡filter¡¡individual¡¡instances¡¡based¡¡on¡¡refinements¡¡of¡¡the¡¡grouping¡£¡¡All¡¡of¡¡this¡¡is¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡possible¡¡in¡¡the¡¡Visual¡¡Basic¡¡language¡¡using¡¡TryCast£¨£©¡¡and¡¡Is£»¡¡which¡¡allow¡¡queries¡¡of¡¡subclassed¡¡types¡¡of¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡an¡¡instance¡£¡¡The¡¡queries¡¡are¡¡noninvasive¡¡and¡¡do¡¡not¡¡cause¡¡exceptions¡¡to¡¡be¡¡thrown¡£¡¡The¡¡queries¡¡give¡¡you¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ability¡¡to¡¡make¡¡decisions¡¡based¡¡on¡¡whether¡¡an¡¡instance¡¡would¡¡like¡¡to¡¡be¡¡associated¡¡with¡¡a¡¡particular¡¡group
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
δÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡