Podcast Episode 7 – Methods

by Trevor Page on November 20, 2012

  • Methods are the key to making programs flexible, useful and easy to code
  • Methods allow us to re-run specific pieces of code at any given moment
    • ex. user clicks “login”, so now we need to validate their credentials
  • Methods are a way to gather or “clump together”, code into logical groupings.
    • Group code together by tasks: validate user, create new user, change user’s password
  • Methods can allow you to extract a piece of information once they’ve completed their execution
    • this is called a “return value”
    • ex. isUserValid? Yes or No? The answer to the question isUserValid is the return value, which is a boolean
  • Methods don’t HAVE to return anything though, like if you just want to create a new user. You call the “createNewUser” method, and the user can get inserted into a database. We don’t need to know anything else about the operation.

Homework

Read the following post about methods: http://howtoprogramwithjava.com/what-is-a-method-in-java/

{ 0 comments… add one now }

Leave a Comment

Powered by sweet Captcha

Previous post:

Next post: