Struktur Level Program

50 %
50 %
Information about Struktur Level Program
Technology

Published on October 24, 2008

Author: dimarahin

Source: slideshare.net

Dimara Kusuma Hakim, ST. Struktur level program

Struktur Program

Designing a Program Identify what you want the program to do. The first step is fairly easy (because it’s always easy to tell someone else what to do). Tell the computer, step by step, how to do what you want it to do. The second (and much harder) step is to figure out how to achieve your desired result. This process of telling the computer what to do, step by step, is what programming is really all about regardless of the programming language you ultimately use.

Identify what you want the program to do. The first step is fairly easy (because it’s always easy to tell someone else what to do).

Tell the computer, step by step, how to do what you want it to do. The second (and much harder) step is to figure out how to achieve your desired result. This process of telling the computer what to do, step by step, is what programming is really all about regardless of the programming language you ultimately use.

Spaghetti programming ? 

The three parts of every program Sequential instructions Branching instructions Looping instructions

Sequential instructions

Branching instructions

Looping instructions

Sequential instructions Sequential simply means that the program follows instructions, one after another, from the first instruction at the top to the last instruction at the bottom

Sequential simply means that the program follows instructions, one after another, from the first instruction at the top to the last instruction at the bottom

Every program organizes most of its instructions sequentially, but few programs organize all of their instructions sequentially. The reason is that if a program organizes all of its instructions sequentially, the program can run through its instructions exactly once before it stops.

Every program organizes most of its instructions sequentially, but few programs organize all of their instructions sequentially. The reason is that if a program organizes all of its instructions sequentially, the program can run through its instructions exactly once before it stops.

Such a program might be handy for creating simple programs that print I am a useless program on-screen, but such programs ignore any data they might receive from the user. No matter how many times you press a key or click the mouse, running the following two-line code always displays : I am a useless program Because this is all I can do Writeln( ‘ I am a useless program ’); Writeln( ‘ Because this is all I can do ‘);

Such a program might be handy for creating simple programs that print I am a useless program on-screen, but such programs ignore any data they might receive from the user. No matter how many times you press a key or click the mouse, running the following two-line code always displays : I am a useless program

Because this is all I can do

Branching instructions To make programs more useful and responsive, they need to accept and react to outside data. When you play a video game and a monster appears on-screen, the game needs to react differently if you shoot and kill the monster or if the monster eats and kills you. If you shoot and kill the monster, the game lets you keep playing. If the monster kills and eats you, the game displays the words GAME OVER on-screen.

To make programs more useful and responsive, they need to accept and react to outside data.

When you play a video game and a monster appears on-screen, the game needs to react differently if you shoot and kill the monster or if the monster eats and kills you. If you shoot and kill the monster, the game lets you keep playing. If the monster kills and eats you, the game displays the words GAME OVER on-screen.

Branching…

Branching instructions simply tell the computer to run different instructions depending on the value of certain data. When you delete a file, many programs ask, Do you really want to delete the file?. If you click the Yes button, the program follows the instructions to delete the file. If you click the No button, the program follows a different set of instructions,

Branching instructions simply tell the computer to run different instructions depending on the value of certain data. When you delete a file, many programs ask, Do you really want to delete the file?. If you click the Yes button, the program follows the instructions to delete the file. If you click the No button, the program follows a different set of instructions,

Write(‘ Do you want to delete the file? (Y or N) ’); Read(answer); IF answer = ‘Y’ THEN writeln (‘Deleting file’ ) ELSE writeln (‘File NOT deleted’);

Looping instructions No matter how many sequential or branching instructions a program has, it runs only once before stopping. To keep a program running until you want it to stop, you need to use looping instructions.

No matter how many sequential or branching instructions a program has, it runs only once before stopping. To keep a program running until you want it to stop, you need to use looping instructions.

Looping instructions make the computer repeat one or more instructions. In a video game, a loop might keep running all the instructions in the program until the game character dies. Then the loop stops and the program (and game) ends

Looping instructions make the computer repeat one or more instructions.

In a video game, a loop might keep running all the instructions in the program until the game character dies. Then the loop stops and the program (and game) ends

FOR i = 1 TO 5 DO Write(i); 1 2 3 4 5

The building blocks of programming

Subprogram

Dividing and Conquering with Subprograms In general, the more complicated the task, the larger your program needs to be. The larger your program gets, the harder it can be to read and understand. Reading a large program can be like trying to read a long novel printed on a scroll rather than on separate pages.

In general, the more complicated the task, the larger your program needs to be.

The larger your program gets, the harder it can be to read and understand.

Reading a large program can be like trying to read a long novel printed on a scroll rather than on separate pages.

Just as books divide large text into separate pages for easy reading, so do programmers divide large programs into separate parts. When you divide a large program into smaller parts, those smaller parts are called subprograms .

Just as books divide large text into separate pages for easy reading,

so do programmers divide large programs into separate parts.

When you divide a large program into smaller parts, those smaller parts are called subprograms .

Rather than clutter your main program with a long list of instructions, subprograms let you group related instructions in one place, making your main program smaller and easier to read and understand.

Rather than clutter your main program with a long list of instructions,

subprograms let you group related instructions in one place,

making your main program smaller and easier to read and understand.

 

procedure GoPassword; // SUB PROGRAM var password : string; Begin WHILE password <> 'open' Do begin Writeln('Enter your password'); read(password); IF password = 'open'THEN Writeln( 'Welcome to the FBI''s secret computer network') ELSE Writeln('TRY AGAIN'); end; end; BEGIN // MAIN PROGRAM GoPassword; readln; END.

By dividing a single program into subprograms, you gain the following advantages : Subprograms divide a large program into smaller parts to make reading and writing large programs easier. Subprograms isolate related program instructions . So if you need to modify a program later, you just need to modify a subprogram, much like removing a defective brick from a wall and putting in a better one

By dividing a single program into subprograms, you gain the following advantages :

Subprograms divide a large program into smaller parts to make reading and writing large programs easier.

Subprograms isolate related program instructions . So if you need to modify a program later, you just need to modify a subprogram, much like removing a defective brick from a wall and putting in a better one

Creating libraries of subprograms When you divide a large program into a bunch of smaller programs, you’re doing nothing more than rearranging and organizing your instructions. Unfortunately, a large program written as one long list of instructions is barely any smaller than the same large program divided into multiple subprograms. Because the larger a program gets, the harder it can be to understand, programmers found a way to take subprograms out of the main program file and store them in separate files .

When you divide a large program into a bunch of smaller programs, you’re doing nothing more than rearranging and organizing your instructions.

Unfortunately, a large program written as one long list of instructions is barely any smaller than the same large program divided into multiple subprograms.

Because the larger a program gets, the harder it can be to understand, programmers found a way to take subprograms out of the main program file and store them in separate files .

 

By storing subprograms in separate files, reading and understanding your program is much simpler. Instead of scrolling through one massive file that contains your main program and all of its subprograms, you can just open the file that contains the subprogram you want.

By storing subprograms in separate files, reading and understanding your program is much simpler.

Instead of scrolling through one massive file that contains your main program and all of its subprograms, you can just open the file that contains the subprogram you want.

A second advantage is that storing subprograms in separate files also lets you reuse subprograms. By storing commonly used subprograms in files , you can create libraries of useful subprograms , copy them to another computer, and reuse them in other programs.

A second advantage is that storing subprograms in separate files also lets you reuse subprograms. By storing commonly used subprograms in files , you can create libraries of useful subprograms , copy them to another computer, and reuse them in other programs.

Sample… One file might contain subprograms that calculate different mathematical equations, and a second file might contain subprograms that display graphics on-screen. By creating and reusing libraries of subprograms, you can keep your main program size to a minimum.

One file might contain subprograms that calculate different mathematical equations,

and a second file might contain subprograms that display graphics on-screen.

By creating and reusing libraries of subprograms, you can keep your main program size to a minimum.

Problem with subprogram libraries : 1 If programmers found a subprogram library useful, they often copied it for their own programs . Unfortunately, this meant that you had multiple copies of the same subprogram library. If you found a mistake in your subprogram library and fixed it, guess what? Now you’d have to find and fix that same mistake in every single copy of that same subprogram library.

If programmers found a subprogram library useful, they often copied it for their own programs . Unfortunately, this meant that you had multiple copies of the same subprogram library. If you found a mistake in your subprogram library and fixed it, guess what? Now you’d have to find and fix that same mistake in every single copy of that same subprogram library.

Problem with subprogram libraries : 2 Programmers often copied a useful subprogram library and then added their own subprograms to that library file, which meant that you not only had multiple copies of a subprogram library, but you could also have slightly different versions of that same subprogram library scattered among multiple programmers.

Programmers often copied a useful subprogram library and then added their own subprograms to that library file, which meant that you not only had multiple copies of a subprogram library, but you could also have slightly different versions of that same subprogram library scattered among multiple programmers.

To solve these twin problems, computer scientists invented something called object-oriented programming (OOP) Object-Oriented programming (OOP) OR “Oops, you spent four years studying the wrong programming language in college  ??? ”. …just kidding… 

To solve these twin problems, computer scientists invented something called object-oriented programming (OOP)

Object-Oriented programming (OOP) OR “Oops, you spent four years studying the wrong programming language in college  ??? ”. …just kidding… 

Dividing programs into objects The basic idea behind objects is that instead of making physical (duplicate) copies of subprograms, you maintain a single, physical copy of subprograms but allow others to make “virtual” copies of those subprograms,

The virtual copies of subprograms work exactly the same as any physical copies. The main advantage is that you can’t modify a virtual copy of a subprogram. This prevents other programmers from copying a subprogram and making many different versions.

The virtual copies of subprograms work exactly the same as any physical copies. The main advantage is that you can’t modify a virtual copy of a subprogram.

This prevents other programmers from copying a subprogram and making many different versions.

If programmers need a subprogram to fix a problem, they need to modify only the original subprogram stored in an object. This automatically updates any virtual copies of the subprogram anywhere else in the program.

If programmers need a subprogram to fix a problem, they need to modify only the original subprogram stored in an object. This automatically updates any virtual copies of the subprogram anywhere else in the program.

If programmers want to create slightly different versions of a subprogram, they just need to create a copy of the virtual subprogram and then make any modifications, which is known as polymorphism. They can either add new instructions or over write any existing instructions stored in the original subprogram object,

If programmers want to create slightly different versions of a subprogram, they just need to create a copy of the virtual subprogram and then make any modifications, which is known as polymorphism.

They can either add new instructions or over write any existing instructions stored in the original subprogram object,

 

Any changes made to a virtual subprogram won’t affect or modify the original subprogram. By sharing subprograms as objects, you gain two advantages: You store a single copy of subprograms that others can freely share. Updating a subprogram in one location automatically updates any virtual copies of that subprogram throughout an entire program. Others can modify any virtual subprograms without physically copying or altering the original subprogram.

Any changes made to a virtual subprogram won’t affect or modify the original subprogram. By sharing subprograms as objects, you gain two advantages:

You store a single copy of subprograms that others can freely share. Updating a subprogram in one location automatically updates any virtual copies of that subprogram throughout an entire program.

Others can modify any virtual subprograms without physically copying or altering the original subprogram.

 

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

ABAP Tutorial Teil 3: Strukturen und interne Tabellen (1)

Mit einer Struktur wird auch eine Tabellenzeile deklariert. Dies geht in mehreren Varianten: “Die Tabellenzeile wird von der Objekt INT4 geerbt.
Read more

C-Tutorial / Strukturen, Dateizugriff (Kap. 13)

Auch verschachtelte Strukturen (Struktur in einer anderen Struktur) sind möglich. ... Dem gegenüber steht der Low-Level-Dateizugriff, ...
Read more

Projektstrukturplan – Wikipedia

Der Projektstrukturplan (PSP) (engl. work breakdown structure; abgekürzt WBS) ist das Ergebnis einer Gliederung des Projekts in plan- und kontrollierbare ...
Read more

Structure of a Visual Basic Program - msdn.microsoft.com

A Visual Basic program is built up from standard building blocks. A solution comprises one or more projects. A project in turn can contain one or more ...
Read more

Low-low Level Struktur - forum.byte-welt.net

Low-low Level Struktur; Willkommen auf byte-welt.net – Die Welt des Programmierens Byte-Welt ist ein kostenloses, werbefreies Portal für Einsteiger, ...
Read more

Treueprogramm Latitudes - Norwegian Cruise Line

Punkte-Struktur. Level Punkte; Bronze: 1 - 19: Silber: 20 - 47: Gold: 48 - 75: Platin: 76+ Gäste, die 250, 500, 700 und 1,000 Punkte erreichen, erhalten ...
Read more

Work breakdown structure - Wikipedia

A work breakdown structure (WBS), in project management and systems engineering, is a deliverable-oriented decomposition of a project into smaller components.
Read more

IT Infrastructure Library – Wikipedia

Mit der einheitlichen und konsistenten Struktur in allen Büchern soll eine einfache Orientierung ... Der Expert-Level ist keine eigene ...
Read more

Data structure - Wikipedia

In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Data structures can ...
Read more