Compartmentalization (defence mechanism)

Compartmentalization is an unconscious psychological defense mechanism used to avoid cognitive dissonance, or the mental discomfort and anxiety caused by a person's having conflicting values, cognitions, emotions, beliefs, etc. within themselves. Compartmentalization allows these conflicting ideas to co-exist by inhibiting direct or explicit acknowledgement and interaction between separate compartmentalized self states.

According to Glen O. Gabbard, oftentimes, "people with a borderline level of organization […] have to compartmentalize people into 'all good' and 'all bad'", on the principle that "compartmentalizing experiences […] prevents conflict stemming from the incompatibility of the two polarized aspects of self or other". Often, "when the individual is confronted with the contradictions in behavior, thought, or affect, he/she regards the differences with bland denial or indifference".