Good morning everybody! This article is Part 2 of "Learn Ruby Fastest from What You Want to Do".
In this series of articles, you will understand the basics of Ruby while moving your hands through "creating an original program", and actively "let's output!"
Of course, input is also important. But more important than that.
This time, I was planning to explain how to decompose the function based on the flowchart (like figure) mentioned in the first article, but before that, I will explain how to transcribe the flowchart (wind).
This article is aimed at people who are "beginners in programming" and "want to make something!". This is a serialized article, so if you haven't read the first article yet, please read this first.
In this article, you will learn the following knowledge about creating flowcharts (like) transcribed in the first article.
--Structured programming
Understanding and applying this knowledge should make the complex process flow easier to read and understand. It's a short content, but please try to proceed with a tea break from time to time.
First, what is structured programming?
"Structured programming is the idea of dividing a program into functional unit parts and forming the whole by combining them." (Kitami, 2020, p.539)
In structured programming, programming is basically performed using only the following three control structures.
--Sequential structure (processes are executed in order from the top) --Selection structure (branch according to some condition and execute either process) --Repeat structure (Repeat a certain process until a certain condition is satisfied)
Now that you understand the three control structures of structured programming, let's verbalize the flow of the game. This time, I will write down the general flow by referring to the game "Ah, peel, whip!".
Game start ⇨ User up / down / left / right selection ⇨ Computer up / down / left / right selection ⇨ User win / loss ⇨ Continue ⇨ Game end
If you apply the written rough flow to the control structure explained above, ... Don!
It is a flowchart that combines a sequential structure, a selection structure, and a repeating structure! In this game, the result is a combination of three structures, but depending on the content, there should be only one or a combination of two.
How was that? This time, the content was quite short.
In this article, I learned the following:
--Structured programming --Sequential structure --Selection structure --Repeating structure --Verbalization of game flow
If you can understand the contents of this time, there should be more variations in flowchart creation!
In the next article, I'll talk about "functional decomposition" (this time).
I want to learn Ruby from what I want to do! If you are a reader, please continue reading the next and subsequent articles.
Thank you for watching until the end (^-^) /
--Kitami-style illustration IT school basic information engineer