3 ms·
Cog is a little webdev framework of mine, a work-in-progress steal from spending couple of years in different companies. Since A/B testing is considered pretty
by sdrinf 16y ago
Cog is a little webdev framework of mine, a work-in-progress steal from spending couple of years in different companies.
Since A/B testing is considered pretty fundamental to most of my clients, I thought I'd share with the dear community of HN one possible implementation of it. You can see A/B testing in action on the sample page:
http://github.com/waverz/cog/blob/master/cog-guestbook/pages/guestbook.html http://github.com/waverz/cog/blob/master/cog-guestbook/pages...
When used together with scriptor, an A/Btest is about 1 line in the design file (db rows, and counters are automagically set up on first page visiting). Stand-alone you might want to integrate it with a templating engine of your own :)
Code is PD, and review is more, than welcome.
- Nycto 16y ago> review is more, than welcome. You opened the door, so here is my feedback: - You never have to explicitly define any of the super globals as global... you can delete any line that says "global $_SESSION;", for example - The database interactions look like they are heavily dependent on global state. It is also a tightly coupled dependency - Use __construct for constructors instead of the class name: http://www.php.net/manual/en/language.oop5.decon.php http://www.php.net/manual/en/language.oop5.decon.php - Foreach is better than a for loop for iterating over arrays - Single character variable names only make code more confusing. You write code once, you read it a dozen times. I challenge you to rewrite this with only using classes (no global functions) and to write unit tests for your code. Remember, if you have to jump through hoops to test your code, you need to rethink what you're doing.
- lmz 16y agoThat resolvequery() function in cog_database.php looks interesting. Wonder what happens if you call resolvequery('INSERT INTO ... VALUES (@email, @example)', array('email' => 'test@example.com', 'example' => 123));