Showing posts with label Void. Show all posts
Showing posts with label Void. Show all posts

Sunday, May 27, 2012

What is a Sequence Diagram?

A sequence diagram is a UML (Unified Modelling Language) diagram. It is used to show the interactions between objects in the sequence they occur.


Here is a class diagram of the objects in the system...

The sequence diagram below, models the interactions required to get the 'Message' from the SpecialPower object.



Where a class diagram shows the details of each class & the relationships between them; a sequence diagram shows the sequential interactions between these objects.


Lifelines
Each object has a lifeline. This is a dashed line. The solid areas denote when an object is active in a process.




Numbering

Notice that each interaction in the sequence diagram is numbered according to the sequential flow of execution.



Void


In design documentation, where no value is returned from an interaction, the word 'void' is often used. A 'void' return is often seen as the result of instantiating an object. This is because a constructor cannot return a value. As well as that, you could expect to see 'void' as the return from a sub procedure.



"UML basics: The sequence diagram" ( http://ibm.co/Lk8yqN )

err....here's a cat:


Tuesday, March 27, 2012

Methods: Procedures & Functions

DOWNLOAD THE CODE: MethodsPkg

There are two types of methods:
  1. Procedure
  2. Function
All methods begin with a method signature which opens into a code block.

A method signature is a contract which specifies:

  • visibility (can it be seen externally?)
  • what type of data it will return
  • what it will do (the name)
  • which data, if any, it requires to perform it's task

visibility | return data type | method name | (parameters if any) {

}



Procedure
What it does: executes processing statements.

Example:



The method signature for a procedure always contains the keyword void (meaning nothing/empty). This is as opposed to a function, which always returns a value. Read on...


Function
What it does: executes processing statements and returns a value to the calling procedure.

Example:



The method signature for a function always contains a datatype to indicate the type of data that will be returned from the function.

The final statement in a function begins with the return keyword, followed by the data that will be returned. In this case, a String.

Methods may also require incoming values called parameters (sometimes called arguments) which are placed within the parenthesis following the method name.