Roald Dahl took inspiration for his book from the real life espionage that took place between candy makers in Europe. As candy recipes are not patentable, candy firms are extremely secretive. Cadbury and Rowntree, the two largest British candy companies at the time of Dahl’s childhood, sent so many informers to work in competitors' factories that their spying became fabled.
Charlie and the Chocolate Factory is about a bizarre and whimsical candy maker who offers a small group of children a rare tour of his wondrous candy factory. Strange and magical misfortunes befall the children because of their bad behavior until finally only one honest child remains, having not given the factory’s secrets away to devious Slugworth, and the factory and happy ending are his. In real life, the candy companies had to employ detectives to keep track of workers, and only a select, trusted few knew how certain processes worked and how recipes were put together.