Comment Re:Python for learning? Good choice. (Score 1) 415
$xml = new Xml();
$foo = $xml->addChild( 'foo');
$foo->addAttribute( 'attr', 'bar');
$foo->addNode( 'foonode', 'foonodevalue');
$fc1->addChild( 'foochild1');
$fc1->addNode( 'foochild1node', 'value1');
$fc2->addChild( 'foochild2');
$fc2->addAttribute( 'foochild2attr', 'value2');
$fc2->addNode( 'foochild2node', 'value2');
$xml->addNode( 'xmlnode', 'value3');
Code like this gets large comment blocks above and below stating that I'm using a non-standard indentation, and why.
When I later had to refactor the XML schema, it was incredibly useful to have it indented this way.
It depends on the library and language though. When I was using nested C structures, or nested object, it wasn't necessary, because the data structure was a lot more visible. This code is easier to understand using traditional indentation:
$xml = new Xml();
$xml->addChild( 'foo');
$xml->foo->addAttribute( 'attr', 'bar');
$xml->foo->addNode( 'foonode', 'foonodevalue');
$xml->foo->addChild( 'foochild1');
$xml->foo->foochild1->addNode( 'foochild1node', 'value1');
$xml->foo->addChild( 'foochild2');
$xml->foo->foochild2->addAttribute( 'foochild2attr', 'value2');
$xml->foo->foochild2->addNode( 'foochild2node', 'value2');
$xml->addNode( 'xmlnode', 'value3');