Is This Use of the “instanceof” Operator Considered Bad Design?
问题 In one of my projects, I have two \"data transfer objects\" RecordType1 and RecordType2 that inherit from an abstract class of RecordType. I want both RecordType objects to be processed by the same RecordProcessor class within a \"process\" method. My first thought was to create a generic process method that delegates to two specific process methods as follows: public RecordType process(RecordType record){ if (record instanceof RecordType1) return process((RecordType1) record); else if