I haven't read Harry Potter, but my girlfriend has. I know enough about the books to talk about the confused mess that is the Hogwarts housing system.
The children at the centre of the story find out that they have magic abilities. What they go on to do is become tangled up in rivalries, group games, and relationship drama. What they focus on less is developing their magic abilities to serve humanity.
The cause of this problem appears to be the fact that students at this wizardry school sleep and play in separate quarters. At the beginning of their education, they are categorised by mental traits of some kind, surrounding them with similar pupils. Apparently, everyone who attends this school is engaged in a rivalry, if not outright fight, against another quarter.
The solution is obvious: Don't create groups unnecessarily and, if you have to, assign pupils randomly. In the case of Hogwarts, why not just assign age groups to dorms? A minor rivalry will remain because smaller groups always form inside an age group, but it would ease the tension. Natural group building allows for more friendship and common cause than predetermined castes do.
I know that fiction needs to be interesting, and therefore tension is required, but I'm sure that a well-functioning wizardry school could prepare kids for even more compelling adventures than Harry, Ron, and Hermione are having at Hogwarts, supported by all the friends who should be on their side.