Upload
alexander-logan
View
214
Download
0
Embed Size (px)
DESCRIPTION
We use procedures all of the time The fire drill on the wall A recipe in a cook book They are set up in advance We use (call) them only as and when we need them
Citation preview
SCORESequenceChoices to be madeOnce may not be enoughReuse and recycleEvaluate and improve
We use procedures all of the timeThe fire drill on the wallA recipe in a cook book
They are set up in advanceWe use (call) them only as and when we need
them
Procedures in ASP.NETProcedure
Name
Code for the
procedure
It doesn’t matter how it works…So long as we know …
What the procedure does.
And
How to call the procedure.
In this case Call DisplayArray
Will draw the contents of the connect four game on the page.
Event ProceduresFor example, whenever you write the code
for a button, you are writing the code inside an event procedure.
E.g.
Private Sub btnOK_Click(ByVal sender As etc…
'code for the click event goes hereEnd Sub
Creating a Sub ProcedureMake sure
you are not creating a procedure inside a procedure!
One place you could use…
1. Start by typing …
2. Then press Enter…
3. Type your procedure code…
4. Call your procedure…
The Benefits of ProceduresGives greater functionalityHides complexityPromotes code re-useSimplifies maintenance
Gives greater functionality
We don’t need to write this code over and over again…
We call it with a single line of code..
Call DisplayArray
Hides complexityCall DisplayArray
Is very easy to typeVery simple to understand
Call DisplayArray =
Promotes code re-use(Library code)The code for connect four could be used
again in a game of noughts and crosses
Smart programmers build up code libraries so that useful procedures may be “recycled”
Simplifies maintenanceIf the code for a certain task exists only once
in a program
E.g. DisplayArray
Any changes to that one procedure are passed on to all the places in the program that call it.
Modifications and error corrections only need to be done once – within the procedure itself.
Flow of the code…Using the debugger we shall examine how the following code works when it calls the different procedures