Learn by doing …

Once again I’ve proved to myself – that I am able to learn much more when I’m doing than when I’m just reading. This time I really wanted to learn about – how to create own app like HackerRank.

Finally I’ve created usable app – which contains already several problems with different level of difficulty – which you can access via web.

If you would like to see effects – take a look: https://spolnik.github.io/JAlgoArena-UI/  https://jalgoarena-ui.herokuapp.com/ (actual version, heroku based) (sometimes you need to wait 5-10 seconds for heroku server to wake up … it’s all about being for free ;).

The simple high level architecture could be seen below:

JAlgoArena

The backend version code is in here https://github.com/spolnik/JAlgoArena and the UI is in here https://github.com/spolnik/JAlgoArena-UI/.

Below you can see screen from the UI:

Zrzut ekranu 2016-08-06 o 15.29.24

How does it work – and what did I learn?

Firstly – measuring (especially in when you only run Java – and you asses it in memory) memory and time of program is not trivial – and the final result is mainly estimation. As you need to consider initial compilation of code effort, JIT compiler and more – one time run does not return valid results.

The approach I’ve chosen (for now) is to do firstly cold run – it answers on two questions. Firstly, is code fitting time limits – if not (and because of security reasons) break the submission check and return back the time limit exceeded status. The second one is – are all test cases passing? In case of test case failure – you mainly return status of test cases indicating how many of them failed.

Zrzut ekranu 2016-08-06 o 15.35.26

After that – there is 10 times run of same program against same test cases – looking for minimum of memory usage and time which takes to run all test cases. That gives the final metric which indicates if submission is successful. I know it’s not ideal yet – but it is good start which allows to progress with other stuff (like UI 😉

The interesting part of that is – that if you would like to build leaderboard or any kind of ranking – it requires providing user management. And with user management – you have all the risks connected with security breaches – keeping passwords and mails (or maybe more info) again that comes back to me and again I realize how much of this additional things is around which makes simple things more difficult.

Going further, as I don’t want all that costs of user management coming with ability to log in – I was looking for other solution. Considering whole that project is supposed to be run on-permises – in companies where you are in the intranet and you have quite trusted environment – I will be looking for something much simpler – like just adding field where you add team name and the submission will be identified with this team name.

There is much more things to consider – like how to build ranking points system, how to do not allow on copying same code (looking for plagiarism), how to build contest around available problems, move existing UI codebase into more modern approach (now it’s simply bootstrap + JQUery), like TypeScript, React, Node.JS server (but on the other hand, making it more complex – is that must to have really?).

Anyway – it didn’t took me much to recall many stuff I’ve learned so far in technologies I’m using here and to find many new challenges I need to solve in case of moving project further.

Remember – especially for Software Engineers it’s a key to not only stay with what you do at work (usually very similar stuff through the months), reading books or taking trainings – but mainly doing own projects (or helping others), building some value through different products – that’s what takes us to the next level – and it’s really enjoyable 🙂

Advertisements

One thought on “Learn by doing …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s