samedi 27 mars 2021

how to make 'B', 'C' codes are not to be loaded into memory to improve performance when 'A' is chosen among 'A', 'B', 'C' through if else?

Let's say we have car management software and codes are,

if (power== "gasoline")
{
   // many code
}
else if (power== "diesel")
{
   // many code
}
else if (power== "electric")
{
   // many code 
}
else if (power== "hybrid")
{
   // many code
}

As title of this question, I don't want the code of 'diesel', 'electric', 'hybrid' to be loaded into memory to improve performance when a user selects 'gasoline'.

Is there a excellent way for this case ?

Thank you !

Aucun commentaire:

Enregistrer un commentaire