This is probably objectively the best approach one can take towards the dilemma of having expectations. It's a compromise between mindless optimism and unappealing pessimism. As a pessimist myself, this is the attitude I am working towards - cautious optimism.
The idea is you prepare yourself emotionally for the worst outcomes by accepting them or being aware of them as possibilities, but at the same time strive to attain the best outcome and not lose hope of having positive results. This does a number of things. One, it "insures" you for the negative possibilities, but at the same time, you will still come off as a positive person and be generally happy, mainly because that's what you'll be promoting as a whole from the inside. It's just that deep down you're aware of the worst possibilities instead of mindlessly assuming that they aren't possible, which is in most cases is overly optimistic. This also allows you to release the tension of worry inside yourself by accepting negative outcomes as possibilities, so you can then comfortably maintain hope within yourself without fear of things not going your way,
The problem with being overly optimistic is you set yourself up for more severe disappointments. And there is some merit to being realistic. Some people may not be able to just be solely optimistic either as deep down they'll still be fearful of failure or negative outcomes.
But you also don't want to be passively always expecting the worst outcome to take place because then you'll lose motivation, hope, happiness, and come off as bitter and unhappy which can make your life miserable and unfortunately, repel others.
In my opinion, the best compromise is "cautious optimism". Maintain hope for the best outcomes and push yourself to attain them. Some of this has to do with being your own cheerleader, which I discussed in my last myTake: http://www.girlsaskguys.com/guys-behavior/a22467-be-your-biggest-cheerleader-jad-t-jones. And the majority of your thoughts and emotions should be based upon this hope. However, deep down remain aware and more importantly accept the possibility of negative outcomes or any risk involved with whatever you're pursuing, so as to insure yourself emotionally should things not go your way.