DEV Community

Milena
Milena

Posted on

1

Control structures

Lets talk about the advantages and disadvantages of each looping structure...

I could be wrong, but I wouldn't use the word "disadvantage" in concepts like loops. We have different types because they can all work in different cases, but sometimes they are not suitable for it. So it is important to have a lot of knowledge of this concept because it makes it easier for us to understand, simplifies the code, and becomes a more fluid program.

Now, citing advantages of loops:

while: will repeat the proposed block of code, until the condition is true

do-while: will do something while a condition is true. I see people calling it a "control repeat structure"

for: already in this loop, we have a repetition structure with iteration, where we iterate a defined value in each repetition, reaching a limit.

I confess that I always get confused with repeat structures and, sometimes, with conditionals. But they are very important concepts, as I mentioned before.

What are your thoughts?

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay