This is an unofficial, but totally accurate guide to the 3 main types of unit. This is going to range depending on side-effects and/or battle randomness.
All units have advantages and disadvantages. This guide will not be a 100% guarantee though. This system is a sort of rock-paper-scissors. I have done tests multiple times and this was the most frequent outcome (when they don't miss) This image shows the middle as assault, the left as a ranged and right as defense.
The assault class. This will usually be in the front lines, and will be trying to smack, stab, slice or even skewer your enemies. They are usually low health-high damage, and tend to die a lot (red shirts). They will try to kill the enemy before the enemy kills them instead of tanking the damage. Assault class includes the squire, clubber, sarissa and farmers. They will usually die to a ranged enemy and will usually beat the defense.
Defense. Usually on the front lines too, ahead of the assault. They will tank lots of damage (usually from the front). They die, but not as much as your assault. They protect their allies and can take some arrows. Defense units include shieldbearers, protectors, haybalers and blunderbusses. They beat ranged and get annihilated by assault.
Ranged. The cowardly nerds who hide like wimps and twang their fancy bowstrings. These guys are absolutely defenceless and at close range completely hopeless, for they become actual stormtroopers. Some ranged units are way overpowered for their attacks are unblockable like the musketeer, bomb thrower or stoner. I count ranged units as ones that fire projectiles. Ranged units include archers, spearthrowers, ninjas and effect archers (ice, fire etc.) They defeat assault and die to defense.
Some units fit into none of these categories. They could be ranged but without a projectile, or be AOE melee, or be summoners, or be support units. They include healers/cheerleaders, bone-mages, mammoths and snake-archers/scarecrows.
Cross Classes (or Colloids)
some classes will actually cross into other classes. This means, for example the samurai can block projectiles and also is an assault class. Colloids include brawlers, hoplites, kings and pirate captains.