Ryoukai, O4s are Lieutenant Commanders, and fill the Department Head level positions in many commands, working directly for the XO and CO. These officers generally have 11-12 years in the Navy, and are the upper management that help to carry out the policies that a CO is implementing in their command. By that point in time, the O4 has made the decision to make a career of it, and go for 20 years at least until retirement, so for the most part they are very career conscious, also, depending on the command and quotas/billets, there are a finite number of them competing for a good fitness report and recommendation for command heading out the door. As mentioned by zab and gatordev, the composition of that group has an effect on the command. How much infighting are the O4s doing to jockey for that #1 slot, and the leadership the front office has in handling them. For the P3 community (pilots), we unfortunately are faced with the left overs and officers that decided not to get out for better $$ working for the airlines. The lure of $$ pulled some of the best out, and those that stayed behind did not have as much competition. I am not saying that all O4s are bad, but I have seen quite a few that made me wonder how they ever made it to that level. An ongoing trend for the hinge in question is to attribute all the successes of his JOs in his department to their foresight, and then when the JO makes a mistake to blame them and wash their hands of it... Ah, the joy of getting sold out by two O4s at planeside in front of the CO and your crew, when the O4s in question didn't have a clue what report the skipper was looking for, but I digress.
On the other hand, I have been fortunate to encounter a string of O4s that took pride in their position, and mentorship towards junior officers, the way it should be. Looking out for your career, giving advice when requested, involving you in useful projects that stress your abilities, and back you up a 100% when you succeed or fail, all the while promoting you to the front office.
As gatordev mentioned, the weaker O4s have a tendency towards ruling your life by email and meetings, wanting numerous "TPS Reports" (for you office space fans), and to come in on saturday.... that way they can "quantify" to the front office, gee, look what MY guys are doing. I worked on a BOMBEX brief for a week, only to find out in the end that no one was going to see it....
It all comes down to the front office, and the leadership of your CO and XO, as bunk mentioned. They limit the degree the O4s get away with the "random tasking" factor, and beat them up appropriately in the dept head meetings. On the flip side, a good front office also empowers the JOs to go out and get the job done. I think that I have been fortunate in having a front office that you would follow anywhere.
As for my complaints about the military, well, I really don't have anything to bitch about. I have it really good in the P3 community, and I know it, since I have also seen the other side as enlisted onboard submarines. As zab mentioned.... FIVE hour preflights, and switching to your 3rd plane for the day are no fun, and an aging aircraft that breaks down more frequently, and is definitely a leadership challenge when you have to motivate your crew to go that extra mile to make the flight and mission happen.
Deployments have been hard, but it is what I signed up to do, and the last two I have been on have been the most rewarding in terms of mission accomplishment.