Of late, I've had the privilege of working with a developer with much more experience than me. Of course, being a junior developer means that pretty much everyone has more experience than me. That actually works out in my favor, because it gives me lots of opportunity to learn. The person I've been working with lately, however, has much more experience than me.
Working with someone with more experience than you provides some really great opportunities to improve yourself as a programmer. The first benefit is probably the most obvious one: You'll learn programming and productivity shortcuts that the senior developer has already figured out. These are little nuggets of wisdom that are a result of the senior developer's years spent doing some of the more repetitive programming tasks. For instance, you might learn a handy keyboard shortcut or code snippet that saves time. These are things that while not earth-shattering, can add a lot of convenience to your life.
The second benefit goes a little deeper conceptually than the first: Exposure to different problem-solving techniques and general design methodologies. Watching someone else solve problems or design a software solution can give you tremendous insight into other ways of thinking. It can also help you identify gaps in your own knowledge and areas where your skills need improving. While watching others solve problems, I'm fascinated by watching them unravel the problem, formulate a solution, then make small adjustments here and there. Once the encounter finishes, I'll often apply the situation to myself by asking two questions: What part of my normal problem-solving methodology is much less efficient than what I just saw, and what part of my normal methodology could have improved upon the solution? By asking these questions, I try to identify my strengths and weaknesses.
A third big opportunity for improvement when working with a more experienced developer is the advice and guidance that he or she can provide. My main mission at my job is twofold: To always be adding value to the company and to constantly be improving. Like all developers, I can get pretty wrapped up in whatever I'm working on. Sometimes I can become so absorbed in what I'm doing that I can't see the forest for the trees, and having that objective guidance from someone who's made similar mistakes really helps me get rid of that tunnel vision. That applies not only to a specific solution, but also to my proficiency in general.
Note that working with someone who knows more than you requires a quality that some developers don't possess in large quantities: Humility. You have to be humble enough to realize that you don't know everything and that other people can have more insight into development-related problems than you. While this presents no problem for most of us, we all know those programmers that wouldn't take advice from another developer if their lives depended on it.