Sunday, September 9, 2012

Methods

Software does lots of boring, repetitive tasks. That does not mean that we have to write boring, repetitive code. One of the advantages of methods is that it helps us in our goal of doing "a given job once and once only".
Methods are blocks of code. According to Rob Miles, they allow us to break down a larger task into a bunch of smaller ones and to reuse the blocks of code.

We wrote the method doit() once and we called it twice in our Main() method. This saved us from having to write the exact same code twice.
1 Chapter 3.1 on C# Yellow Book by Rob Miles
http://www.robmiles.com/c-yellow-book/Rob%20Miles%20CSharp%20Yellow%20Book%202012.pdf

No comments:

Post a Comment

Please be kind.