Before starting, I want to make it clear that this is the way I upgraded my buildings/troops, and you don't have to do everything exactly this way. I just found this order of upgrades to be highly successful for myself.
This guide will have two parts.
Part 1) Order of building upgrades/order of building new buildings
Part 2) Order of troop upgrades
1) The first thing I do when reaching a new TH level is to build the buildings that take no time at all, e.g. traps and walls. I want to build ALL the new buildings available ASAP, regardless of their level, so I spend the first few days or so (it's easier with 5 builders) building every single new building possible. This may seem like it causes an endless wave of upgrades, but if you follow a specific order like I do, it's not so bad.
I try to get all my walls to level 5 within the first day just so they can be at least SOME use. Doing 50 walls to level 6 or higher, then, is too expensive, because you need the gold for important Defenses.
After doing some walls and traps, you should be around 1 million gold down from your starting point, which by the way should be the max amount possible. The next step is to build any 5-minute/15-minute structures available. The reason I do this next is so I can use the time to find an abandoned base to farm. Always keep on training a barch/any farming army you use while building these new buildings. As long as you're in around Silver 1 to Gold 2, you should find an abandoned base within 10 minutes. Your basic Defenses should be complete by now.
At this point, upgrade your Lab ASAP. You want higher leveled troops so you can increase attack power, gaining more loot, more trophies, and more war stars. The sooner you upgrade your Lab, the better.
After your lab, you can build one or two of the new, very important Defenses, such as a Wizard Tower, AD, or a Mortar. Teslas can wait a bit.
Now, you should have one or two builders left, with one working on the Lab, and two or three working on important Defenses, which should be done in half a day or so.
Use the remaining builder to do a quick upgrade on a new Defense, like a Cannon or Archer Tower. Always always farm when you have no builders left or are running out of a resource. This way, you almost never run out of troops. On a good day of farming, you can farm around 2 million in 2 hours (like I did when I hit TH8. OMG) This method of farming when waiting for 1-hour/2-hour upgrades, and whenever I had no builders remaining, got my Gold Grab to 137 million as a TH7.
Once you have no Defense 2-hour or less upgrades left, you can start building a Tesla or X-Bow, if you have enough Gold left. (which you should if you followed my farming instructions)
On the next day, your 3 major defenses have been finished building. You want to continuously upgrade them until they are on par with your current level. DO NOT upgrade already existing Defenses to the highest level for your new TH level JUST YET. Wait until every new building you have is on par.
Your next few days should be spent upgrading major defenses to par level, building all new buildings, e.g. Dark Barracks or Mines/Pumps. By now your Lab should be done upgrading, and we'll talk about troop upgrades in the next section. The Lab being done, that frees up another Builder. Use this builder to work on the minor Defenses. Don't touch those level 5 walls yet.
Builder 1: Archer Tower to next low level
Builder 2: AD to next low level
Builder 3: Mortar to next low level
Builder 4: Wizard Tower to next low level
Builder 5: Tesla
Fast forward a week or two. You've been farming to keep all storages maxed. All new buildings are up to par level. Now, since you have 5 builders, keep one or two, depending on your preference and available elixir, on your Army Camps. Though elixir upgrades seem unimportant right now, Army Camps are important because you want to max out your army potential to, like I said, increase loot gained, trophies, and war stars. If you missed a full level 12 collector in an abandoned base because you didn't have any archers or goblins left, wouldn't it have been awesome to have 20 extra camp space to get 100k more loot? This is why I always semi-prioritize Army Camps as a fairly new TH-X.
Three builders left. What do you spend them on? I see too many people making the mistake up upgrading all three or four ADs at once. Don't do this because any air raider will see you and all your loot and take the chance to 3 star you because all your ADs were down. At this point, I would suggest using a builder from the remaining 3 each on a DIFFERENT important defense, like this:
Builder 1: Army Camp
Builder 2: Army Camp
Builder 3: Mortar
Builder 4: Wizard Tower
Builder 5: Air Defense
At this point, when your gold is capped out from barching abandoned bases repeatedly during spare time, you should feel free to work on those level 5 walls. You can probably afford to upgrade around 5 at a time.
Fast forward a month. About half of your defenses are one level higher than max for your previous TH. All your walls are level 7 (or you have level 8 walls from TH8) At this point, all Army Camps should be maxed, and your storages should still be capped if you are a good farmer. It is now safe to start upgrading new X-Bows, upgrading Cannons/Archer Towers to level 9, 10, or 11, depending on your TH. Your major Defenses should all be close to maxed for your TH.
Builder 1: Archer Tower
Builder 2: Archer Tower
Builder 3: Cannon
Builder 4: Cannon
Builder 5: Dark Barracks
Fast forward another month and a half. Every defense is now maxed. NOW is the time to start grinding out walls while doing elixir upgrades. Farm, farm, farm, Gold is the place to be if you are TH9, TH8s can afford Silver 1 or Gold 3. You should be hauling in about 2 million of each resource every day if you are a good farmer like me. At this point, you can start doing more elixir upgrades and trap upgrades, while always leaving one X-Bow upgrading.
Builder 1: X-Bow
Builder 2: Bomb
Builder 3: Dark Barracks
Builder 4: Air Bomb
Builder 5: Open for walls and removing clutter
The next month should be pretty generic. Keep 1 builder on X-Bows, rest on elixir upgrades and traps. Traps are often underestimated; their true power is hidden until you really know how to use them. If they are well-placed, they can wipe out a good portion of an army.
Fast forward another month and a half. Now is the time to check your progress. Your defenses should be maxed, your traps should be close to maxed, your walls should all be level 8. Your army should be close to maxed. Now decide if you want to grind out your walls to 9 or 10, or if you want to upgrade your TH. Either way is fine. If you grind your walls, do just that, while keeping the troop upgrades going until your troops are maxed. If you upgrade your TH, take the time while the TH is upgrading to upgrade another troop and do a few walls, but always leave enough gold or elixir left to cap your storages once you reach your new TH. As long as you have a good farming base, you should be losing at most 200k loot per enemy attack, which isn't much considering you can farm at least 350k every farming raid.
Part 2) Troop upgrades
Once your laboratory is done, upgrade your Archers. These are the mot versatile troop you have, and you will be using them a hecka lot for farming.
This section will just be a list of what to upgrade in order; there is no real strategy unlike your building upgrades.
-Choose: if you are farming heavy, do Barbarians, Minions, or Giants. If you are war oriented, do Dragons. If you like trophies and don't mind a trophy attack once every so often, do your Loons.
-Personally, I like Looning a lot, so I do Loons after Giants.
-Wizards. These are your firepower for war attacks, and admit it, you probably sneak in one or two of these while farming.
After this, it really is of your choice. Goblins usually wait; I would do Wall Breakers next. Nothing more frustrating than wasting a ton of Wall Breakers on a compartment with one full Mine in it. Why not just drop one or two and get the job done? When people ask what to upgrade next, I always tell them to upgrade the next thing they use most. Don't worry about cost, if you are a good farmer you will have near full storages by the end of every day.
Remember, ALWAYS use BAM or Barch to farm while waiting for upgrades. Other armies, like Chief Pat's Ultimate Farming, are effective but slow to train. Barch/BAM is very cost effective, cheap, and has a high rate of return. Don't go for inside loot; go for abandoned bases with 300k loot or more. Spells are optional, but I usually bring them if I can. I bring lightning spells with me to help zap full storages if I see them (yes, being a jag is okay here), or full mines/pumps that I cannot reach inside the base. Zapping full collectors will always return more than the original cost as long as the collector is level 9 or higher. Or, dropping 2 lightning spells to take out a mortar that would otherwise wreck you whole army is worth it because you're gaining 300k+ from the attack anyway, and Lightning spells don't cost that much.
Bring a heal spell if you want to keep your troops alive to reach a storage or two, but that really is up to you.
And another word of advice--don't trophy push until you are maxed. You need need need, did I say need that elixir for expensive trophy armies. You can't afford to be doing elixir upgrades while pushing. As for Gold and DE, the more you have the better; at TH8, when you reach masters, it's better to leave Gold and DE outside along with your TH so you get sniped and people take free loot, instead of them 3 starring you in order to take that loot.
Hope this guide helped some of you, and don't forget to leave feedback so I can be reinforced on the idea that I suck at writing guides xD