Doing a Test With Codility
Two days ago I was called by an employer offering me a job as a Developer. After having a quick phone interview, she told me that they need to test my programming skill that I can do it at home. I was thought it really nice that I didn’t have to go to their office ( – always hesitate to go anywhere in Jakarta in busy work day), and their email come in the afternoon just sending a link to this site, codility.com:
To my surprise, this site offers exactly what the companies who in search for programmer and need to ensure their basic programming skills. We can look at how the test work by doing the sample test accessible from the homepage. The interface are nice, we can even choose our langauge of choice with the same given problem. The Help screen is intuitive. The IDE is enough to write a solution. And we can verify our work againts the default test case (that in used in the instruction) and our own test cases.
If we submit the task, the server will then evaluate our result againts more heavily internal test cases to make the score, and this is where I know I got pretty “unsatisficated” score. We can have a view about how and what that will be scored from our code from the analysis in the report, we could be use this to our advantage before taking the real test. However, in the real test, our result report will not be shown.

So, these are some tips I want to share when working on codility as a testee:
- Do several demo tests (http://codility.com/demo/take-sample-test/ - accessible from the homepage) – two other samples accessible from blog post (http://blog.codility.com/2011/03/solutions-for-task-equi.html) before doing the real test, so you get familiar with the interface, the problem, and the way to verify and submit result.
- Have place that suitable to do the test without interuption for about the time allocated to you, because we cannot pause the timer, and also concern the electricity supply if working on a laptop.
- When the test starting, allocate enough time (about 30% of time) to understand the problem given in the instruction, having a sheet of paper beside you is a good idea to scratch your mind. In my case, it would always about creating a function that working with an array as an input.
- After familiar with the problem, make some quick custom test cases (array) and the expected output to be verified againts the code.
- Start coding the initial solution (about 10-20% of time), the problem are usually puzzling, but it should not too complicated or written in long lines (at least in my case).
- Do a lot of verification and code fixing against different test cases! (about 50-60% of time)
- Don’t forget in mind the code must work with extreme data possible (the size of array – even empty array, or the value in each item).
- Submit with confidence – don’t forget those lines might affecting your life next month… ;-P
After finishing the test, I found that my code was not optimized properly (I forgot to put some ‘breaks’), there’s nothing I can do, hope they will contact me again after this (?) I found my own drawback that I must improve such as:
- Underestimate the importance of identifying size of array and data type (using long as a container for integer operation is a good idea)
- Forgot to put multiple breaks in a stepped ‘for’ iteration! #sigh
- Need a way to make extreme test cases
Companies had very different styles in testing the recruits. Some form of tests I have had includes (each in different occasions):
- Creating a pseudocode with a real world case on paper, and got hired…
- Creating a pseudocode with common algorithm (sorting, etc) on paper, and got hired…
- Drawing solution for a puzzle-like problem on paper, got further progress but unfortunately could not take it…
- Asked to make an almost complete solution, in a closed room, with a prepared laptop, without internet connection… never got the next call
- Asked to make a program for a given task in an empty workstation, with internet, got hired as my first job…
- With Codility, no call yet
PHP Extracting Variables from an Object
Extracting variables from an associative array’s index is quite straightforward.
It will make the associative array’s index as variables in the scope of your code (ie. global, functions or class method):
extract($array_of_thing);
But, nowadays, I prefer to objectify any associative array, how about extracting variables from an object?
The “bad news” is the extract function need an array as the parameter.
The “good news” is that PHP can easily convert object to an associative array simply by casting it:
$array_of_thing = (array) $object_of_thing;
This convertion will only create an associative array out of the public members of the object (good thing, right?).
It the reverse version of converting associative array to a default object (stdClass):
$object_of_thing = (object) $array_of_thing;
Now, all we have to do is to extract the result of the converted object, fortunately, it can be done in a single statement:
extract((array) $object_of_thing);
The business case for this, in my own purpose, might be for creating a parameter filtering or a View component.
Resources:
PHP Class ‘Virtual’ Method using External File
I learn that when we include external file within a class method, the file will run in the class’ method context thus it can access the private members of the class (using $this keyword). The included file can also have return keyword inside it.
This capability could be useful in a case like we have several classes that need to share same method, but we don’t want to put it in a parent class (for reason that we might encountering need a multiple inheritance feature), neithermore, to have it written in each classes.
File: index.php
<?php
abstract class AbstractClass
{
public function sharedMethod()
{
$helper = new ClassHelper();
return $helper->helperMethod($this);
}
}
class ClassOne extends AbstractClass
{
private $arg = 'this is class ONE.';
public function classOneMethod()
{
return include('shared_method.php');
}
}
class ClassTwo extends AbstractClass
{
private $arg = 'this is class TWO.';
public function classTwoMethod()
{
return include('shared_method.php');
}
}
class ClassHelper
{
public function helperMethod($caller)
{
// error:
// $arg = $caller->arg;
$arg = 'ClassHelper Helper Method Called, but I can\'t call the Caller private property
';
return $arg;
}
}
// program
$classone = new ClassOne();
$classtwo = new ClassTwo();
echo '<p>'.$classone->sharedMethod().'</p>';
echo '<p>'.$classtwo->sharedMethod().'</p>';
echo '<p>'.$classone->classOneMethod().'</p>';
echo '<p>'.$classtwo->classTwoMethod().'</p>';
?>
File: shared_method.php
<?php $arg = $this->arg.' Shared Method Called! I am in the class context, so I can call private property'; return $arg; ?>
For this example, we must use include rather than include_once, to make sure that everytime any class include this file it will be executed.
Result in browser:
ClassHelper Helper Method Called, but I can't call the Caller private propertyClassHelper Helper Method Called, but I can't call the Caller private property
this is class ONE. Shared Method Called! I am in the class context, so I can call private property
this is class TWO. Shared Method Called! I am in the class context, so I can call private property
![]()
This method might need a scripting language like PHP and not a valid Object-Oriented approach. I can’t really tell you when the above case will happen because it just a matter of my personal opinion right now to have the classes’ methods written as separate file. I think it could be handy in the project files not to maintain business rule inside one big class file.
This method also related to my previous post about actor-centered business logic. This way, the Actor Service could handle same request without having to share another parent class (they should already have one).
Actor-Centered Business-Logic
Ketika merancang sebuah sistem informasi umumnya kita mengikuti pola 3-tiers:
- Data Logic
- Business Logic, dan
- Presentation Logic
- Module-Centered Business-Logic adalah persepsi Business-Logic pada umumnya, saya definisikan ulang disini sebagai sebuah konsep logika yang menyusun kerangka suatu sistem kedalam modul-modul yang mandiri dengan pola pikir HAL APA SAJA yang ada dalam sistem tersebut. Contohnya: Modul Penjualan, Modul Pembelian, Modul Pengguna, Modul Keuangan, dan sebagainya.
- Actor-Centered Business-Logic saya definisikan sebagai sebuah konsep logika yang menyusun kerangka suatu sistem kedalam Aktor-Aktor mandiri dengan pola pikir SIAPA SAJA yang berada dalam sistem tersebut. User disini misalnya Aktor Guest, Actor Admin dan Aktor Member, dan lainnya jika ada. Dalam sistem berbasis web bisa dibilang jenis credential seorang pengunjung halaman pada saat itu.
Kalau dari diagramnya, terlihat Actor-Service mirip dengan Module namun terpisah secara logika bisnis. Tapi pola pikirnya tetaplah dengan Actor, bukan Module, karena kalau tetap Module maka rancangannya malah bisa menjadi module-centered generasi ke-0.
Jika diibaratkan sebuah sistem dengan pendekatan Module-centered seperti sebuah instansi yang loket-loket pelayanannya memiliki plang nama masing-masing departemennya. Ada Departemen Penjualan, Departemen Pembelian, Departemen Keuangan dan lain-lain. Cukup familiar bukan? Pengguna yang memiliki keperluan dapat mendatangi loket-loket yang bersangkutan. Idealnya, keperluan yang meliputi proses lintas departemen dapat dilayani di satu loket saja (sistem satu pintu). Orang telah berpikir bahwa kebutuhan internal harus dijalankan secara berbeda dari kebutuhan eksternal. Sehingga loket-loket dengan pendekatan ini diubah plang namanya menjadi, loket pengurusan tanah, loket pengurusan identitas, loket pengurusan pajak kendaraan dan lain-lain.
Pola pikir penulis sebelumnya masih berpusat pada pendekatan ini. Namun penulis merasa ada yang kurang tepat dalam pola pikir ini. Sekalipun nampak valid dalam cakupan perancangan sistem, ada ketidakselarasan yang terasa dalam proses pengembangan nyatanya. Salah satu masalah yang terjadi dalam proses pengembangan nyata adalah masalah pembagian tugas. Perancangan logika bisnis berbasis pendekatan ini penulis rasa juga menyulitkan dalam pembagian tugas dalam sebuah tim. Hal ini lebih cocok dihadapi dengan pendekatan jenis kedua (actor-centered).
Pendekatan Actor-Centered selayaknya sebuah instansi dengan loket-loket pelayanannya berupa orang-orang yang menjadi pendamping (-bukan perantara). kita istilahkan disini sebagai Agen. Misalnya ada agen untuk Pelanggan (Customer Service), agen untuk pengunjung baru (Receptionist), agen untuk rekanan (Sales and Marketing Agents), agen untuk internal (Office Boy/Girl). Contoh dalam sebuah aplikasi web adalah: Actor Guest, Actor Admin, dan Actor Member.
Pendekatan yang kedua ini bukanlah pengembangan atau penambahan dari pendekatan pertama. Artinya bukan sesuatu yang mungkin lebih baik. Perlu dipikirkan lebih lanjut. Cara kedua ini tidak saja hanya digunakan dalam memenuhi kebutuhan eksternal, pemenuhan kebutuhan internal juga dilayani seperti ini (sehingga tidak terjadi kerancuan dua pendekatan digunakan sekaligus). Hal ini bisa terjadi ketika daya bagi dan akses sumber daya (resource) sudah sangat cepat dan terbuka. Tidak lagi perlu dibagi menjadi departemen-departemen fisik yang awalnya untuk mengelola dokumen-dokumen fisik. Sementara pemisahan logika sumber daya nantinya diserahkan pada lapisan Data Logic-nya. Hukum/aturan (business-rule) sejatinya tidak diterapkan pada APA, tetapi kepada SIAPA.
Manfaat lain yang mungkin bisa diperoleh dari pendekatan kedua adalah adanya konsistensi desain dari awal hingga akhir. Mengurangi missing-link dalam desain dan implementasi. Namun hal ini masih dipengaruhi lagi oleh dua lapisan logika lain nantinya. Kecap, kecap…
Pohon Kategori Software di WebStore Google Chrome
Google Chrome Web Store adalah koleksi aplikasi web, atau lebih tepatnya situs aplikasi, untuk ditambahkan di halaman launcher (shortcut) di browser Google Chrome.
Pohon kategori aplikasi di Google Chrome Web Store:
- Education
- Entertainment
- Family
- Games
- Lifestyle
- News & Weather
- Productivity
- Shopping
- Social & Communication
- Utilities
- Extentions
- Themes
Pohon Kategori Software di Market.Android.com
Berikut ini Pohon Kategori software untuk OS Android di situs market.android.com.
Pohon Kategori Software di Situs Download.CNET.com
Berikut ini Pohon Kategori software untuk OS Windows di situs Download.CNET.com.
Link ke masing-masing kategori dapat dilihat di sitemap situs tersebut.


