« Smiraglia, Bibliographic Control of Music | main | a mishmash of basic php »
I should just know this stuff
22 Jan 08
but it never hurts to review:
- three-tier architectures: client(browser) ↔ web server ↔ database server
- database applications are stateful, http is stateless
- the browser is a thin client, but it is possible to pass some of the work to the browser; e.g. JavaScript can be used to validate data before sending to the web server
I have a tendency to skim discussion of strings, variables, math, increments, expressions, operators. . . . Can’t I just look that stuff up? But I may need to think about character encoding and data entry. On to the object-oriented stuff:
- an object is a container in which data and functions can be bound
- a class is an object (?) that can be used to create many similar objects (it doesn’t help that the book I’m using keeps using the term package to describe the example of a class that is used†)
- a method is a function that belongs to a class (or package); a method can be called on an object that has been created by the class
- each specific object created by the class is an instance
† – It reads like this: An object is created by a package. A method (or member function) is called on an object. A method is provided by a package. The package in question is a class (aren’t all packages – should I just forget they ever said “package”?). An object created by a class is an instance. Now I get an example that shows me how to create a user-defined class that counts. There’s nothing like learning by doing. Back to class:
- variables defined within a class are member variables; functions, member functions.
- “The class definition defines how data and functionality are actually bound together—member variables and functions take their meaning from the class of which they’re a part.”
- class definitions can be placed in include files, the benefits of which aren’t listed in my text, but I imagine must include:
- efficiency: the class needn’t be written out every time it’s needed, saving time and bandwidth
- uniformity: by having only one copy of a class that could be used by multiple programmes, we ensure that the class always functions in the same way
- security: the class remains on the server, and I’m guessing this might make things a little more secure in some way. Or not. I just can’t finish a list after only two items.
- a constructor is a method that is called when an object is created, and can be used to set up the initial state of the new object
- a destructor is a method that is called when an object is destroyed
- destructor functions are useful for housekeeping tasks like closing the connection to a DBMS or saving user preferences to a file
PHP also has private members variables, but it’s very rare that these ever become law.
I think I’ll save inheritance for tomorrow.
Williams, Hugh E. and David Lane. Web Database Applications with PHP and MySQL. Sebastapol, CA: O’Reilly, 2004.
Posted by pzed on January 22, 2008 at 5.28pm
Categories: libraries, music, web stuff
