That’s an excellent question and it’s one I’ve been pondering in this game. The answer to your second question is, I think, yes. There is probably a better, more definitive answer, but I think the opening “ended” at move seven when we both castled.
In trying to answer this question earlier in my life, I arbitrarily decided that the opening ended whenever a player moved the same piece twice without capturing. It’s more of a personal rule-of-thumb but it’s objective, and it’s worked for me. It also captures the idea that some openings “end” quickly and others drag on. (If someone mates on the 10th move, was the 5th move the middle game?)
glee will probably be able to provide a better answer, but in answer to the question I would ask why it is important to identify the middlegame? It’s just a convenient shorthand used in much chess literature to describe the bit between the opening and the endgame, both of which are somewhat easier to objectify. As a chessplayer, you don’t gain anything, IMHO, from identifying the middlegame starting. As SiXSwordS basically says, it will vary from game to game.
My answers to chrisk’s questions are therefore no, yes, and who cares? I’m sure some real expert will be along shortly to correct me.
I will add that I think it is important to try to identify the opening and the end game because you do need to shift gears. You may never find an objective way to say: Thus Begineth the Middlegame!, but there are so few hard and fast rules that having some guidelines (…in the opening: develop your pieces, control the center, castle or know why you are not castling…) is a good place to start.
I tell my pupil beginners that the opening lasts about 6-10 moves and they should try to develop pieces, control the centre and castle in that time.
After that comes the middlegame, where they should have plans and try to carry them out.
The transistion is possibly useful to such inexperienced players, but not so to others.
The opening to experienced players probably ends when one of them is out of ‘book’.
I’ve played the same 17 moves of ‘book’* myself a couple of times.
I’ve also won the same game in 7 moves**, even though it was still the ‘opening’.