DJ’s certainly know a lot about loops as their music is made up of them. A loop is a pattern that repeats itself under certain conditions. DJs take and put together music loops of different instruments, or even full songs, whatever makes the audience happy. Of course, looping the same thing over and over can be pretty boring after a while. So eventually, the DJ has to break the loop to keep everyone dancing.
It's the same in programming, where loops are instructions that are repeated, just like the music beats. Just imagine you needed a robot to do something 100 times, what would you do, you would copy and paste the code 100 times, this would be so time consuming, and the long streams of code would make the robot respond very slowly. Or instead, you could instruct the computer to repeat a bit of code until the time comes that you need it to stop. loops repeat actions, so you don't have to keep writing out instruction.
An industrial robot will make its product as long as there is the material to do so. A computer will calculate the same sums until you instruct it to stop. When it comes to stopping a loop. A DJ can trust his experience or gut feeling to know when to stop a loop. Not so simple for a robot who doesn't have a sense of judgment or freedom of choice. So a programmer needs to enter clear instructions into the code.
These are called conditional statements. When these instructions yield the correct outcome, the robot stops repeating itself. A conditional statement consists of two parts, a decision and a conclusion. If the audience stops dancing, then the DJ plays something else. In this way, a computer or robot can break a loop. It can also break a loop by itself if it does not understand a given command. Loops are very handy tools that are used to avoid writing the same codes over and over again. To jump out of a loop before it is completed.
A break loop can be used to stop the loop prematurely. If factory life is becoming too boring, then the robot should break the loop and do a bit of dancing