Preheat the oven to 350°F on convection mode or 375°F on conventional mode.
Scrub, peel, and slice 4 medium russet potatoes (1 ½ to 2 pounds) into thin slices about ⅜ inch thick.
Chop 1 small onion and cut your ham into bite-size pieces.
In a medium saucepan over medium-high heat, melt 4 tablespoons of butter and add the chopped onion. Cook until translucent, which should take about 3-4 minutes.
Sprinkle 4 tablespoons of flour into the saucepan and mix well. Continue cooking and whisking for approximately 2 minutes, until the mixture turns slightly brown.
Slowly add 3 cups of milk to the saucepan while continuing to whisk. Whisk and cook until the sauce thickens well, which should take about 3-4 minutes. Add 1 teaspoon of salt and ½ teaspoon of black pepper during this step.
Butter a 9 by 13 baking dish to prepare it for the next steps.
Layer about ⅓ of the sliced potatoes in the prepared baking dish. Top with ⅓ of the ham, ½ cup of cheese, and ⅓ of the sauce. Repeat this step two more times, using a full cup of cheese on the top layer.
Cover the baking dish with aluminum foil.
Bake for 90 minutes, then uncover and continue cooking for another 20-25 minutes, until the dish turns nicely brown and bubbles.
Let the dish sit for about 10 minutes before serving.