Archive for the ‘methods’ Category
objects and web scripting
scripting typically involves creating objects in order to execute certain tasks to achieve a desired outcome. and so … how do i create an object? it sounds silly, really. but, honest … its abstract … a tough concept around which to wrap one’s head. its the core of modern-day programming, though. so i had better start getting it.
object creation involves 2 steps.
(1). create an object definition ~ the code containing methods and properties of the object. methods ~ directions for making the object. properties ~ characteristics that typify the object.
create a constructor function ~ a named group of 1 or more programming statements that can create new objects. note – by convention, capitalize the first letter of a constructor function.
add properties ~ identified by object name “dot” property name. refer to the newly created, not yet instantiated objects as “this”
objectName.propertyName = value
add methods ~ (methods = functions called from within the method.) name the method, assign a function. use action words when naming methods. identified using the syntax below. (argument = input to subroutine … used to assign a value to a property of the new object)
objectName.methodName(arguement)
(2) instantiation ~ create an instance of the newly defined object. specify a unique name for the new object. assign the object to the recently created object definition using the “new” keyword.
steps in object instantion ~ variable assigned a value ~ variable value passed as a parameter (parameters act as local copies of the argument) to the new object ~ parameter used to assign variable value to an object property ~ object property used by the object’s show method ~ show calls the object’s display method, which writs to the browser.
methods
instructions … distinct sequences of logic that an object can manipulate in order to perform its function, carry out its service, communicate with users and other program objects. methods can only have access to data known to their particular object, and provide a mechanism for accessing (for both reading and writing) the private data stored in an object or a class..
in programming code, methods consist of a sequence of statements required to perform an action, a set of input parameters to customize those actions, and possibly an output value (called return value) of some kind. constructors, accessors, static (i.e. class-level) methods, instance methods, and destructors all play a role in object programming.

//2: parameter declaration~specifies the information a method is given when it is executed
//3: method call~calls the method println (), which belongs to the object known as System.out, and which prints a line of text
//4: variable declaration~declares a variable called proverb, and assigns the string “Practise makes perfect!” to it
//5: method call~prints the string referred to by the variable proverb to the terminal window
//6: another method call~calls the method length() on the string object to determine how many characters the string contains

method declarations~a sequence of statements describing the actions the program and its objects must perform.
class declaration~a language construct to define a class; methods define classes by describing their actions
variables~named locations in the computer’s memory which hold values during program execution. methods often use variables told hold intermediate results. when we assign a value to a variable, we store the value in variable so that the value can get later referenced, via the variable.
Leave a Comment
Leave a Comment







