My #2 rule for preventing weight gain is simple. Do not keep ready-made cookies or cake in your cupboard.
It's too easy to grab a handful as you sneak off to the TV or, in my case, to my computer. Instead, keep bananas, peaches, plums, something sweet but healthy on the ready.
If I want cookies...really, really, want them...I have to make them. From scratch. (I do have mixes for when the kids have friends over. But even that is better than ready-made.) This way a) I have to have time to make them and b) they don't have all those chemicals and preservatives that my body doesn't need.
When you don't have time to make the cookies, or don't feel like getting out all the ingredients and mixing the dough...not to mention cleaning everything up afterward...you don't eat the cookies. If the craving won't go away, you make them and enjoy them. Go ahead. Everything in moderation. Just be sure there are plenty of people around who will eat whatever cookies are left over. Do not leave them lying around or you will eat them for days. 500 calories at a time. Don't say I didn't warn you.
At any rate, keep fresh fruit on hand, which often keeps cravings for sweets at bay, and for God's sake, get rid of those packaged cookies, Twinkies, Little Debbie snacks, etc. They aren't doing you any good. If you need a cookie, really need one (and if you're like me, you do), go to the trouble to make them.
It will make a huge difference in your diet.