| Programming Style? |
| Structured |
|
83% |
[ 5 ] |
| Linear |
|
16% |
[ 1 ] |
|
| Total Votes : 6 |
|
| Author |
Message |
tinman47 Lord of Gaming

 Joined: 24 Feb 2007 Posts: 231
|
Posted: Thu May 03, 2007 6:05 pm
Post subject: Programming Style. Linear VS Structured |
|
|
Whats your programming style.If its structured,reply STRUC,
if its linear,reply LINE,then I rank it up in 10 days. |
|
| Back to top |
|
 |
tinman47 Lord of Gaming

 Joined: 24 Feb 2007 Posts: 231
|
Posted: Thu May 03, 2007 6:06 pm
Post subject: |
|
|
| LINE |
|
| Back to top |
|
 |
wardrich lawl catz r lawlz

 Joined: 14 Sep 2002 Posts: 3140 Location: Ontario Canada
|
Posted: Thu May 03, 2007 6:09 pm
Post subject: |
|
|
| there, I made it a poll. lol |
|
| Back to top |
|
 |
tinman47 Lord of Gaming

 Joined: 24 Feb 2007 Posts: 231
|
Posted: Thu May 03, 2007 6:18 pm
Post subject: |
|
|
| Wow,thats what the little POLL button was for,thanks wardrich. |
|
| Back to top |
|
 |
Larry Laffer Moderator

 Joined: 19 Feb 2006 Posts: 3393 Location: Romania
|
Posted: Fri May 04, 2007 12:59 am
Post subject: |
|
|
lol, yeah it's obvious!  |
|
| Back to top |
|
 |
dosraider Moderator

 Joined: 15 Mar 2005 Posts: 5051 Location: ROTFLMAO in Belgium.
|
Posted: Fri May 04, 2007 1:32 am
Post subject: |
|
|
Unruly.
Can't poll.  |
|
| Back to top |
|
 |
abyss Moloral Compass

 Joined: 06 Nov 2006 Posts: 762 Location: A city known for mining. sudbury
|
Posted: Fri May 04, 2007 4:38 pm
Post subject: |
|
|
| What does linear and structured mean. |
|
| Back to top |
|
 |
wardrich lawl catz r lawlz

 Joined: 14 Sep 2002 Posts: 3140 Location: Ontario Canada
|
Posted: Fri May 04, 2007 4:41 pm
Post subject: |
|
|
Linear programming starts at the top and runs down the code until the bottom line.
Structured programming uses classes and methods. Line 3 may tell the interpreter to jump to line 300, then jump back to line 4. |
|
| Back to top |
|
 |
abyss Moloral Compass

 Joined: 06 Nov 2006 Posts: 762 Location: A city known for mining. sudbury
|
Posted: Fri May 04, 2007 4:56 pm
Post subject: |
|
|
| I don't get it. |
|
| Back to top |
|
 |
wardrich lawl catz r lawlz

 Joined: 14 Sep 2002 Posts: 3140 Location: Ontario Canada
|
Posted: Fri May 04, 2007 5:56 pm
Post subject: |
|
|
| what don't you get? |
|
| Back to top |
|
 |
tinman47 Lord of Gaming

 Joined: 24 Feb 2007 Posts: 231
|
Posted: Fri May 04, 2007 11:25 pm
Post subject: |
|
|
Linear programming is when you just write a big list of code that is just stuck together and is not organized and just executes straight through,structured programming is when you organize your code into big and small blocks or paragraphs that you can call and use seperately.Do you understand now?  |
|
| Back to top |
|
 |
abyss Moloral Compass

 Joined: 06 Nov 2006 Posts: 762 Location: A city known for mining. sudbury
|
Posted: Sat May 05, 2007 6:46 am
Post subject: |
|
|
| How is that useful. I really don't understand it. |
|
| Back to top |
|
 |
dosraider Moderator

 Joined: 15 Mar 2005 Posts: 5051 Location: ROTFLMAO in Belgium.
|
Posted: Sat May 05, 2007 7:46 am
Post subject: |
|
|
It's extremely usefull.
Think about a coded block, you can call it several times and jump back to the next %% line.
If you need, let's say, a specific process 20 times ( suppose here you need 500 lines or so for that process) , in stead of writing those 500 lines 20x you simply jump to the subroutine and back where you were (now yeah a line down or whatever if there is a variable input ... whatever).
It is very much used in industrial coding ( PLC - Automatisation ...) where repetitive actions are needed.
A good example are electric motors that need a starting/stopping slope , or a check if they are running/stopped before you can safely go to the next step.
You don't code such routine for 2000 motors seperately, you code one and call that one when needed.
Another example ?
Emergency stop buttons, if you ever seen those big red knobs in industry ...
Some complex machinery have hundreds of those, and some machinery needs a specific stopping routine, first shut that motor, next that one, break 1 on, next motor , break 2 on ...
You will NOT write that whole sequence for every emergency stop button, no, you write it once, and call a subroutine with an IF or an OR when such a button is hit. |
|
| Back to top |
|
 |
abyss Moloral Compass

 Joined: 06 Nov 2006 Posts: 762 Location: A city known for mining. sudbury
|
Posted: Sat May 05, 2007 5:06 pm
Post subject: |
|
|
| I am a completely inept moron, so I still have no idea what you're talking about despite your crystal clear explaination. Forget about it. |
|
| Back to top |
|
 |
wardrich lawl catz r lawlz

 Joined: 14 Sep 2002 Posts: 3140 Location: Ontario Canada
|
Posted: Sun May 06, 2007 1:15 am
Post subject: |
|
|
Linear = any old book
Structured = Choose Your Own Adventure
Or, a better example... say you want to program walking to the store and back to get some peanut butter and bread...
you'll have to walk to the store open a door walk around in the store to find the bread then take the bread and walk more to find the PB, which you will also take. Then you'll want to pay for the goods, walk to the door and open it again. Then you're going to walk home...
Now, from a linear POV [missing a lot of validation checks]:
| Code: |
do until location = store
Move left foot
move right foot
get location
repeat
move left arm until hand is on door
push with arm
move left foot through door
move right foot through door
release hand from door
lower arm
do until location = peanut butter
move left foot
move right foot
get location
repeat
raise right arm until right hand is on the peanut butter
place right hand on peanut butter
tighten right-hand fingers around peanut butter
raise peanut butter off shelf
bring right hand to bag
put pb in the bag
loosen right-hand fingers
take right hand off of pb
raise right arm until hand is not in bag
do until location = bread
move left foot
move right foot
get location
repeat
raise right arm until right hand is on the bread
place right hand on bread
tighten right-hand fingers around bread
raise bread off shelf
bring right hand to bag
put bread in the bag
loosen right-hand fingers
take right hand off of bread
raise right arm until hand is not in bag
do until location = cash
move left foot
move right foot
get location
repeat
lower left arm until left hand is in pocket
do until money in left hand = bill total
put left hand on coin
tighten left-hand fingers around coin
raise arm until hand is level with cashier
align left hand to cashier's hand
loosen left-hand fingers off of coin
lower left arm until left hand is in pocket
repeat
raise right arm until right hand is on bag handle
tighten right-hand fingers
raise right arm until bag is off counter
move left foot
move right foot
lower right arm
do until location = door
move left foot
move right foot
check location
repeat
move left arm until hand is on door
push with arm
move left foot through door
move right foot through door
release hand from door
lower arm
|
And now, from a structured POV:
| Code: |
do until location = door
Walk
repeat
position arm(right, down, pocket)
do until location = pb
Walk
repeat
open(left, up)
position arm(right, up, pb)
grab(right)
position arm(right, down, bag)
release(right)
do until location = bread
Walk
repeat
position arm(right, up, head)
position arm(right, down, bread)
grab(right)
position arm(right, down, bag)
release(right)
do until location = cash
Walk
repeat
do until money = bill total
money = pocket change - coin
position arm(left, down, coin)
position arm(left, up, cashier hand)
repeat
position arm(right, up, bag)
grab(right)
do until position = door
Walk
repeat
open(left, up)
do until location = home
walk
repeat
Walk
move left foot
move right foot
check location
return location
---
position arm(arm, direction, object)
move arm direction until it is level with object
---
grab(arm)
tighten arm fingers
---
release(arm)
loosen arm fingers
---
open(arm, direction)
position(arm, direction, door)
push door with arm
Walk
---
|
|
|
| Back to top |
|
 |
|