DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Programming Style. Linear VS Structured

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation

Programming Style?
Structured
83%
 83%  [ 5 ]
Linear
16%
 16%  [ 1 ]
Total Votes : 6

Author Message
tinman47
Lord of Gaming
Lord of Gaming


Offline
Joined: 24 Feb 2007
Posts: 230

PostPosted: Thu May 03, 2007 6:05 pm     Post subject: Programming Style. Linear VS Structured Reply with quote

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
Lord of Gaming


Offline
Joined: 24 Feb 2007
Posts: 230

PostPosted: Thu May 03, 2007 6:06 pm     Post subject: Reply with quote

LINE
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Thu May 03, 2007 6:09 pm     Post subject: Reply with quote

there, I made it a poll. lol
Back to top
tinman47
Lord of Gaming
Lord of Gaming


Offline
Joined: 24 Feb 2007
Posts: 230

PostPosted: Thu May 03, 2007 6:18 pm     Post subject: Reply with quote

Wow,thats what the little POLL button was for,thanks wardrich.
Back to top
Larry Laffer
Admin
Admin


Offline
Joined: 19 Feb 2006
Posts: 4144
Location: Romania

PostPosted: Fri May 04, 2007 12:59 am     Post subject: Reply with quote

lol, yeah it's obvious! Laughing
Back to top
dosraider
Admin
Admin


Offline
Joined: 15 Mar 2005
Posts: 9257
Location: ROTFLMAO in Belgium.

PostPosted: Fri May 04, 2007 1:32 am     Post subject: Reply with quote

Unruly.


Can't poll. Suspicious
Back to top
abyss
Moloral Compass
Moloral Compass


Offline
Joined: 06 Nov 2006
Posts: 754

PostPosted: Fri May 04, 2007 4:38 pm     Post subject: Reply with quote

What does linear and structured mean.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Fri May 04, 2007 4:41 pm     Post subject: Reply with quote

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
Moloral Compass


Offline
Joined: 06 Nov 2006
Posts: 754

PostPosted: Fri May 04, 2007 4:56 pm     Post subject: Reply with quote

I don't get it.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Fri May 04, 2007 5:56 pm     Post subject: Reply with quote

what don't you get?
Back to top
tinman47
Lord of Gaming
Lord of Gaming


Offline
Joined: 24 Feb 2007
Posts: 230

PostPosted: Fri May 04, 2007 11:25 pm     Post subject: Reply with quote

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? Cool
Back to top
abyss
Moloral Compass
Moloral Compass


Offline
Joined: 06 Nov 2006
Posts: 754

PostPosted: Sat May 05, 2007 6:46 am     Post subject: Reply with quote

How is that useful. I really don't understand it.
Back to top
dosraider
Admin
Admin


Offline
Joined: 15 Mar 2005
Posts: 9257
Location: ROTFLMAO in Belgium.

PostPosted: Sat May 05, 2007 7:46 am     Post subject: Reply with quote

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
Moloral Compass


Offline
Joined: 06 Nov 2006
Posts: 754

PostPosted: Sat May 05, 2007 5:06 pm     Post subject: Reply with quote

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
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Sun May 06, 2007 1:15 am     Post subject: Reply with quote

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
abyss
Moloral Compass
Moloral Compass


Offline
Joined: 06 Nov 2006
Posts: 754

PostPosted: Sun May 06, 2007 6:14 am     Post subject: Reply with quote

I understand it now i prefer structured.
Back to top
Larry Laffer
Admin
Admin


Offline
Joined: 19 Feb 2006
Posts: 4144
Location: Romania

PostPosted: Sun May 06, 2007 6:14 am     Post subject: Reply with quote

Now, that IS a good example (rofl)
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Sun May 06, 2007 4:34 pm     Post subject: Reply with quote

Thanks... feel free to share it. It's one of my best ones yet. Tbbbbbth!. I remember my grade 10 programming teacher I think it was asking me "how would you program yourself to make a peanut butter sandwich, assuming you have to go to the store to get what you need".

I went on for 2 solid minutes and had only JUST made it to the part where I reach the store. lol. She was impressed... all the other newbs were like "First I walk to the store" totally undefining how to walk, and leaving out all sorts of easily overlooked steps. lol.

Too bad I didn't know about methods back then Tbbbbbth!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 
Free Windows games


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)