mardi 7 novembre 2023

Will it break SOLID principle?

trying to write a generic method which get called and based on object type it should set indicators.

  1. will it break solid principle?
  2. is there any better way of doing it.

i was working on one of the feature where i have 3 line of business like Car, van and bike. I have IVechile interface which is handling all the common implementation between 3 Line of business.

Now, i have to set two common indicator Car and Van but for bike i want to set some different indicator. I want to create a object of this class once but it handle based on type of line business. If write this method like this will it break SOLID principle? If it is incorrect please suggest me something?

Note: INDICATOR_B should be true in all LOB

function populateIndicator() {
  if (_motorObject typeis Car or _motorObject typeis entity.Van) {
    _motorObject.INDICATOR_A = true
  }
  if (_motorObject typeis Bike) {
    _motorObject.INDICATOR_C = true
  }
  _motorObject.INDICATOR_B = true
}

Aucun commentaire:

Enregistrer un commentaire