Both possibilities if we understand code-switching (translaguaging) as a conscious action, as pointed by Lisbeth Nilsson. I do think code-switching is a very interesting and useful strategy as regards teaching contents in an aditional language. When code-switching is not a conscious strategy we come into a completely different scenario and other elements should be taken into accout (why is code-switching produced, if this is the consequence of L2 -or L3- interference, for instance).
Code-switching in an additional language requires a more advanced vocabulary, a good understanding of spoken language, and knowledge of how word nuances can be used to slightly change the code or meaning of an utterence.
Code-switching is evident in dialects as well as multilinguals. It is important to recognize that code-switching is a conscious process in many situations, although the process itself may not involve any deliberation on the structural properties of the dialects or languages in question. Those who speak English as a second language tend to code-switch under two conditions (e.g., Nilep, 2006; Woolard, 2004): (1) when speaking with an audience they know is bilingual and (2) when they need a word in L2 that they don’t have or can’t remember. The situation is different for nonstandard-English speakers. They generally do not code-switch when speaking with others who are bidialectal. Instead, they will use one dialect or the other, depending on the social relationship that exists among the group and on the setting. The dominant factor, however, is the social relationship: As it becomes more intimate, there is a greater tendency to use the home dialect, even in those situations in which other speakers do not have a high proficiency in that dialect.
Code-switching also occur when you talk to different people, for example people in different ages (infant, toddler, teenager, adult, senior) people with different occupations and status (industrial worker, CEO) or people with different degrees of cognitive disabilities. However, this kind of code-switching may be either unconscious, intuitive, skilled or used as a strategy.
As previous discussants have remarked, code-switching can be both. In multilingual classrooms, e.g., code-switching can skillfully and consciously be used to gain and maintain learner attention. In many multilingual communities code mixing is used to the extent that we may speak of 'mixed codes'; especially among the youth who may use mixed code to create and maintain group identities. I also agree that code-mixing is often used as a strategy to overcome lexical gaps or to mark subtle differences in meaning. Additionally unconscious code mixing happens (in my experience especially in balanced bilinguals) because of a competition between and co-activation of the two languages.
Code switching is a tool which helps both the teacher and students. It facilitates students and improve teachers performance as a bilingual or multilingual.