Sunday, April 18, 2010

Optimize For loop

[fi]

In examples below i deal with java.util.List datatype's implementations, but same repeats also in many other, especially imperiative syntax following programming languages, and also in other datatypes like arrays, map's, etc.

We can see often in programming code, and study examples following kind for-loops:

for(int i = 0; i < list.size(); i++) {
doSomething(list.get(i));
}


There isn't anything wrong in example, but if you have interested to write optimized code, recommended way to write for ( foreach ) loop looks following:

for(int i = 0, len = list.size(); i < len; i++) {
doSomething(list.get(i));
}

Upper exammple has a problem that it calls list.size() method before every iteration when variable comparison is done, this can also be wanted if it is known what it do, if like for example the size of the list is changed during iteration, but most commonly this isn't purpose.. for expression first part, which is mainly intended variable initialization, execute only once, and so in comparison the length variable is known, and it is not needed to ask again from list, which executes more processor time.

Well, mostly lists are quite small, and achieved benefit is quite minimal, but on the other hand the other syntax is small change to study, and once it has acquired, it will come straight from spinal and doesnt cause extra headache.

Furthermore list can be someway dynamizally, for example: size() method can execute database query, or something other, where benefit highlighted.

Saturday, April 17, 2010

New google docs and folders

[fi]
After long time i have spend little time with Google docs, i must admit it is great technology, but now i notice very annoying feature in folders.

If i want to create new documents to some specific folder, i can open folder, and create this new document, but they will always go as non categorized, and wont stay to my folder, instead, i have to open all items view where i can see all my files, and specify to new document to some specific folder.

I search feature from internet, and it seems that others has also same problem, and at least today there was no solutions, but i assume that googles development team will fix problem at some state

Friday, April 16, 2010

Send blogs with mobile & email

[fi]

One test more, i defined to my blog an email address where i can send mails which should be directly published in dencrypt blog.

I am writing this in my bed with Nokia E63 & opera mobile 10 beta to my gmail and now it is time to try send it..

Good luck and good night. o/

Thursday, April 15, 2010

Electronic lab Velleman EL3001

[fi]

Since childhood i have been very interested all kind electronic, technical, programming etc. stuff, even mathematics which theory i don't understand at all, but which logic i use almost every day programming all kind functions. =)

When i was younger, many times i was dreaming to buy one of those electrical labs, and study electronic basics, but i never had money or time or something was on way, and i remembered this couple day ago. I started to search from internet somekind electrical study stuff and found Velleman EL3001 electronic lab.

http://www.tequipment.net/Velleman_EL3001.html

.. so now when i am little older and have little money to spend i ordered one of those, and can't wait it come ( it will take about one week.. ), so one day i will blog something about it.

Adding attachments to blog

[fi]

Next feature what i soon started to want in this blog was ability to send attachment files, but it seems that files to able to send must be images or videos, so no jar's, zip's, etc.

Luckly we can share files with Google Docs, so what i did i created shared folder for DEncrypt attachments, and now i can just upload files to this folder and link those files to my blog.

So.. say hello with HelloWorld.scala

Change the blogger language

[fi]

After couple minutes playing with my new blog account, i wanted to change my account language to english instead finnish (maby the default came from my account?).

I couldn't find from menus anything which change it, so after little searching with google i found following link where the language can change:

http://www.blogger.com/language.g

I assume you must first be logged in before you can change your language.

DEncrypt

[fi]

Hi,

DEncrypt is blog where i will share my life, ideas, toughs, programming hints etc. for other people, and especially for myself.