Code switching in its current definition is the phenomenon of a person changing their behaviour in order to fit in with other people. It’s often used when people of a minority culture alter their behaviour in order to fit in with a majority culture.
Code switching is often interpreted as something that people shouldn’t really have to do, as it stops them being themselves.
This cartoon illustrates an example of when code switching would be a very good thing.
Code switching is in many ways a rebranding of the normal social activity of modifying one’s behaviour in different social settings. It is currently viewed by some people as a bad thing partly because of the current philosophy that you should “be yourself”.