How do I determine an object's type?

I’m writing a function which, for one of its parameters, could sensibly take any of several types of object. E.G. a spreadsheet, range, or cell. However the different object types need slightly different handling.

How do I determine the type of an object at runtime? “Object” won’t do; I need to know whether it’s an object of THIS type or an object of THAT type.

Look for the properties ‘SupportedServiceNames’ (an array) and/or ‘ImplementationName’. Mostly the first variant will offer what you need.

Okay, that answers the initial question but… looking for a list of ImplementationNames I found a page discussing a (former) bug, where several people expressed that it’s a poor coding practice to compare ImplementationName against a string literal. Other than find/generate an object of the type I’m interested in (which in some cases could be expensive or problematic) and compare the two objects’ ImplementationNames, (and/or whole arrays of service names) what do I compare against?

You will use services and thus need to know if a specific service is supported by an object.
What we call a spreadsheet or a single cell, now pOject simply, both also answer true to the question pObject.SupportsService("com.sun.star.sheet.SheetCellRange") like a generic cell range does. Since access to properties (even if an abbreviating notation exists) is provided by services that’s enough.
Best read the famous texts by Andrew Pitonyak.

Writing code for more than one kind of objects is a well established practise - assuming that it only depends on services supported by all of them.
Please note that SupportsService() is working case sensitive.
Distinction by ImplementationName is doubtabel.
If urgently needed you should realize that, e.g, a cell will support the SheetCellRange service, but “com.sun.star.sheet.SheetCell” is only supported by single cells.