methods in programming

12
Methods in Programming Jonathan Heimdal November 8, 2012 2A Computer Technology

Upload: sachi

Post on 24-Feb-2016

27 views

Category:

Documents


0 download

DESCRIPTION

Methods in Programming. Jonathan Heimdal November 8, 2012 2A Computer Technology. Main Method. User Method. Main bodies of code go here Starts with capital letters Main can access user methods easily. Can be referred to several times in main Usually starts with lower case letters - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Methods in Programming

Methods in Programming

Jonathan HeimdalNovember 8, 2012

2A Computer Technology

Page 2: Methods in Programming

Method Comparison

Main Method User Method

Main bodies of code go here

Starts with capital letters

Main can access user methods easily

Can be referred to several times in main

Usually starts with lower case letters

Used to shorten and simplify programs

Page 3: Methods in Programming

Main Method

• Method name is Main

• Main method has parameters inside parenthesis

• Main code goes inside opening and closing curly braces {CODE HERE}

Page 4: Methods in Programming

User Method

• Method name is OpenReadWriteFileAsync

• User method has parameters inside parenthesis

Page 5: Methods in Programming

Purposes for User Methods“A purpose for a user built method, is if, for example, you must use the same block of code several times in a program, you don’t have to retype the same block of code over and over. All you have to do is type the name of the method and the parameters in place of the block of code.” (Heimdal, 2012)

Used to shorten and simplify programs

Saves time when writing large programs

Makes programs easier to read

Page 6: Methods in Programming

How to Identify

All methods are outside of main

Methods are sometimes in separate class

Class variables can indicate methods

Page 7: Methods in Programming

Types of “Methods”

Constructors

Getters

Setters

Methods

Page 8: Methods in Programming

Constructors

Identified by having the same name as class name

Can do similar actions methods can

Page 9: Methods in Programming

Getters

“Getters are types of methods that are similar to a read only pdf text file. It only allows the user to read what is displayed, and does not allow user to edit.” (Heimdal, 2012)

Gives only get access to user

Page 10: Methods in Programming

Setters

“Setters are similar to getters except for that you may read and edit. Setters allow user to access and edit or use the code in the setter method.” (Heimdal, 2012)

Gives only set access to user

Page 11: Methods in Programming

Methods inside of Methods?

“Methods cannot be inside of other methods. However, a method can also rely on other methods. For example, in a method, you could have a block of code that instigates another action. This action is done by another method. So, a method can rely on other methods inside its’ own code to achieve the overall program.” (Heimdal, 2012)

Page 12: Methods in Programming

Bibliography

Heimdal, J. (2012, November 18). Purposes for Methods. (M. Tamietti, Interviewer)

Navneeth. (2012, July 22). Compiling Multiple main() methods in C#. Retrieved November 18, 2012, from www.wordpress.com: http://crmerp4bus.wordpress.com/2012/07/22/compiling-multiple-main-methods-in-c/

Sabnis, M. (2012, April 6). Asynchronous Programming using C# 4.5 and Visual Studio 2011. Retrieved November 18, 2012, from www.dotnetcurry.com: www.dotnetcurry.com/ShowArticle.aspx?ID=797