Procedural Programming is a programming method which is used to create structured applications. Modular Elements or Modules are sections of code which execute a different function. Modular Elements run individually in each section of code, so when these modular elements are put together in a sequence, running one after another, they will create a structured program. Even though these sections of code work together, they do not rely on each other as some parts of the code may change another part. You can have a class to perform a large function but modularity is important as it takes the little steps from the large function and uses and manipulates the little steps.
Here we have the humanbeing class.
The code to the side shows the steps how to create a human being in java. You have to set some attributes to a person. In this case you set the Name, Sex,Origin,Height, Weight, Skin Colour and Age. All of these attributes have been set to have a parameter.
Even though we have set these variables to have a certain parameter, we can also use these variables in another class to do something else.
We have set the varible sName to 'Nathan'. We can use the setName function which makes teh sName parameter,'Nathan', to equal sNewName. So even though we used a function called setName, we could use this function to do something else.
Modularity is not just incorporated in programming languages. Modularity can also be used to show the steps in the real world. For example, Modularity can be used to show the steps of going to school. You can say that the thing you are doing is going to school. However, the actual things that you are completing are the steps which take you there. The following steps show you how you might get to school;
- You need to wake up/get out of bed
- You need to eat your breakfast
- You need to wash yourself
- You need to get dressed
- You need to gather your school belongings
- You need to leave the house
- You need to travel to school
- You have now got to school.
No comments:
Post a Comment