I have a very different perspective that the other suggestions made here. Others seem to say that a group assignment shouldn't really be about cooperation and working together, but about dividing it up - externally. I think that the concern is about easing the grading process, but I would rather be a teacher than a grader.
In the real world that students will later face, both in education and in the workplace, they will be asked to actually cooperate in the work, not just divide it up. When divided up and someone fails to fulfill his or her part, the project as a whole may fail even though most "did their part". This is unacceptable and will leave most of the "group's" members frustrated.
It is also easy to demand that everyone is individually responsible for everything, which sounds good, but is unrealistic. Often in such divide work situation, the other students don't realize, or have any reason to suspect, that they have additional, major, last minute tasks to do.
The first thing you need to remember is that students need to be taught the things you want them to learn when they don't already do it naturally. You need to use some class/lab time to actually demonstrate group work and work sharing. You also need to monitor it either directly or via some sort of feedback mechanism with counseling.
The next thing you need to realize is that in a group, not everyone needs to participate in the same way - coding, for example. Organization is important. Research may be important. Easing interpersonal conflicts may be extremely important.
Next it is necessary to know that not everyone participates the same amount in each small time period, but may do so over time. One of the big ideas in group work is pay it forward. Make a lot of contributions early on so that if you cannot do so later you have still done your share and others won't disparage your contributions.
And of course, not everyone participates equally over time, either, and it is difficult to make it so. Instead you can use some form of "safe" peer evaluation of the members of the group so that you get insight into who the main contributors are. But don't be naive in this either. If all of the questions on your peer evaluation form are about, say, coding, then you are devaluing other sorts of contributions. I prefer to ask students to name one (or a few) key contributors to the group and to say why they were chosen. I also ask each student to specify their own personal contribution. Someone who does all the work him/herself isn't a contributor.
Group work should be done by a group. Don't neglect the social aspect of it. Work within your class framework to bring people together so that they actually have positive feelings for one another.
In a classroom situation learning is the main goal, not the completed project. The project itself can fail if the learning is good. This is different from the real world, of course, but the classroom should be a safer place to make mistakes, provided that the important lessons are still learned.
Note also, especially for a programming course, that even if some student didn't do much of the coding, it is still possible to assure that each student understand the whole work, not just their part. This again, isn't "real world," but is necessary to the educational process. This assurance can be gained in interviews, presentations, or quizzes, for example. This is a variation on the "everyone is responsible" rule, in fact. Everyone is responsible for knowing.
Finally, let me note something from the real world. Many Agile Software Development groups have a rule that no code can be committed to the code base if it was written by an individual, rather than a pair. Some programming is done by individuals, but only for experimental purposes to test out an idea. If the idea proves fruitful, the experimenter works with a partner to create the committable code.
The reason for this important policy is that any team doing real work wants a large enough Bus Factor so that if one or a few key people leave they don't take all of the knowledge of the project with them. This actually applies also to student team projects as some students do, in fact, leave a course in the middle of a project. The others must be able to carry on.