Learn VB .NET Through Game Programming [Electronic resources]

Matthew Tagliaferri

نسخه متنی -صفحه : 106/ 15
نمايش فراداده

Setting Up Methods

The procedures discussed in the previous section, UpdateGuessButtons, are called methods. A method is a procedure or function associated with a class. In the case of the Guess the Die Roll program, the UpdateGuessButtons method is associated with the fGuess class, which is a subclass of the .NET Framework form class.

Methods are often thought of as the “do work” code for a class. Because of this, it’s common that a method name is an action phrase or a verb. Look at all of the method names associated with the final (version 1) fGuess class in the Guess the Die Roll program, and you’ll see a pattern:

RollTheDie

UpdateDiePosition

DrawDie

UpdateGuessButtons

Each of the method names has a verb in it, and thus it’s self-evident what task each method performs.