This paper presents an innovative educational approach to organizing the out-of-school teaching of programming in middle childhood. The proposed DGBL model includes three distinct educational phases, i.e. learning visual programming, programming and robotics, and programming and electronics. The research was carried out during the school years of 2017–2019. The study sample consists of 329 primary school students from K4 to K10 from the Lodzkie Voivodeship in Poland. The results were obtained from anonymous questionnaires completed by course participants. The answers confirm that the proposed approach helps children to learn the main concepts of computational thinking and programming. The described approach reinforces the essential idea in children that programming, engineering, mathematics and technology are intertwined in the modern world. Moreover, the approach combines and balances practical, methodological and pedagogical issues and is suitably integrated with out-of-school programming education to facilitate the teaching and learning process.