code: def add_object(self, obj):
          
          if _debug: Application._debug("add_object %r", obj)
  
          # extract the object name and identifier
          object_name = obj.objectName
          if not object_name:
              raise RuntimeError("object name required")
          object_identifier = obj.objectIdentifier
          if not object_identifier:
              raise RuntimeError("object identifier required")
  
          # assuming the object identifier is well formed, check the instance number
          if (object_identifier[1] >= ObjectIdentifier.maximum_instance_number):
              raise RuntimeError("invalid object identifier")
  
          # make sure it hasn't already been defined
          if object_name in self.objectName:
              raise RuntimeError("already an object with name %r" % (object_name,))
          if object_identifier in self.objectIdentifier:
              raise RuntimeError("already an object with identifier %r" % (object_identifier,))
  
          # now put it in local dictionaries
          self.objectName[object_name] = obj
          self.objectIdentifier[object_identifier] = obj
  
          # append the new object's identifier to the local device's object list
          # if there is one and it has an object list property
          if self.localDevice and self.localDevice.objectList:
              self.localDevice.objectList.append(object_identifier)
  
          # let the object know which application stack it belongs to
          obj._app = self
docs: Add an object to the local collection.