The method depends on how your sensors are setup.
Assuming you are using some kind of distance sensor, you want to determine where the object is and how far away it is, and where its edges are. So, if your robot is senses an object, it scans the object until it sees the edges of the object. Once the robot has the objects size, it could 'know' what that object is based off what you tell it objects that size are.
It doesn't necessarily need to be 'size' and 'distance', though. You could have other sensors, like heat detection. Or, a sensor which could determine density, like ultrasound. Using one or more of these and the data the sensor gets, the robot decides what it is based off what you program it to think.
And everything gets more complex if the object is not stationary.