“Global data” by M. Fowler & K. Beck

Since our earliest days of writing software, we were warned of perils of global data - how it was invented by demons from the fourth plane of hell, which is the resting place of any programmer who dares to use it. (C) Refactoring, 2nd Edition

July 13, 2019 · 1 min · anvyst

PHP: Array vs ArrayObject benchmarking

Some measurements on Arrays vs ArrayObjects found among gist users. Just going to bring it here, in case gist dissappears. # php -v PHP 5.3.6 (cli) (built: Mar 17 2011 20:58:15) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies # echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $s[] = array("name"=>"Adam","age"=>35); }; echo memory_get_peak_usage(); ' | php 655040 # echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $o = new ArrayObject; $o->name = "Adam"; $o->age = 35; $s[] = $o;} echo memory_get_peak_usage(); ' | php 887984 # time echo '<?php $s = array(); for($x=0;$x<100000;$x++){ $o = new ArrayObject; $o->name = "Adam"; $o->age = 35; $s[] = $o;} echo memory_get_peak_usage(); ' | php 61010784 real 0m1.448s user 0m1.208s sys 0m0.231s # time echo '<?php $s = array(); for($x=0;$x<100000;$x++){ $s[] = array("name"=>"Adam","age"=>35); }; echo memory_get_peak_usage(); ' | php 33647944 real 0m0.525s user 0m0.429s sys 0m0.092s We can conclude the following at least in PHP 5.6: ...

November 16, 2016 · 2 min · anvyst

Code elegance: one of those days

Ah, it’s just one of those days! It seems that I can wail about this topic in non-stop mode. Why do people overcomplicate problem domain with sophisticated solution. Have you tried to read what you wrote the day after? A week after? No? Then, read it, and try to guess what you’ve been trying to achieve! And at the meantime, read this Programmers Stackexchange topic on Code Elegance. Not enough? ...

March 5, 2015 · 1 min · anvyst