I recently upgraded to Yosemite, which allows you to send and receive iMessages, or Messages, from your computer, rather than your phone. While this is certainly a novel feature, it can be quite distracting and, unfortunately, the feature is enabled by default. After days of lost productivity as a result of receiving inane messages while programming, I decided to disable it. It's best to disable it from your computer so that you can still utilize iMessage's functionality within your iOS device.
tl;dr; Disable iMessage on your Mac without disabling it on your phone. This works for both Messages in MacOS and iMessage in OS X.