ThinkHTML Notes and stuff


most data in life is partial data



Buttons (different levels)
Tooltips (different levels)
Tabs (different levels)


Auto-negotiate headers

Language: en, es, ru
Content-type: xml, html, json
mobile not mobile???
Cookie sharing? (with United Kingdom locale) (with United Kingdom locale but in spanish, top level domain adds complexity) (Australian geotargeting, bad idea since the country can have more than one language)


Section content





Notes: redirects to for control over cookies has canonical link to
Dots are forbidden in URL slugs to avoid confusion with extensions

A resource can have many languages, locales, formats. To specify them we use "en", "en-US", ".json"

Normally: - Locale is (has many tecnical limitations, use instead) - Language is (has some tecnical limitations, use or instead) - Format is (has minor tecnical limitations, use normally)

Subdomains handle sub-site and language

. (redirects to www. to not send cookies to all subdomains)
static. (redirects to en.static to not send cookies to all subdomains)
en.static. (gets cookies from static.)
en.www. (Do not use, gets cookies from www.)

( seems like so much simpler...)

Auto negotiate content version (Redirects to a specific version to give control of cookies with subdomains)

Web version

Alternative sites






Language comparison

nouns = variables verbs = functions adjectives?

fox jumps over dog

radialSwapXAxis($fox, $dog, array('radius'=>'1m')); // anything can jump over anything, even in zero gravity
$fox->jumpOver($dog); // here only a fox can jump over things, does not make sense

Good way to name functions (functions are verbs in languages)

function actionVerb(subject, options){}

This keeps the number of variables to a minimum number, which helps reduce confusion to which variable

// bad (you have no clue what each argument does)
action(true, true, true);

// bad (ignoring legacy software, forces people to rewrite their code to use new function)
action($subject, $opt1, $opt2, $opt3, $opt4); // old function
action($subject, $opt3, $opt4); // new function

// bad (supporting legacy, forces people using new function to add empty params, like in wordpress)
action($subject, $opt1, $opt2, $opt3, $opt4); // old function
action($subject, null, null, $opt3, $opt4); // new function

action($subject, array('compress'=>true, 'lossy'=>true));
action(array('compress'=>true, 'use-enviroment'=>true, 'lossy'=>true)); // old function
action(array('compress'=>true, 'lossy'=>true)); // new function

Objects create context for functions and variables,

// Asynchronous Transfer Mode
// Automated teller machine
// At the moment

Even class variables (called properties, similar to adjectives) can have different values / meaning depending on the context

Apple::$red; // red
Fox::$red; // brown-red

Objects can carry context in instances that can be configured at runtime

$it = new Abbreviations('IT');

$bank = new Abbreviations('Bank');

$teen = new Abbreviations('Teen');

good for config carriers or other object wrapping.
just like variables "instances" are also things, except they are defined at compile time
Just like real languages, this allows us to have "assumed" defaults for verbs and nouns

class Context {
    function jacked($subject, $things){

$context = new Context(array('it'=>"John's hidden stash", 'them'=>'Collection of coins', 'everything'=>array("John's clothing","John's house")));
$context->jacked($someone, array('it', 'them', 'everything'));

Although you can do the same with variables

$it = "John's hidden stash";

But it is harder to carry over large amounts of definitions, while with an array it is easier, but arrays don't carry functions (verbs) very well in PHP
In javascript, objects are fine to carry context (variables and functions)

Prefer composition over inheritance (interfaces are still good)

With extending

No class names in code that works after everything was defined (Find out the name for this type of code)

// add middleware (Classes mentioned, direct dependencies)
$req->db = new Connection($options);
$req->html = new HTML5Parser$options);
$req->img = new ImageGD($options);

// use middleware (No classes mentioned)

Constructors must be minimal and not do processing, especially if it can fail (functions are for processing, constructors are for config)

// bad
class ImageObject {
    var $gd;
    function __construct($img_file){
        $this->gd = imagecreatefromstring($img_file);
    function crop(){
// good
class ImageConverter {
    var $options = array();
    function __construct($options){
        $this->options = array_merge($this->options, $options);
    function convertGD($img_gd, $options=array()){
        $o = array_merge($this->options, $options);
        $w = imagesx($img_gd);
        $h = imagesy($img_gd);
        $img = imagecreatetruecolor($s['dst_w'],$s['dst_h']);
        $img = imagecopyresampled($img, $img_gd, 0, 0, 0, 0, $o['width'], $o['height'], $w, $h);
        return new ImageGD($img);
    function convertString($img_str, $options=array()){
        return $this->convertGD(imagecreatefromstring($img_str), $options);
    function convertFile($img_file, $options){
        return $this->convertString(file_get_contents($img_file), $options);
class ImageGD {
    var $gd;
    function __construct($gd){
        $this->gd = $gd;
    function save($file, $options){
        return imagejpeg($this->gd, $file);
// also good
function jQuery(selection){
    var self = this;
    selection.each(function(i, el){
        self[i] = el;
var els = new jQuery(selection);


Wrapper classes (Decorators) add functions and data to other objects just make sure that they work with minimal data, preferably just the object or resource


Make services

Data service?

must work with minumum data given
the load functions job is the combine tables into views or to use views directly
it loads MANY views and leverages the combined abilities of the database and the server
externally you just request "tagged" content and filter it with filters

// $data[view_name][row_num][col_name] = value;
$data = $data_service->load($filter);

now that we have the data in an array format, we can format it into any shape that we want
format will convert it into a tree structure

$formatted_data = $data->format($xls);

this tree structure is sent to a template that wraps it with html