Understand Their 'Why'
It easier to deal with a difficult boss when you are able to understand their 'prime motivations', that is, the reason they do what they do. The more you understand this, the more you will be able to manage your expectations, deliver the desired results and successfully deal with your difficult boss. Try to figure out what drives your boss; figure out his/her concerns, core values and priorities; try to know understand what he/she cares about; what frightens he/she; what kind of person is he/she; and how does he/she measures success.
Work Around Their Weaknesses
In trying to understand your boss, you'll gain some insight into his/her weaknesses. When you do, you then need to go a step further and learn to work around such weaknesses and as much as possible, try to make the best of it to favour your work. This because making your boss look bad or going to war with him/her might be very bad for you and damage your reputation. If your boss is disorganized, rather than complaining about it, try to keep things as organized as possible. If your boss is forgetful or slow to respond, ensure you find a way to document all interactions with him/her and continue with your work while you wait to hear back from him/her. Regardless of whatever weakness your boss has, you should settle down, think and try to find a way around it. You almost always will.
Be The Better Person
This will speak a lot for your reputation and do more for you than confronting your boss and letting his/her bad behaviour get to you. Avoid letting your boss's bad behaviour influence and dictate your own behaviour. As much as possible try to remain respectful and professional, in other words, take the high road. Refuse the temptation to slack off, lose interest or stop performing, all because your boss does so. This is because successfully handling a difficult boss positively sets you apart, and the truth is you never know who's watching or listening and who you're impressing with your resilience.
Adapt To Them But Never Cower
Yes, it's important to observe your boss's behavioural styles, preferences and pet peeves, and learn to adapt to them by finding ways to deal with them, but you are not to lose your sense of independence and allow your boss bully you and make you cower in fear. You must always stand firm, keep your head held high and refuse to let your boss push you around. Just make sure you do the best job you can, ask questions where you need to and try to understand and mitigate difficult situations, but never cower in fear to your boss or allow your boss make you lose your temper.
You Can Try To Talk To Them
Sometimes, your boss might not mean to be such a nightmare, he/she might not even know that they are doing anything wrong. Just remember that there is an option of voicing your concerns to your boss and engaging in a mature conversation about how the situation can be improved. Avoid being judgmental and assuming your boss can't take feedback or just doesn't care. The only thing you need to be mindful of here is the personality type of your boss, that is, how mature he/she is to handle being talked to and worked with to find ways to move forward with the situation.
If the situation with your boss is beyond bad and your boss's behaviour has become not only difficult but even abusive, it might be advisable to report to the management. However, you should try as much as possible to let this be the last resort after you've tried all else.