Scrubber Class Design
About the Scrubber Class:
A scrubber class starts off as a name, a class_name to be specific.
The code of a scrubber class defines an agent, metaphorically a rabbit.
The design of the code follows the design of the [database schema](Database Schema Design). So, the database is an assumption upon which each scrubber class rests. The attributes of a scrubber class parallel the fields of its namesake database table.
The aim of the scrubber class is be an agent with a basic API that will play nice with others. Polymorphism plays a big role in the overall freeradiantbunny design, so having a default simple set of functions that a given instance of a scrubber class can perform will help the over-all whole be more fluid and flexible. (For more on this, see the scene_elements class.
OK, so if there is just one main design for the scrubber class, what is the API for that design:
PHP Style Conventions
Use a script to beautiful the code.
Based Upon Design of Database Schema
The qualifties of the database schema are reflected in the class design.
Rule 1a. Every __table name__ will have a corresponding __php filename__.
Rule 1b. Every __table name__ will have a corresponding __class__ in that php file.
Rule 2a. If there is a __column_name__ in the database, the class has an __private property variable__;
Rule 2b. If the __columnn_name__ is an id other than the primary key, the class has an \"attribue private variable that ends in \"_obj\" instead of \"_id\". This is because the class represents the whole instance of the class reprented by just the primary key id.
Rule 2c. If the class inherits from the class standard, then the set of variables in standard will not be in the class.
Rule 2d. If the standard class is inherited, all variables in standard should be in the database table as columns.
Rule 2e. If the class inherits from the class sproject, then the set of variables in sproject will not be in the class.
Rule 2f. If the sproject class is inherited, all variables in sproject should be in the database table as columns.
Rule 2g. In addition to the variable declarations, the class should contain accessors. The default is both a __get_name()__ and a __set_name()__ for the variable __name__. Another option is for just a __set_plant_obj()__, as is the case for the variable __plant_obj__ and database column __plant_id__.
Rule 3. For every table_name in database, the php code has a make function that creates an instance of the class.
Rule 4. Each php file with have qualities that make it a php file, such as the <?php at the beginning of the file.
Rule 5. Each class will have a set of functions that will enable it. See "Scrubber Protected Functions" and "Scrubber Markup Functions" below.
Scrubber Protected Functions
Three functions are protected functions.
__determine_type()_
In this function, the program assesses the __given__ variables and determines what __type__ of query should be executed upon the database.
The design for this function is up in the air, to a degree. The structure of the __if__ statements is necessary inside the subclass. Also, the call contain the _error message_ line is necessary inside the subclass. If either of these pieces of code needed to be changed, all classes would have to be modified. Why not move the code elsewhere (perhaps using the __strategy pattern__)?
The sql statements are contained inside the class file. This follows the design goal of having each php file be a definition of that particular subclass.
__prepare_query()
In this function, the program examines the __type__ and defines the SQL statement to be executed upon the database. when done with this and if there are no errors, the SQL statement is executed.
__transfer()
In this function, the results of the execution of the SQL statements are assigned to respective varibles.
Scrubber Markup Functions
Three functions are functions that output markup.
__output_aggregate()
This function outputs an aggregation.
__output_single()
This function outputs a single.
Scrubber API
- class_html_table()
- subsub() and other menus
- output_aggregate() and output_simple()
Associated Classes
A large number of classes are stored instantiated and saved in the private variables in a Scrubber Class.
- parameters_obj
- user_obj
- database_obj
- list_bliss_obj
- validation_obj
- query_type_obj
- error_message_obj
- create_obj
- helper_obj
Testing
Use PHP unit testing.
Maybe make a poor man's unit test, listing all the URLs that are of use and put them in maxonomy rallytally and then check for errors.