Degrees of freedom can be defined as the number of independent ways in which the space configuration of a mechanical system may change.
Suppose I place an ant on a table with the restriction that the ant can move only through a tube on a line along x-axis. Then the ant will have only one degree of freedom in three dimensional space.
However if I allow the ant to move freely on the table, then it can be at any point on the surface at any time $t$ and it can change its $x$ as well as $y$ coordinate as time evolves. Then one can say the ant has two degrees of freedom. Thus the number of independent coordinates does define the configuration, and the degree of freedom is the count of that number.
However if I place an ant which has wings, then it can travel independently in $x$, $y$ and $z$ direction, and its position can be located at a point $P(x,y,z,t)$ at any instant, so now it has three degrees of freedom as it can be located by three independent variables.
To sum up:
A material particle confined to a line in space can be displaced only along the line, and therefore has one degree of freedom.
A particle confined to a surface can be displaced in two perpendicular directions and accordingly has two degrees of freedom.
A free particle in physical space has three degrees of freedom corresponding to three possible perpendicular displacements.
Now suppose I have two ants with wings then this system has three coordinate each and can be located by six independent variables. In this case, the degree of freedom = no. of particles x3 = 3N degree of freedom.
A system composed of two free particles has six degrees of freedom, and one composed of $N$ free particles has $3N$ degrees.
If a system of two particles is subject to a requirement that the particles remain a constant distance apart, the number of degrees of freedom becomes five.
Imagine those two ants bound by a string such that their distance apart is constant $L$ . An equation of the type $F(x,y,z,x',y',z',t) =L$ governing this condition will hold. This equation is called equation of constraint and each constraint can reduce the degrees of freedom by one. Therefore the constraint system of $N$ particles will have
a no. of degrees of freedom = $3N -m$, where $m is the number of constraining equations operating on the system.
Any requirement which diminishes by one the degrees of freedom of a system is called a holonomic constraint.
Each such constraint is expressible by an equation of condition which relates the system's coordinates to a constant, and may also involve the time.
When applied to systems of particles, a holonomic constraint frequently has the geometrical significance of confining a particle to a specified surface, which may be time-dependent.
Constraints are defined as restrictions on the natural degrees of freedom of a system.
If $n$ and $k$ are the numbers of the natural and actual degrees of freedom, the difference $n − k$ is the number of constraints.
A pendulum ball is a body having 3 degrees of freedom. When one hangs the bob by a string of length $l$, then it can only move in a plane with the condition that $x^2 + y^2 = l^2$ . This is one constraining equation, and another one is that z = constant, or $z-c =0$. Now the bob has only one degree of freedom and can be defined with only one coordinate, say $\theta$, the angle made by the string with the vertical.
So the simple pendulum has only one degree of freedom.
The advantage of the above description is that one can go to an independent set of coordinates to describe the motion of the system. Such sets are called generalized coordinates.
Is the concept useful in building objects or theoretical work? Perhaps something Lagrange invented ?? Maybe a useful problem solved by this concept would help ?
The new description in terms of 'generalised coordinates' and momenta leads to further development in Lagrangian mechanics by using the 'principle of virtual work' and developing a set of equations of motion in generalised coordinates and velocities, which are an independent set and free from the constraining forces, in terms of the evolution of kinetic and potential energies only.
One can check: