Category Archives: Technology

Geeky stuff

Use “get” methods to help writing more testable code

Imagine you have the following code

If you were writing unit test against do_something(), you would need to do some complex mocking on User.objects.filter() to return some mock up data. But this can be easily prevented by refactoring into a separate get_users() method as below:

This way, you can just mock get_users() to… Read More »

Minimal Django script setup

Notes about python logging

Consider the following code

Executing above: It won’t log anything to console, because it default to level warning It won’t log anything to console, because no stream has been set

Executing above: Running basicConfig(…) default adds the stream to stderr (unless specified explicitly) to root logger It sets the root logger level to… Read More »

Good references for writing tests

http://blog.codepipes.com/testing/software-testing-antipatterns.htm The above article talks about some anti-patterns in tests, personally I agree most of them especially anti-pattern on “Treating TDD as a religion”.

Good Read: Being A Developer After 40

“In our industry, every technology generates what I call a “galaxy.” These galaxies feature stars but also black holes; meteoric changes that fade in the night, many planets, only a tiny fraction of which harbour some kind of life, and lots of cosmic dust and dark matter. Examples of galaxies are, for example, .NET, Cocoa, Node.js,… Read More »

Orcon connection issue…

The graph below is the connection graph on Orcon VDSL, see the arrow pointed regular connection drops, it is particularly obvious during online gaming. The graph below is the connection graph tethered on my phone on 3G Mobile Data, comparing to above, a lot less connection drops.