Code-switching: refers to linguistic behavior of a bilingual speaker who subconsciously shifts from speaking one variety to another variety, usually in response to factors associated with the social situation
Code-mixing: the process whereby speakers indulge in code-switching between languages of such rapidity and density, even within sentences and phrases, that it is not really possible to say at any given time which language they are speaking.
Sociolinguistic explanations for this behavior normally concentrate on the possibility, through using code-mixing as a strategy, of projecting two identities at once, for example that of a modern, sophisticated, educated person and that of a loyal, local patriot
diglossia: refers to a situation in which two dialects or languages are used by a single language community and one variety is considered more prestigious than the other