Friday, April 24, 2015

Craft 2015

I just love it.
There is nothing comparable to the two days of technology recreation for a programmer.
Thank you for all the organizers and lecturers! It is unforgettable.
For all you poor fellows who could not make there, check out the site for the speeches!

Monday, September 29, 2014

Android on Budget

I have bought some budget Android phones for my children. It made me remember to my former phones where I had to take care of all the tiny details to get maximum power out of the machine.

The phones

Moto E

Amazing hardware for the price meets well optimized software.

Navon Mizu 502

Beast of a kind with dual SIM.

The problems

Cannot go back

To reach all the apps that I have bought on Play I have registered my very own account on their phone. One should take care though! When activating the phone the process takes time and you will not be able to turn of synchronization before it get started. When you get to turning off sync it should download a lot of information about you (calendar events, pics, etc.) already. Register first the account of the real user!
It seems to be a pain to move to a budget phone from a better one. 

State of ART

I wanted to test ART vs Dalvik. Actually the only real change was that apps cannot be moved to SD card. Do not turn on ART on a budget phone unless you know what you are doing!

SD card extension

As time went by I had to realize that there are some apps that cannot be moved to SD card. That was a bit strange to me first: it was allowed on former versions of Android. Nowadays the application providers can give their preference which does not help on phones with storage on diet.
Fortunately there is a possibility to change some preferences through adb to get into a better position.
And when you run into trouble with adb (like I did) it might be helpful to start the service as root.

No problem

Both phones are very useful, well built. It is just the memory that takes it all. At least kids have to learn taking care...

Wednesday, February 26, 2014

Unit Testing

I just have realized how far is my understanding of unit testing from my expectations.
While I was reading the book Programming Groovy, the strange feeling came that I do not seem to be professional in this area of programming. In the last 6 years I tried hard to make progress in applying Test Driven Development in my projects, but only the last year gave me some kind of peace.
Yeah, it is a process. But it took so long. And still I miss some points.
I am collecting the guides here that were helping me and I am trying to give good overview of some good testing practices.
But before we get lost in the details let us consider the reasons!

Reasoning

Besides the standard few points ("tested code is working", "test make you free to refactor", "prevents returning bugs") there are some more complex benefits of using unit tests.

Deliver Effective Code

The first thing came to my mind was that the code is always write-once-read-many. It is important to write code that is clean and can be read easily. Testing a code with lot of coupling is hard: a lot of mock code must be written and one naturally feels that it is plainly wrong. And it is even more important not to write code that is not used. Tests keep you focused on your main problem (the failing test case) and they help you avoid Featuritis.

Measure Progress

With the constant test-code-check-refactor-check cycle one can be aware of the progress of his coding. Sometimes we get lost in details and dive too deep in coding, that we miss the target. With tests onboard the target cannot be lost.
It also helps to jump into coding and avoid to much procrastination.

Share Knowledge

The unit test is a perfect example for using the given API in the manner as the creator supposed it to be used. All the funny details can be learned from the different test cases. For a programmer the code is the most effective documentation: it is terse, structured and readable.

Gain Knowledge

I also use UT for getting insight on a given API. I formulate my expectations in the form of test cases. And I even gain the possibility to debug the given behavior during real work.
That is how you gain experience by doing something.

(Feel free to add more in comments...)

Ramdisk automation

I have replaced the HDD of my laptop with SSD. The speed increase was amazing. The drawback is that the frequent compilation could use up the storage quickly.
Ramdisk was proposed to be used for cache area of browsers and I have also found some interesting posts about persistent ram disk usage.
The point was to get rid of the frequent update of the files in the target directory of my java projects (that was typically caused by mvn clean install/package).

I have put together a nice little script that replaces the current working directory with an in-memory version. It also takes care of synchronizing back the data every once in a while.

#! /bin/sh 
#
if [ -z "$2" ]
then
  echo "Usage: bin/ramdisk.sh {start|stop|sync} {dir}"
  exit 1
fi
 
case "$1" in
  start)
    mkdir -p /tmp/$2
    rsync -aF $2/ /tmp/$2
    mv $2 $2.save
    ln -s /tmp/$2 $2
    crontab -l | cat - $2/.crontab | crontab -
    ;;
  sync)
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> log/ramdisk_sync.log
    rsync -aF --delete --recursive --force /tmp/$2/ $2.save
    ;;
  stop)
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD and STOP >> log/ramdisk_sync.log
    crontab -l | sed -e "\,$2,d" | crontab -
    rm $2
    rsync -aF --delete --recursive --force /tmp/$2/ $2.save
    mv $2.save $2
    rm -rf /tmp/$2
    ;;
  *)
    echo "Usage: bin/ramdisk.sh {start|stop|sync} {dir}"
    exit 1
    ;;
esac

exit 0

It seems just good enough.
The point is that I put a .crontab file in the working directory, so each project can define its own synchronization policy.
The typical crontab file looks like this:
*/10 * * * * bin/ramdisk.sh sync proj/xpbydoing
Happy ramdisk usage!

Wednesday, August 21, 2013

SCP could fail

What could go wrong with scp?

Recently I am using Oracle Developer Day virtual machine to test Oracle DB. Transferring files between the host and the VM by scp failed as both .bash_profile and .bashrc of the oracle user contains some output commands. scp is not interactive so those lines must be commented out as the following comment points out.

Thursday, August 1, 2013

Terminator startup

Terminator is a terminal emulator for multiple platforms.
I just have replaced the gnome-terminal with it, as it has really nice and usable features.
My favorite is the possibility to create layouts and with one command I can spawn a new terminal window that is split to separate command areas. I use command prompt a lot: for git, maven, ssh or just for finding files. So it is really nice that for one project I create just one layout with all the necessary command shells that I need usually.
One point that hold me back for a while was that I wanted the separate shell prompts to start from different folders. In the layout menu there is a possibility to specify a startup command for a given terminal. It took me some time to realize though that this command replaces the terminal. So if there is no command it starts my shell. If a command is given it executes it, but the shell will not be started. So my first trial to write
cd /home/tyufi/tools/jboss
was not enough it must have been extended to
cd /home/tyufi/tools/jboss; bash
Now it works perfectly!

A complete guide can be found here.

Saturday, September 22, 2012

Agile Architect


Does it exist at all?


When we are talking about agile we can say: agile methodology, agile team, agile programmer. But who is the architect?
Architect used to be the mediator between the business and the IT. He has been used to feel safe that programmers did not fool poor users. Another part of his job was to preserve code quality and system integrity against stupid programmers.

Isn't it enough to think of programmers as lazy, dumb, bad ass guys?


With agile methodologies an era has ended: the era of quantity. Now we esteem quality. What matters more: the quality is measured by the customer, not by an abstract QA team. Agile team members (not just the programmers only) are devoted to deploy value. From this point of view who needs yet another guy to point out the relevance of quality?

We are not yet there!


The problem is that most of companies do want to change (speed up, make cheaper, stabilize) their development methodology to gain business advantage (or just catch up with the others) but their agile is just something that can be used to push their requirements (without much resistance from programmers). The problem is that most programmers do want to move from making piece of crap to make pieces of craft but their agile is just something where one can have enough time to make something real cool.
Both intents are understandable and acceptable. But agile is more! Agile is about the customer. Agile is an open, honest relationship between the participants of the project. And most people do not know that. And that is where the agile architect comes in!

Design Agile


Agile architect is the mapping tool and navigation assistant to teams in moving from traditional projects to agile projects. The destination must be estimated according to the life situation of the team, company and customer. The road must be planned to make thing more and more agile. The progress must be reflected during the ride. Off-tracking must be watched and corrected (even by recalculation of the path). That is what architects are for.
mapping icon