Answer the question
In order to leave comments, you need to log in
How to apply polymorphism correctly?
Let's say in the system there is such an entity as the waybill (tn) for each of the delivery services. But depending on the type of tn, some can be edited in the database, others interact with third-party services (sdek) and they have the appropriate logic. How can I better build an architecture so that, for example, when editing an order, call the necessary tn methods depending on its type? (if ttn can be edited - edit, if you need to edit on a third-party service - do it) Make the appropriate interfaces for each type? ( EditableInDb
, DeliveryServiceSync
etc.) and then check for the interface
if ($ttn instanceof EditableInDb) {
//some logic
}
Answer the question
In order to leave comments, you need to log in
Made a boolean type property, which will be the main main difference
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question