My castle was attacked everyday recently and it is a very good chance for me to experiment with several defensive formation.

That's the reason why I put a line of elite hoplites the front to take down weak units first, and allow stronger units next taken down by the line of self-detonating towsers.
Next are the ramparts and the arrow towers. Putting arrow towers right behind the rampart as the ramparts are extra strong in defense. When the enemy units take several rounds to destroy your ramparts, they had already taken up quite an amount of damage from the arrow towers and the archers.
Putting hoplites and self-detonating towers around your hero is important, as whether your hero survives determine the win or lose of the battle. These are the last line of defense, so that any enemy units approaching your hero should be taken down by the body guards.
This formation has proven effective for some time. It had an disadvantage though, is if your enemy is patient enough to give you consecutive attacks, your defense building will finally all broken down, and he can finally occupy your castle...
Do you have any good formation to suggest? If so, feel free to leave a comment.