Weight control: how to maintain a stable weight with a sedentary job if you visit the gym only two to three times a week?
Regular gym workouts are important for muscle tone, but they make up only a small fraction of your daily energy expenditure. If the rest of the time you spend in front of a monitor, your general level of non-exercise activity drops to a minimum, which leads to slow weight gain even with regular gym visits.
To fix this, implement the concept of increasing non-exercise activity, known as NEAT. These are all the movements you make outside of workouts: walking, cleaning, taking the stairs. Set up a fitness tracker with a reminder to stretch every hour and take short walks around the apartment or office while heavy code compiles or tests are running.
Also, review your nutritional intake on workout days and rest days. On days when you sit at the computer without physical exertion, the caloric content of your diet should be slightly lower, as the body expends less energy. On workout days, you can allow yourself a little more complex carbohydrates to restore your strength.