10/02/2015

Web Programming: Parameters vs. Arguments, Class vs. Object, Properties vs. Attributes

One of the more confusing things about web programming is that there are specific names for data that is being passed around the program. The name changes depending on whether the data is being sent to something or being received by something.

Parameters - data that is being sent to a function or method.

Arguments - data that is being received from a request.

The difference between Class and Object is not too hard to understand:

Class - A model or template that describes a thing. Like blueprints for a home or car, or parts of an account.

Object - an instance of a Class. Like a actual product made from the blueprints.

Properties and Attributes are very similar and nearly interchangeable, but usage tend to depend on the context of the programming language.

Properties - usually refers to a variable or named value stored inside of a programming object. Many programmers say: "Objects have Properties and Methods."

Attributes - like properties in that they belong to something. In HTML, Attributes are placed inside of an HTML tag, and these are passed to the web browser for specific identification and interpretation.

Examples:

Here, "dog" and "1234" are the Parameters being sent as varibles.

$clientID = 1234;
$typeOfRelative = "dog";
$clientDogName = getRelativeName($clientID, $typeOfRelative);

Here, the function receives two Arguments via the variables "$clientIDReceived" and "$typeOfRelativeReceived".

function ($clientIDReceived, $typeOfRelativeReceived) {
    $relativeName = [DO SOME KIND OF DATABASE QUERY USING THE INFO RECEIVED]
  return ($relativeName);
}

Here, the object is called Client, and Client has 3 Properties, "$name", "$dogName","$partnerName":

class Client {
  public $name;
  public $dogName;
  public $partnerName;
}

Here, in HTML, the "id" and "style" are Attributes of the HTML tag:

<h1 id="mainTitle" style="color:darkblue;">CLIENT INFO</h1>

No comments :

Post a Comment