Get out a 2 or 3 quart saucepan. In it combine the sugar and cornstarch. Gradually stir in the milk. I use a whisk to make sure the cornstarch doesn’t lump. If the milk is cold, so much the better, cornstarch dissolves most completely in cold liquids. Heat the pudding over medium heat. You will have to stir it a lot. Maybe not constantly, but darn close to it. Keep stirring it until it boils. Then count to 60, so that it boils for a full minute. The pudding will thicken up considerably as it cooks.
Next crack your egg into a cereal bowl. Ladle a bit of the hot pudding into the bowl with the egg. Stir the egg up pretty fast (so it doesn’t cook in the hot pudding) until it is well incorporated. Then scrape this egg/pudding mixture back into the saucepan. Whisk it up smooth. Bring the pudding back to a boil and then remove it from the stove. Drop in the margarine and measure in the vanilla. Stir the margarine in until it melts.