Tuesday, October 19, 2010

DevReach 18+19 October Sofia, Bulgaria (part7)


Dynamic State Storage Using the ASP.NET Provider Model

Interesting session about creating a storage for an application and making it with a unified interface.
Dealing with problems when you have same kind of storage collections.
Using the isolateUser, isolateProvider.

Nice design for his library.

HTML5 and CSS3

SVG vs Canvas
SVG is slower for animatons
Canvas is not suitable for low number of items which can be interacted with

-ms ; -o ; -moz ; -webkit ---- these are specific for certain browser, default is used otherwise

LESS - JS library that reduces and makes CSS easier when supporting different browsers
Modernizr - make your site supporting older browsers (IE6 >)

Recognize older/new browser --- the property "autofocus" -- tricky attribute

CSS3 can put round edges for rectangles; 3D shadows; rotate images ... lots of nice animation

DRY principle - Don't Repeat Yourself
Assumption Driven Programming - don't assume something instead of asking the user
Dependency Injection principle
The God class - the one great class that does everything


DevReach 18+19 October Sofia, Bulgaria (part6)


HTML 5 crash course

HTML 5 is connected with everything that is modern and flashy today. 
Introduction of iPad is in the same day as the HTML5 introduction.
Adobe vs Apple conflict.

"Apple is becoming the most important company in the US"

www.html5rocks.com - some tricks, a site recommended.

Browser vendors love HTML 5 because they don't want their products to be 'old'.
HTML 5 is pushed into the history.

HTML5 is not ready yet. It's good

The sad facts:

60% of Internet is used with IE6, IE5 and IE7 - they don't support HTML5.
60% Windows XP
15% still use IE 6.
91% of the browser users use Windows - they have the grip

Silverlight updates are quicker - they are pushed with automatic updates with Windows.

In his oppinion "Html 5 > 4"

www.html5test.com - test the browser about html5 support
Chrome - 217 + 10 bonus
IE8 - 27 + 0 bonus
Opera 10.61 - 159 + 7 bonus

Microsoft will never get 100% for ACID3 test because they don't want to support SVG fonts.

HTML5 template is with a DTD... nobody validates it with a DTD. "A pain in the ass" - quote.
AJAX was never specified.... they reverse-engineered it.
HTML5 has a spec - that makes it a lot different. The error behaviour consistent.

He simplified the HTML5... - charset, language, DTD validation - cleaner.

New semantic tags:
Old way - meaningless IDs for "div" tag
Google statistics : code.google.com/webstats about names of ID
They took the statistics and used the mostly used words and make them special words. They made the best practices rules in HTML5.

WebMatrix - interesting free tool for building web sites. Part of the WebPlatform. It's a direct competitor to PHP.
Razor + MVC  --- "in a 6 months will be the hottest thing"

"Microsoft's primary goals this year - Azure, IE9 and HTML5"

Modernizer - javascript lib for audio
html5shim .code.google.com -- javascript for adding HTML5 tags to IE6 (which doesn't support it)

html5 - audio tag
html5boilerplate - best add-on pack for html5

"Silverlight version of video is adaptive to the broadband width"

Google created a site to refer to for fonts instead of distribute them in your own site as a local copy.


DevReach 18+19 October Sofia, Bulgaria (part5)


Designing Applications in the era of Many-core Computing:

This session was about making a unparalleled program use all cores of a CPU.
The presenter was a Romanian so his program was the recipee for making goulash.
He used threading on a higher level with a structure called a Task.
A tasks can be combined to be one after another by a lambda expressions.

Building RESTful Applications with the Open Data Protocol

The last session I attended was one regarding RESTful services.
The presenter was very high-spirited and it was a joy to listen to his explanations.
So REST services is exposing a service to be accessed  via pure URL address through the browser. 
Using the HTTP methods POST GET UPDATE DELETE to access the service if you have the access rights.

He demonstrated how to connect to such a service via a client.

He created an REST service. 
He showed an easy API to do paging for the service.

It was a very nice presentation. 


Monday, October 18, 2010

DevReach 18+19 October Sofia, Bulgaria (part4)


Easing into Windows Phone 7 Development

 The presenter : "How many of you hade a Windows Mobile device"
.... some hands raised
he: "I'm sorry." :)

Fair enough...

BUG: Oops, first Windows Phone 7 glitch - the hold of search button didn't make the menu came up.

For developers:
Expression Blend 4.
Has a good emulator
You need a developer account for 99$ from Microsoft to unlock your phone, to debug your device.
You need Zune to connect to a device to test your application.

NOT GOOD: There is a 10 application limit... you have to uninstall some of your applications that you are developing...
That sounds like a pretty bad deal...

BUG: He said himself he found a bug. After a few application deployments, it says it can't deploy more applications and it gets fixed when you disconnect the USB cable and reconnect it again.
This is getting more and more interesting...

The memory usage cap - 90 MB of processing memory space.

PROBLEM: But using more memory produces strange exceptions following his words... he lost a lot of time until he thought of checking the memory usage.

There are dark/light theme for the Windows Phone 7.
He showed that it's easy to adapt your application to the theme.

Changing icons automatically when theme is changed - use AppBar.
- app bar is like a pop-up menu or the drag-menu in Android , but it's inside the application.

The emulator can be rotated in horizontal mode and rotates the icons with nice motion.

He raised the question:
- how do you display tooltips when there is no mouseOver event?
Well, his suggestion is design and for example wait for a few seconds and make a label visible.

Panorama - a huge background image which is automatically moved depending on the count of the items in the panorama.

Different sets of keyboards are available - chat keyboard, normal, etc


DevReach 18+19 October Sofia, Bulgaria (part3)


.Net tips and tricks

1. SQL injection prevention
<%: ... %> -- for ASP.net and it prevents SQL injection etc
Use it instead of <%=...%>

2. Trace it
-- better for debugging

add as a attribute in the page xml ->  
makes the other traces to be colored in red

3. Caching
http://tinyurl.com/c275vt - Update Callback

He's showing some web caching with load testing.

<% OutputCache ... - he increased the performance for a page showing database entries from 25 requests/sec to 250 req/sec.

4. use IDisposable when net using WCF
and "using()"

5. Action / Func keywords for lambda
Don't Repeat Yourself - principle :) We know it. Nothing new.
Action is for better logging.

6. Extension methods:
Search for some extension methods to improve given sites. 

7. Testing different vesions of configurations
custom config sections

8. WebForms - don't use Labels too much
9. WebForms - ViewState - be careful with its usage
- move the viewState to the bottom of the page because of bots collect a few thousand bytes from a page to scan it. Put your data to the top!

10. Some tools he uses everyday
LinqPad - linqpad.net
Reflector - reflector.red-gate.com - similar to Java Decompiler - see the source of a class file
FireBug - for Firefox
Fiddler - for IE
ViewState Decoder - http://tinyurl.com/2msmev


DevReach 18+19 October Sofia, Bulgaria (part2)


Internet Explorer 9
Roman Russev from Microsoft Slovakia is speaking about it.
fast / clean / secure / interoperable

He takes notice of the new open policy of Microsoft - the open beta releases of Win7, IE etc

Interesting features are like pinning pages from IE directly to the taskbar of Windows7.

Visual Studio 2010 Light Switch
It's all about data and screens.
It's a tool for not-developers to create business applications - making it easier.

First step - "choose a language, you can decide how are you going to deploy it later"
Next step - describe the data for the application

It looks very point-n-click.

Next step - building a screen. Just adding a template hooks the data with the look.
Many out-of-the-box stuff added like - search bar, ribbon, tabs etc...

Looks pretty nice to have all these and not work hard to implement them.


Sunday, October 17, 2010

DevReach 18+19 October Sofia, Bulgaria (part1)

Expect my comments about DevReach, .net technologies and cloud computing.
I know this site is about Java and technology but I see it as a good opportunity to check what is the competition going to present to the public.

Expect updates!


Registration went smoothly. I'm eagerly expecting the beginning of the keynote in the 13th hall.

Interesting facts:
- 2010 is the 5th DevReach and it has double the speakers, sessions and attendees than the first DevReach back in 2006.

- There will be a prize for the first registers - a free Visual Studio 2010 Ultimate

Vertigo's CEO is talking about User Experience.
He's presenting lots of sites that are streaming video.
A new Jay-Z's book has a site written on Silverlight - with lots of video, maps etc - very awesome.
Keynote "You have to learn about design!"

5 important areas for design:
- Industrial design
Surrounds us; he's talking about showers - Desing + Intent ! Everything is meant with a reasaon. "Observe and ask yourself why!"
"Developers, we are very good at accepting bad user experience. We can adapt. Common user can't."

- Usability
Jakob Nielson
How long does it take you to accomplish your goal?
"Honestly, people don't care about software" :)
"Don't make me think" - by Steve Krug --- about easy usage of products
"You could be embarrassed  by testing your product with real users..."

Fonts fonts fonts
They can make your intention wrong or extremely right and immersive.
He explains the curves of fonts... He says that the emptiness is more important than the black ink part of a letter.
Helvetica is his favourite font.

-Natural UI
-Motion graphics

Introduction of mouse - not as intuitive as touch screens! The presenter's daughter got confused... nice example!
Touch - become interesting when iPhone came out.
"Nobody wants a 15 000 $ coffee table..." :) Funny guy is making us laugh.

Oh my god!
He's showing us Windows Phone 7 and its intuitive UI
"You are not using Helvetica" :) - nice point!

Key concept is a caption (text) which is partly cut out of the screen and it MAKES you to slide to see the rest of the application.


Thursday, October 07, 2010

Java2Days Sofia Day 1 (part 6)

17:00 - 6. Google App Engine for Java Ice Penov

GAE = Google App Engine
Google Eclipse Plug-in - comfortable for developing in Java.

GAE lets you run and maintain your web applications
GAE supports Java and Python

An application will become available on *.appspot.com

Benefits and advantages of GAE:
- cloud
- free resources
- Google infrastructure for scalability
- easy integration with Google accounts and other services

(demonstrates how to create a GAE application)

GWT = Google Web Toolkit (made for JavaScript and AJAX)

GWT compiles Java to JavaScript => slower compile . That is done because it's executed in a browser.

"OK. I'm speaking with the Google cloud... I should socialize more" - after creating a Google application that sends messages via Google Talk and you can return your parameters to your application as you respond via Google Talk as well. :)

GAE is in sandbox.
- cannot write to file system
- cannot open socket to another host
- cannot open a thread
- cannot make explicit System calls like System.exit()

There is a white-list of JRE features supported by the GAE cloud. (easily googleable)
- he thinks that this is a major drawback, because you can't make your application run on your server and then associate it with the cloud.

There are some metrics services on the GAE - CPU time, request-count etc...

Out-of-the-box Services API:

- storing data is done with Google BigTable which is a NoSQL
   JDO preferred to JPA; GQL is available - no real info given for this
 ------- cannot use JOIN query and aggregation queries

-  MemCache Java API - distributed in-memory data cache
      JCache API can be used

- Mail Service - Java Mail API can be used
- XMPP - Google Talk uses this IM protocol
- Image service - resize, rotate, flip, crop
- Google Account - you can integrate openID into your GAE application

GAE and other technologies interoperabilities:
- JEE - not supported JDBC, RMI,
- other JVM languages - supported

-3rd party
--- supported - Spring, Tiles, Struts, GWT
--- not supported - Hibernate, iText, Rich(ICE)Faces

And that's it for today!
Java2Days first day is over. I hope you find these notes interesting. I wrote them as I was attending the sessions so my posts could lack enough sentences but you will forgive me :)

Unfortunately, I cannot cover Java2Days Day 2 and  share my thoughts.

Leni Kirilov

Java2Days Sofia Day 1 (part5)

Quotes from other sessions not that interesting:

JSF has no pros
Oracle + Sun =  Snoracle

16:00 - 5. Building RESTFul Web Services with Java  Vassil Popovski, VMware

REST Principles:
-- everything is a resource
-- resources have identifiers
-- uniform access
-- resources have representations
-- link things together

HTTP methods

JAX-RS - java API for rest services. The presenter says that this SRS seems readable.


JAX-RS = POJO + Annotations

Best implementation of JAX-RS is CXF

Key concepts
- resource classes - have at least 1 resource method
- resource methods - annotated with @POST @GET etc
- provider classes  - extending JAX-RS interface

More commonly-used annotations:
@Path - relative path for a resources
@Consumers / @Produces - for media types
 - produces = output
 - consumes = input
@QueryParam - inject the value of a query into a variable

- scalable solutions
- compared to SOAP is much simpler


Java2Days Sofia Day 1 (part4)

4. Mission Critical Enterprise/Cloud ApplicationsEugene Ciuran

What is Cloud  and how do we use it?
- quick deployment
- virtualize hardware
- replace data center

- turn on/off machines (virtual hardware) as needed - all you need is a credit card

- horizontal - load-balancing
- vertical - improve applications - more hardware

high availability != uptime
If your network is down and servers UP - your application is not AVAILABLE for users.

Availability scale chart
90% - one nine  = 36.5 days down
99% - two nines = 4 days down
99,9% - ... =  9 hours
... 53 minues
... 5.3 minutes
....32 sec

from 90% - 99 -- you double the resources
Each step, the cost is doubled.

The best option at the moment is 99.9%
Well, at 2008 Amazon was down for 9 hours... it cost them much.

SLA = Service Level Agreement - agreement between customer and a vendor
SLA is not a legal document!

The most important question is "What do I do when an outage happens? How do I repair a disaster?"

At the point of 5-6 nines you see that cloud will cost you as much as building your own infrastructure!!!!

Hybrid cloud architecture - some data that is not mission-critical is stored in the User part, so when that part goes down , your applications are still working.

Amazon vs Google App Engine vs Rackspace
elastic load-balancer vs static stateless calls

Interesting case study about a project not scaling and going to migrate to a cloud.

"If there is a mission-critical application/data just write it on Java... .Net is great, but if your job depends on it - just write it on Java"   - The comment to do on a Java conference :)

- introduced ESB for scaling
- although ESB has many connections, it is not the single-point-of-failure - it is the load-balancer(which was another virtual machine)

(next - page)

Java2Days Sofia Day 1 (part3)

12:00 3. A Quick Tour of Contexts and Dependency Injection for Java EE Reza Rahman

The nice looking Indian dude Reza will explain the JEE6 introduced feature  CDI / DI.

CDI/DI is the most important new feature, if we believe him.
CDI is about application orchestrations.

@Qualifier - a mechanism to introduce additional logic in a bean

The general perspective is that JEE6 applications using CDI will include lots of annotations
like @Inject, @Qualifier, @Decorator @Produces, @xxxxScoped ...etc etc - may be 20 more


Java2Days Sofia Day 1 (part2)

11:00 - 2.Introduction to Spring Integration and What's new in Spring Integration 2.0
Josh Long & Oleg Zhurakousky, VMWare

Pipes and Filters - this is the basics of Spring - similar to Linux.
=> loose coupling mechanism

(Interesting way of question->answer way to present your product. The two presenters are great!)

Channels are comfortable for postponed communication. When both sides aren't presented at the same moment in time. a.k.a publish/subscribe.

Pipes are channels
Filters are endpoints.

Message endpoint types:
Transformers  - convert payload or modify headers
Filters - discard messages based on boolean evaluation
Router - determine next channel based on content
Splitter - generate multiple messages from one
Aggregator - assemble a single message from multiple

Spring Integration - it's integrated in the Spring framework.
(long demo with small letters... not everybody sees that good and they didn't zoom it permanently...)

(next part)

Java2Days Sofia Day 1 (part1)

11Here I'm going to blog my thoughts about the sessions:

9:30 - 0. Introduction

The introduction was translated live in both English and French by two girl-students. :) They were kind of shy and inexperienced but it was funny to watch them.

Unscheduled introduction by a dude from Oracle forced the Vitosha schedule to be 30 minutes behind the other xxx2Days presentations... Great organization ...

10:00 - 1. Java EE 6 - why and how J2EE became popular again

Regarding JEE6 the new Oracle employee Alexis Pouchkine said that NetBeans is the best for JEE6 development today. Eclipse is still behind. Go go, NetBeans!

Expect more annotations in JEE6.

Ruby developers don't create applications much faster than Java developers anymore. Just 5-10% faster.

JEE6 compliant application servers are : Glassfish, Oracle's WebLogic, and a few more.

He's making a comparison between JEE5 and JEE6. JEE5 was all about making the development faster and easier, but JEE6 includes a lot of new features.

Detailed explanations for
- Bean validation
     - something like assertions with annotations for fields of beans - @Valid annotation makes validation recursive
     - you can create your own validation annotations
 - Web Profile
 - CDI - very interesting annotations for defining exact implementations and validations etc... Interesting code samples

Expect JEE7 with cloud features. If I can suppose right, I expect Java7 features as well :) That means we won't see it for another 2-3 years.


Thursday, September 09, 2010

Java 7 new feautres (part 2)

Hi there,

I'm continuing my review on the expected features from where I started them:

JSR 308: Annotations on Java types
An extension to the Java annotation syntax to permit annotations on any occurrence of a type
In my opinion, this will make Java code stranger... May be I have got used to the current Java code style, but too much @ will make it look like PHP or other languages using strange symbols.
About the feature - it could add new flexibility in checks - kinda like "throws", final ... Imagine how JUnit will change after this feature is introduced!

JSR TBD: Small language enhancements (Project Coin)
A set of small language changes intended to simplify common, day-to-day programming tasks
String in switch --- My comment is "FINALLY, GUYS!"
Automatic resource management --- Well, we all got tired of all the try-catch around code pieces using  Streams. Just makes the code larger, but not doing anything special.
Generics initialization improvement - personally, I don't mind leaving it out, but sloppy developers will make less errors.
Collection literals and array-like access - this is similar to the one above. Just for easier initialization and access.

JSR 203: More new I/O APIs for the Java platform (NIO.2)
New APIs for filesystem access, scalable asynchronous I/O operations, socket-channel binding and configuration, and multicast datagrams
The best new feature about this is the new .resolve() method, which will find the files as they are meant to be found and not force the developer to think which class loader is used at the moment etc etc... Until man encounters this problem, he doesn't know how frustrating it can be.

Update the XML stack
Upgrade the JAXP, JAXB, and JAX-WS APIs to the most recent stable versions
Actually, I don't know the exact reason behind the decision to drop the upgrade of the above-mentioned technologies, but as I use them at work on daily basis, I find this surprising. It would be great if their specifications are revised and developers at Oracle (former Sun) upgrade them to the next level, because Java API for XML will always be "modern" and the need for updates/improvements won't decrease.
Of course, I could be terribly wrong. ;)

Swing JDatePicker component
Add the SwingLabs JXDatePicker component to the platform
I have not used Swing as much as to notice that DatePicker is missing ... When I read it was to be "ADDED" I thought, "shame on you for forgetting it"! I suppose that more than half of Swing applications need date of some sort...


I'll skip intentionally the other improvements regarding class loaders, collections concurrency and Swing , because I don't find them as attractive as the ones I commented above. Here's a link to the full list.

I hope you found my comments reasonable. I am optimistic about the new Java version. I just hope the developers don't have too many problems and they don't delay the launch...

Good luck!

Leni Kirilov

Thursday, September 02, 2010

My own naming convention and what problems could arise from it

Hi, developers!

We write applications and our applications use data. We create data, edit data, store data...
Sometimes we store data on the File System. And I think that's a common practice.

Have you ever wondered how to name your files in order, not to have naming collisions or creating some temporary files with some extensions, only you as a developer, should know about ?
Have you ever encountered exceptions in your code while accessing the file system? A glitch in your code maybe?

I am going to address this issue because it's sometimes regarded as a trivial task and everybody is said to do it the right way.

1. Create states in your program 

If at runtime your program has some strict set of states that it is in, then you can be calm and happy about your design. If you can keep the state of your variables consistent, you can manipulate them as you wish and not fear some collisions. What I mean is when you invoke a method, it knows exactly what to expect - whether a String that is passed as a parameter could be null, or if it is in a special internal format, etc...

Entering methods and exiting from methods must keep the representation invariant intact and everybody should know their role in the process.

2. Keep the number of states of your program low
If you apply rule no.1, you can still mess up, if you have like ... 100 different states. Your head will be full of conditions and rules to transit from one state to the other...

 A developer should not think about more than 7 things while developing. That way he can stay focused and make always the best decisions about his design.

3. Document your states

Be honest about your program's states. Tell your colleagues. Don't be shy or overprotective , if there's this colleague who always critisize your code. If they know about the states you introduced, then they could tell you about a problem earlier and adopt those states in their modules early on.
Not to mention that at one happy moment, somebody else different from you will be supporting this code.

4. Avoid tricky (smart) code

I've seen smart code and it lead to invisible problems, reported and fixed years after the code was written and got into the final product.

- Imagine the following situation - you are passed String with the name of a file, and you must create your own temp file, where you should store your temporary data during the processing of the original file. So you create a file with

String tempName = originalFile + "temp";

And later you decide to wipe all those temp files, but since you have added "temp" at the end, you can just use
if ( "temp".equals(String.lastIndexOf(aFileName) ) {...deleteFile(); }

And you thought you deleted your files. What happens if there are files that are called "xxxtemp" by the original user? Even if you add "temp" at the end , you will get to delete both the temp and the original.

- Another smelly situation - your use case is to keep the temp files and delete all non-temp-ending files.
Ok so lets use:

fileName.replaceAll("", "temp");

So we'll discard the temp and we'll automatically get the original filename...
Wrong! What happens if all this is happening in directory "c:\temp\myfiles" ? You will get invalid file paths and another exception is thrown.

You should be very careful with these kind of situations with files.
I suggest 2 ways to avoid problems:

A) store in a collection the original files and in a new collection the references to the temp (new) files.
That way you don't need to think of weird algorithms to find temp/original files by their derivative's names.

B) if you have to think of such an algorithm be sure that it finds exactly what you want.
Back to the example with the replaceAll():
int lastIndex = fileName.lastIndexOf("temp");
fileName.replace("", "temp", lastIndex);

And this is exactly the opposite of string += otherString.

I am sure other developers have found other techniques to avoid problems but those were mine.
Feel free to share your opinion.

Leni Kirilov

Wednesday, September 01, 2010

JDK 7 new features (part 1)

Hi there,

We all know Java. Many love it, some dislike it, other actually hate it... and if they knew its weaknesses and flaws as I know some of them, well, they'd pity all the Java developers for choosing such a fragile platform and language...

 So basically , before you thought I hate Java, the thruth is just the opposite - check this blog's name :) - but I admit that Java has some veeeery bad treats and design flaws.

But why am I talking about Java flaws in a posting called "Java 7 new features" -- well , because they(the guys behind Java) try to address some of these problems , I'm also going to point some of them to you..

This list is not ordered by me - everywhere I look these features are presented in this order. I'll keep it that way for consistency.

Feature: 64/32 bit pointers support 
-- why store 32bit pointers in 64bit space, when you don't need it. The JVM will be more agile and not create empty spaces in the pointers, so less space will be required, which will help the traffic more than a local system with gigabytes of RAM. Performance boost.

Feature: Garbage-first Garbage Collection
- kills the young fast-dying generation first. and preserves objects that have survived the wipe a few times.
Result: more GC options and strategies -- performance boost.

Feature: dynamic languages in JVM
-- All can agree that Dynamic languages have big future ahead of them and that's a good reason that Java should try to adopt them and try to run them natively on a JVM. Thus making the JVM something like a universal VM for different kinds of languages. Imagine the freedom to combine different languages and techniques easily with native support and not some simulators.... no performance problems ... no interoperability problems... I really hope this is going to be implemented very professionally.

Added support for lambda functions, which could revolutionize some known patterns in the Java world - creation of an anonymous class for an interface like MouseListener and so on - now you can create a lambda implementation, pass it as an argument and inside it can be executed. This will make our Java a more interesting place. The anonymous-class design that was being forced because of the lack of such a feature and it's not intuitive at all. Let's see where this will get us.

Feature: Java modularity - Project Jigsaw
This project, in my opinion, will be an improvement, which will improve our Java experience. But what exactly is the problem? What do you mean with "Java modularity" ? Java is already modular, some will say... Well, it isn't.

Just check your local JRE installation and see in the \lib\  directory the rt.jar (rt = runtime). Notice the size - using latest JDK 1.6 Update 21, the rt.jar is around 47 MB.

Yeah, 47 MB and that's a module... yeah right. Nice design, guys! Many classes must be written with lots of lines to fill those 47 MB and believe me - these 47MB in rt.jar are all classes. Who wants to say how many millions of code...

But why when I only use java.net and java.lang should my JVM also load SWING and java.beans and javax.xml ... The sad reason is that all of them are all TIGHTLY coupled...

Somehow, somebody let it all loose control and everybody started pushing shit in this .jar file... well it works, so who cares? It's not modular... again, who cares? You can't easily extract a piece of it and place it elsewhere. You can't manage your JVM RAM requirements because of required modules being all stick together and you can't separate them.

Image that you can modify your JVM depending on your business case !
Well, project JIGSAW is trying to solve exactly this problem - separating all swing, applet etc modules into separate sub-projects and decomponentizing the  rt.jar into several (hundred?) jar files.

I imagine something like a ( JVM + OSGi ) ... yeah :)

I wish the developers good luck, because of the issues that could arise, and I think it's not a trivial job.
Remember they also have to maintain the backwards operability somehow...

I see that this post has become very long, so I'm going to continue it later.

Feel free to comment, because my view on a topic could be very wrong, but I'd love if you start a discussion. Especially when the topic is Java :)

Leni Kirilov

Saturday, August 28, 2010

Java 5 and Java 6 not so popular features set

Many know about generics, collections enhancements and auto-boxing, varargs, annotations ,but there are some less popular features added to java in Java5 and Java6. I'm going to point the lights on them, because they are little treasures:

Java 5:

- Formatter class - easy to use class for proper formatting of numbers, date-time, currency etc

- Scanner class - slower but comfortable to use to read text from streams

-    java.util.concurrency.* package - atomic classes introduced. You are going to use them if you are in a concurrent environment... Also locks and some thread-safe collections

- JMX was added to J2SE --- instrumentation, management for your applications, MBeans - you name it

- Arrays.fill() -- fills an array with a value you give it. Very useful instead of writing a loop and doing it manually.

- Arrays.deepToString(); --- another great static method -- instead of writing a recursion method to print the toString method of the elements in a multi-dimensional array, you just use this method !

- JTable printing - it looks more natural to have a native printing method

Java 6:

-  Deque --double-ended queue was added as an interface in the collections package

- int[] newArray = Arrays.copyOf(anotherArray, newLength);  --- faster and cooler than System.arraycopy(..)

- drag'n'drop improved --- they made it more usable, but how exactly - I haven't tried it to tell you

- JTable sorting and filtering added

- Console class added

- new methods in File - getTotalSpace(), getFreeSpace(), getUsableSpace() --- why create a file and fill it with some data when you can first check if there is enough space in the drive to create the file in the first place?

- java.util.zip.DeflaterInputStream: Data read from this stream is compressed.
  java.util.zip.InflaterOutputStream: Data written to this stream is decompressed.

Or in normal human language - something like a Zip Streams where data is compressed . Nice! I am sure to use it next time!

- JMX was greatly fixed and update so my suggestion is to use it on this JRE6 version.

- JSR 223: Scripting for the Java™ Platform API -- This is a framework by which Java Applications can "host" script engines

So Java guys, out there, don't miss out these features and have in mind the enhancements :)


Wednesday, August 25, 2010

Dell Inspiron 1520 bugs

First of all I want to say that I'm very happy with my 2-year-old Dell laptop and his performance. This little piece of hardware (3 kg isn't that small...) has been very useful for me, writing some homeworks for the university, studying, chatting, even flirting, and of course preparing some projects connected with  Java, CPP and Python.

Anyway, but there are some flaws and I'll comment on a few of them

- strange noise

From time to the laptop starts beeping in a disturbing way... as if there is a flake of dirt in the CPU and the CPU's reading heads are registering it and the fast movement produces the squeaking sound ! Of course, that's not it, because CPU's units don't have moving parts... May be it's something in the HDD ... I hope not because I don't want lost bytes/files/hard-drives problem. It was a frightening sound the first few times, but I got used it .... because it happens quite often. May be once a month. And I'm using my notebook everyday...

- blue/black screen of death

I suppose this is due to my Windows 7 (and before was XP), but the message I got is always for a hardware malfunction and a memory dump is created. This has happened 4-5 times for these 2 years. Not good. But there was the moment I played Starcraft and it got it quite often... so may be it's a software glitch... Nevertheless it's not a
pleasant experience.

- I use Hibernate
I'm not using restart very often. I'm always hibernating and I can justify that this feature is GREAT! What hibernate does is save the state of all programs on your HDD (requires some free HDD space) and shuts down completely very quickly.
+ no power consumption compared to sleep
+ faster shut down compared to restart/shut down
+ faster start compared to restart/ shut down + start
+ all programs are already loaded and waiting for you!

People, use hibernate! Saves time and it's very nice.

A few more tricks help reduce the performance degradation:
- use programs like CCleaner to uninstall unused programs; clean registry; turn off start-up applications
- use defragmenters - your HDD becomes so unordered (fragmented) that a simple song play with Winamp makes your HDD heads travel looong distances and degrade performance. Of course all the small and constantly created/deleted files that a browser makes are "helping" for the situation. 

- DVD malfunction

In today's epoch of very fast Internet connection people need less and less CDs or DVDs storages, so basically I have almost never used my DVD and it's all in dust now. Well I tried to clean it, being careful with the lenses etc but the read speed is very low. But again may be it's a common problem when not using a device.

 - light up/down the Laptop screen on Windows 7

 When using FN+up and FN+down the display sometimes doesn't dim itself on all possible levels (8 levels of gray may be). For example 4-5 levels are active and the screen stays dark... Then you have to find the "Adjust brightness" option in Windows and using the software slider to move it and then it seems it resets which level how much darkness must set and then it manages to be from full dark to full light again...
Again this could be just a driver issue.
Later I found this to be connected with the Power plan chosen and with the cable of my AC adapter charger. When I unplug it and then plug it again, it fixes.

- Home button next to Power button

OK what's good is this button to me when I don't have Home Media Station or what was its name (a Dell software) because my laptop had not a single bit set when I bought it - completely empty (as I wanted it) and now it seems I cannot adjust what the button should do - for example open an Opera browser would be great... I'm very disappointed because I used some forum discussions solutions to setup my PC but... I failed...
Actually that was on my Win XP and now I'm going to try on Win7. Wish me luck!

I managed to set my Home Media Station button to Winamp :) Finally, I can use all buttons on my notebook.
I used this forum discussion to manage and configure the button :  link 

Leni Kirilov

Sunday, July 11, 2010

Idea: JUnit and Code coverage connection

I'm going to share my first thoughts regarding unit testing, JUnit and TDD (test-driven development). I'm sure that this won't be the last post on this subject because there is a lot that can be said and I've had a few interesting discussions with a colleagues of mine regarding the benefit of TDD and whether it is a good or a bad principle.


Here I'm going to share a thought which seems logic to me, but unfortunately have not seen it implemented yet.
I've been writing some unit tests recently and  it occurred to me that it would be nice if the JUnit was combined with code coverage and after runs of the test suites, there is a statistic that shows which test (test method), which lines of code did they cover!

Imagine if it was possible to see that - when an old test fails, it shows you which particular code it validates, so if a change in that code occurred, you can catch it immediately!

Of course there is the scenario when a change occurred in the context of the process that is tested and not the process itself and the code that could break a certain test, but nevertheless this information won't lie to you and trick you and slow you down in rooting down the real problem.

Also some monitoring of the submits to the project repository and analyzing which code fixes what test , would be the same as which test validates which lines of code.

There could be done something about that!

Some basic tips:

For NetBeans users check this link:

Check official xUnit site or Junit


Saturday, July 10, 2010

Eclipse DemoCamp 2010

Here I'm going to tell every reader what amazed me and what I think is remarkable around Eclipse DemoCamp 2010 Sofia.

First of all I would like to give my special thanks to the organizers who managed to stay in schedule through the whole event - all presentations were exact, question sessions, no power surge problems, comfortable hall and of course top-class food and beverages prepared for the breaks.

I was impressed that the president of the Eclipse Foundation presented its goals and its history and path for the future - very interesting indeed to hear it from the man who has seen it all from the very beginning and gave birth to something that is accepted as a standard in the modern world - open-source foundation which holds and nurtures different projects under the hood of Eclipse.

There were a few presenters whose names I cannot write, because I don't remember them (sorry) but they covered the following areas:
- OSGi bundled application server - Virgo
- Swordfish - framework for bundled enterprise services
- Rational - IBM's CASE non-free very functional software product
- context-depended language generator plug-in for Eclipse

1. Virgo
 I was most impressed by the Virgo application server which is constructed using the ideology of bundled products (like Eclipse IDE) and the ease and plugability at runtime of small software components called bundles. In that way you can turn on/off features at runtime with no downtime and manage dependencies between different components.
Also you can create very light and feature-set specific application servers who can for example support only Servlets (web container) and you don't care about EJBs or Web Services and all you need are simple security and logging for example.

The man presenter was very young Spring (now VMWare) developer who demonstrated the Virgo server
and it started very quickly and redeployed applications with just a click and no waiting or whatever...

Just amazing! - Believe me, you will find it amazing if you have to do an enterprise application and deploying it on a heavy proprietary application server like NetWeaver, whose architecture is just not modern anymore. The bundle concept is unknown to it. Nevertheless still an excellent application server.

Don't forget scalability - using bundles would be much easier to manage dependencies and physical separation and transport.

2. Context-dependant language generator plug-in for Eclipse
There was an amazing demo of a framework which lets you easily define your own language and reserved words for it. After that you can easily create an Eclipse project specific for your new language and even have the editor validate your syntax and semantics!

The presenter Kiril did a great job and capture the audience - he was the winner of the Demo sessions.

3. Rational
The presenter was a guy from Croatia (sorry if I am wrong) and used not 1 but 4 presentation sessions to explain what Rational can and cannot do (actually, I think it can do everything, even prepare you a sandwich...)

So basically Rational is a CASE tool which covers all aspects of software development process:
- requirements engineering
- storing requirements and managing them
- preparing architecture
- design analysis
- bug tracker and connection to various requirements
- track exceptions with real code lines and bugs
- suggest improvements based on an exception
- complex statistics and diagrams which even the presenter was confused to explain
and many more

Believe me, if you know all the features of Rational and can use it productively  you are a GOD.

Unfortunately not everybody in the audience appreciated the presenters attempt to cover high percentage of the products capabilities... His voice wasn't as clear as hoped either...


All in all I am very confident that I will attend the Eclipse Demo Camp next year and who knows - may be I'll present something of my own...


Sunday, June 20, 2010

NetBeans plugin Code Coverage "interesting" behaviour

I decided to test the plugin for code coverage for NetBeans. Created an empty test method, activated the plugin, ran the tests and when I ask for coverage statistics it said I had not ran my tests...

I lost an hour looking for the cause of this problem but at the end all was pretty innocent...

Once I implemented some actual methods and not juts an EMPTY test method , and at least 1 line of code was invoked the statistics appeared and everything was fancy and flashy and showing some numbers...

So remember - it's not the problem in your plugin! It works... (except for single test files ) but when you run all tests, it works as nice as a baby soft skin :)


NetBeans 6.8 ME removal leads to unusable NetBeans

I had installed NetBeans 6.8 the version where all possible java technologies are bundled together.

I had no problems, but I decided to deactivate and uninstall the ME plugins... huge mistake.. The whole NetBeans became an empty shell... with just a few menus to the top and a simple editor... I was greatly surprised.

The good thing is that I installed NetBeans 6.9 and it sniffed my NetBeans 6.8 and imported all projects, copied the configurations and even the plugins... And in just 5 minutes a could continue with my work having all my configurations, no need to configure all my custom changes all over again.

So in just 30 minutes I was surprised twice by the NetBeans - the good thing is that in the end everything is working how it is supposed to be working. :)

I suppose this is something that Еclipse lacks...

//later edit:
- different Eclipse installations can share configuration with the Workspaces

Sunday, June 06, 2010

Programming language popularity

I've just stumbled upon a very interesting site showing the trend through the years regarding peoples' interest in different programming languages.

You can find it here:


TIOBE says their statistics don't show that the languages compared are better/worse than the others, or that there are more Lines Of Codes written using them now.

Monday, May 24, 2010

JDK 1.6 installation problems

Today's topic is Java Developers' Kit.

I've had a peculiar problem with JDKs.  I wanted to install the latest version of JDK 1.6 update 18 at the time, but I also wanted to have JDK 1.5 so that I test my application with different compilers and runtime environments.

However there was some sort of problem with it (the source of it, I am unaware till this day) that caused my Windows  unable to detect my successful installation. I checked that on this special site java.com

I could also check it with an applet in a page - it said that I need to install java...

1. First idea - reinstall
I thought that my register was messed-up and ran CCleaner to clean it. That didn't help.

I decided to reinstall it and here's my first surprise:
After the successful uninstall and running CCleaner again (just to be sure), and decided to reinstall the JDK
I've got a very "funny" error message (something like this - I don't remember the correct caption):

"Installer has detected that you have JDK installed. Do you want to repair/reinstall it?"
If you click NO - the installer shuts down.
If you click YES - the following message appears:

"You don't have JDK installed on your machine!"

Holly shit ! Isn't that just a bit contradicting...

Obviously, the algorithm at the beginning isn't the same as the one at the end...

2. Second idea - install older version
OK. I cannot override this incorrect installation. So let's try to downgrade it a bit.
I decided to try JDK 1.6 update 17. When I run it it said:

"You have already installed a higher version of JDK" - installation finished!

Thank you very much, smart installer!

3. Third idea - ask Google
"OK stop trying to be a smart ass. There has to be somebody with the same problem that has a solution!" 
 was my thought.
Yeah, right... After many hours of searching and "smart solutions", none of them helped me.
I intend not to list them here... just too many and very customized...

One of them seemed promising to me.
Google helped me find a tool and step-by-step solution.

4. Forth idea - clean up registry 
I absolutely had no other choice than to try and clean my registry.

Including backing up my registry and using a free tool called "JavaRA"  that could help me maintain my system and Java versions and updates very well... well I tried it and it didn't help... I was very disappointed but maybe my expectations were just too great.

5. No idea - desperation
I was quite desperate that my JDK ws not correctly installed. My applets weren't working. Eclipse stopped working at a certain moment. NetBeans - too. I even had to use system restore... a total disaster.

And I just migrated to Windows 7 Pro 64bit version... which seemed nice for user but apparently not for JAVA users... Using Win XP I didn't have such problems (although I think I had a similar problem a few years ago).
but I had a workaround!!

6. The workaround  - JDK 1.7 unofficial!
Well, I was lucky I accidentally installed JDK1.7 which is still unofficial and doesn't overwrite the latest JDK 1.6. So when I installed and played around with PATH and JAVA_HOME variables and Eclipse and NetBeans configurations, I was able to continue with my Java project development.
But I was still unsatisfied, because this is just a workaround !

A developer must never be satisfied with a mere workaround!

Wednesday, May 19, 2010

NetBeans 6.8 bugs

Today I'll comment my favourite IDE for Java development - NetBeans.

Some may say that I'm a newbie and like less complicated IDE or that "true Java developers" use Eclipse - OK so be it, but I'm working on Eclipse at work and at home I'm using whatever I feel like using and NetBeans is what I like using!

So I've recently found a few bugs while developing a small application.

1. Swing forms editor bug

NetBeans is popular with its very well-made Swing UI editor and I agree with common understandings. UI forms are easy to use, can be configured in lots of ways (some of which I haven't tried yet), but satisfies my needs completely. It generates some code and locks it , so that future UI replacement/movements are still consistent with the rest of the class you are managing. Easy event handling methods and so on...

But I've had a few places I wanted to manipulate and configure the initialization of the components. NetBeans automatically creates a constructor with "init();" method call in it , but my case required to modify this init() method.

So you can click on the JComponent and click "Customize code" , which lets you modify the constructor called but not the declaration! I found this very restrictive and tried to trick NetBeans.

I had to change the place of a class from package "a" to package "b", but if I cannot change the declaration, I'm stuck. So I decided to use REFACTOR rename on the package of the problematic class. And it worked! ...
at first...

I refactored the name of the package and no problem in the UI created code.
But if you try to move 1 pixel of the UI form , it regenerates again the locked code and refreshes the metainf. xml in the netbeans project and my IDE shows an error of non-existing class/package...

I'm going to report this and get it fixed in NetBeans 6.9.

2. Main class in built .jar is missing

The next major bug I've found is already reported. I even reached the helpful guys in www.stackoverflow.com
You can find my question here ->  Main class in NetBeans bug

I'll rewrite the short description here:

You create a Java project in NetBeans 6.8 or 6.9 and build it to create a .jar file.
Even if you have set in the project settings which class contains the main() method to be executed, the build omits this configuration in the meta-inf/manifest file  after build and so the .jar is not executable.

This is easily fixed by :
- creating a metainf.mf file in root of your project
- the file contains something like

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01 (Sun Microsystems Inc.)
Main-Class: com.example.MainClass
Class-Path: lib/lib1.jar lib/lib2.jar

- editing the nbproject/project.properties  file
- add manifest.file=manifest.mf
- save and rebuild

This solved my problem and thanks a lot to the NetBeans and stackoverflow society so quickly.


Tuesday, May 18, 2010

Laptop battery preservation tips

I've made some research regarding laptop Lithium-Ion batteries, because I was concerned, that if I don't use it properly, I might damage the battery of my brand new laptop

I've find a few nice resources with plenty of explanation in the Internet but nobody said his/her suggestion was the true thing. So I decided to try a few strategies myself out.

Here's my story and make your own conclusions out of it:

I bought a Dell Inspiron 1520 back in 2008 September. It has a 9-cell battery Lithium-Ion.

It was said to be possible to work for 3 hours with normal usage on "power management settings" and I have tried it and it proved to be true. And I wanted to keep it this way for as long as possible.

I mainly use my laptop as a "desktop laptop" and it's constantly plugged to the AC adapter.
  • The idea was to discharge the battery to 30-50% and put it in a cold place (refrigerator) - this way it is supposed to be best preserved for a long time.
I decided to remove the battery and stick with purely AC power, but after a few accidental power cable plug-out ... I decided it's not such a good idea. The UPS feature is essential! 

The next idea proved to be more successful. I've put reminders every 2 weeks to use my laptop on battery only and drop it just under 50% of charge. This is somewhat of an exercise for the battery and it doesn't "forget" how to charge/decharge.
  • I put 2 week reminders in Google Calendar to use laptop on battery only till 50% battery capacity.

I have used this technique for the last 24 months. I'm using these days the laptop more on battery only and it survives more than 2:30 hours. That is with slightly dimmed screen and power settings ON, Windows 7 and wireless put on. I'm using it as if it's on AC power.

So I think this little technique has helped me.
Comparison with a friend of mine using a Sony laptop only on AC power and now he says it manages to keep it on battery for about an hour. What a difference!

Piece of advice:
This strategy helped me, but can be harmful for your laptop and/or battery ! Do this on your own risk!
(I'm obliged to write this... )


Sunday, May 16, 2010

Skype timestamp bug


I will now tell you more about the Skype bug I recently discovered. It's pretty easy to reproduce it.

All you need is a Skype chat conversation that has entries let's say, for the last 15 minutes.
And now you go to your clock time/date of your Windows (haven't tried it for Linux but I guess the result will be the same) and change it 15 minutes to the past.

Now you chat some more! The strange thing you should notice is that your 'new' entries are put between your other chat entries! This happens simply because they are ordered with key the time these entries are made.

So if you are chatting with Skype and decide to play with your clock , you will notice this strange behaviour.

Don't change your clock settings unless you want your chat history scrambled. The Skype folks should document this somewhere.


Saturday, May 15, 2010

Windows 7 Pro 64bit bugs

Hi, again,

I'm sharing my findings regarding Windows 7. I'm using Win7 Pro edition 64 bit, free for the students of my university. I thought that it's very well made and bug-free - all those open beta testing must have improved the new Microsoft OS.
It is indeed very good and a perfect successor of Win XP (I skip the unsuccessful experiment Vista), but I've found a few bugs - some very hard to find, others - hard to miss!

1. Navigation with "Back button" in Control panel.

Basically the case is the following:
- you enter the new Control Panel design - one can see some groups of settings in the center and some quick shortcuts on the left side. If you move your mouse over these links, a hand-cursor appears and if you click them, you are transferred to the corresponding menu.
How to see the bug?
- just click on a clickable content in the window (center part) and you should get to another place in the control panel.
- try to move your mouse over the left section with the quick links.
- click the BACK <-   arrow and you are back to the starting point.
- if you try to point over the quick links on the left again, some of them make the cursor change shape to hand, some of them not!
- if you click on some of these that don't make the cursor transform to hand , you will experience the bug - you are just sent to another menu, which doesn't correspond to the name of what you clicked!!! Absolutely without any reason... You can click XXX menu and get sent to YYY submenu... unpredictable feature is something one must try to avoid as best as possible.
The others that make the hand appear work OK...

2. Connection timeout leads to memory leak.

If you are using LAN network to connect to the Internet and you connect to your provider via PPPoE, you can experience this problem.

If your provider is down, but you try to connect nevertheless, it tells you something like "provider is down, try reconnect in 90 seconds" and the countdown starts...
If you have clicked "Automatic reconnect" on your connection settings, than your OS will keep repeating this for as long as you have setup... and I have set up something like 1000 - how could I predict that something wrong could happen:

- After 30-60 minutes of non-stop redialing, if you check task manager and see resources , you will notice that the process, which manages the redialing is consuming almost 1.8 GB of RAM !!! And continues growing...
Later I saw that the OS became absolutely non-responsive and even the mouse couldn't move... I haven't seen a problem like this for a long time... when you close the process, you can continue with your work, but of course very disturbing... and many nerves were wasted until I found the reason behind this.

My Internet provider had such problems for 2 days straight and I experienced this three times! I am very certain this is the reason. And I have enough RAM - 3 GB is more than enough for Win 7- 1.0 GB is taken up at start up.

- I have disabled "Automatic reconnect"
- I don't use quick links on the left, because they don't work in Control Panel (could be so elsewhere too...)
- I have created two bug reports to Microsoft site - no response and I don't expect.

For everybody who wants to report a bug to Microsoft Windows, you can do so here:
(I've spent quite some time to find this link - use it! 30 minutes now and a few hours in the past)

try this link - I have not tried this but it could work

So report whatever you see so that Windows 7 is better.
This is valid for every other software that you use!


Wednesday, May 12, 2010

Debugging Eclipse

Today I had the chance to debug some functionality in the Eclipse IDE, or to be more precise the SAP NetWeaver Developer Studio customized version of Eclipse.

The main thing about debugging is to setup your environment the right way.
There is configuration.ini file in the main directory of your IDE. Inserting specific parameters allows the NetWeaver DS to be started in debug mode and on specified port.
Then you need to start a debug session as a "Remote application" on 'localhost:port' and you are good to go.

 I managed to do that but I lost some time figuring this thing out :
- better make a copy of your IDE and not debug your IDE with the same one.

What I mean is that you can open 2 times the same IDE and debug one of them with the other but here's the tricky part. If you want to make update to a file in the IDE you want to debug, you will have to shut down both instances and start them up again. And lets suppose you have to change not 1 file but a few files, and not just 1 time, but a few times... and then you have wasted your time.

Personal advice - make a separate copy of your IDE and use it for DEBUG and leave your main IDE untouched.


Other than that, there is nothing special about it.


Just a reminder for my future posts

I'll write about the following topics in no particular order, unless somebody says explicitly that they are interested in a topic and I'll post it ASAP.

I'd like to remind myself to document my thoughts regarding these topics:

These topics will follow:
  • JDK 7 new features
    • what I like
    • what I don't like 
  • JDK 1.6 installation problems
    • hints how to solve the problems 
  • Sony PRS-600 Touch - my brand new reader (and all the fuss regarding getting it)
    • review
    • some hints, tips and tricks 
    • problems 
    • conversion tools 
  • Windows 7
    • connecting to network
    •  control panel (Back) button navigation
  • some bugs of my Dell Inspiron Laptop
    • DVD
    • strange noise 
  • Eclipse debugging
  • NetBeans 6.8 bugs
    • swing editor bugs - needs to be reported
    • main class problem
  • Laptop battery preservation  tips
    • because what I have done so far has proven me right - thoughts from experience
  • Internet Browsers
    • Opera thoughts
    • Chrome
    • Firefox
    • IE
  • Google Chrome OS
  • Android
  • Skype time stamp bug 
  • HDD partitioning problems
    • how not to make your data inconsistent because of pure mistake or lack of knowledge
  •  Test-Driven Development


Hello world!

Hello world!

This blog is going to be especially for people interested in computers, programming, Java and mobile gadgets.

I've decided to start this blog as a way to express some of my thoughts which I forget otherwise.

I hope everybody who encounters this blog, finds something interesting and valuable.

Happy reading!