I don't think most lawyers, doctors, and software engineers are "middle class". They might claim to be "upper middle class" to avoid being categorized as "upper class" as many wealthy people do.
These professions are a core of the middle class. Maybe some of the most successful could be called upper-middle class, if they also had a large inheritance?
But a regular software dev or a GP is the perfect representation of a middle class - having enough money for comfortable life, travel, owning a house, new car, leisure activities and having money for investments.
If one can’t afford these (all at the same time) - it is not middle class. Middle class is not a “median - average salary class”, by a long shot.
The most successful lawyers, doctors, and software engineers are upper class. High-earning lawyers make millions per year, and even moderately successful doctors in major cities make $500k+. I've heard doctors brag about making $800k, working part-time. The most successful software engineers make near or over a million.
Can you define "upper middle class" and "upper class" in a way that excludes all but "some of the most successful" doctors, lawyers, and software engineers? Because I sure can't.