Thursday, March 21, 2013

Taking JSF to a test drive

Hi,
usually I am not a web guy, my work is focused on the business logic and infrastructures. but from time to time i find myself developing some web applications since it's a very important part in any application. long time ago i usually used to work with struts but today struts is not so popular and i usually pick spring MVC for this issue. but when one of my customers wish to know more about JSF i decided to pick up the glove and take JSF 2.1 to a test drive. when i had my devlopments in struts i thought what should be better struts or JSF, in that point JSF was not mature enough but now when JSF 2.1 is already in the air i thought about giving it another chance. well JSF did make a long way since than.

Today JSF is satisfy web framework that give you everything that you need in the server side, including:
1. Full MVC framewok that simplify the nevigation and create seperation in the model, view & control.
2. cross platform rich web UI component that provide better look & feel to the application.
3. AJAX library that enable you to preform AJAX calls

so i decided to take a ride on the JSF see if the rumers are true...
well, i build some basic app and i did have some troubles but basically it looks good.
Well, the idea here is that you have new HTML tags that can be used inside the JSP page and you can inject a code to the JSP if you register the class as a component in the JSF.
this is very diffrent from struts and spring MVC since the HTML looks very diffrent.
i think that front end developers that work with HTML & javascript can find this framework a real treat since it is very much web oriented and the HTML really talks to you. However, server guys like me can find a hard time to optimize it and get full control on behind the scene of this framework.
So probably it will not be my choise as a framework but i can understand why some programmers will love it.

Wednesday, March 13, 2013

java interoperability



Hi, I would like to thank to all the participants that listen to my lecture about interoperability between java and other languages inside the JVM process. In the following link you can download the lecture presentation as well as the code of the presentation.

https://www.dropbox.com/s/hh0ys4gvbehvj0l/script.zip


Friday, March 8, 2013

Java memory leaks

Last week i visited one of my customers that had a memory problem.
His application's memory keep rising no matter how much memory they allocate for it.
Each time OutOfMemory Error has accrued the RnD advice the support to increase the memory size.
However, after few days the old OutOfMemory error happened again.
I told the RnD manager that his application suffer from memory leaks, just like C++ it's also a bug.
The RnD manager told me: "we are working in java with GC it's impossible to have memory leaks" well, in java we also may have memory leaks but it is very diffrent from C++.

In java the application will suffer from memory leaks in the following example:

 public static void main(String[] args) {
  Observable ds = new Observable();
  Main m = new Main();
  ds.addObserver(m);
  // do some work...
  // when finish work with main forget removing m from observer

 }
so in this case even if m was removed from other data structure it's still in the heap of the program. The problem is even worse when you are working with application server since you need to understand how beans released from the memory. Such bugs are difficult to detect since you don't know which object is leaked and you have to deeply understand your program in order to clean all your code. However, most of the professional profilers provide you tools to handle memory leaks and you can use them to clean your code. In addition, there are some tools in the java language and some good best practices to avoid memory leaks. so after 1 day of workshop training that i provide for this customer there are no more questions about memory leaks and the guys start working and removed most of the memory leaks from their application. Now it's work better and the customer stop complaining about the endurance of the application.

Saturday, March 2, 2013

Why using solr search engine instead of searching in DB

Next week at the 6.3 i will lecture about solr in windows azure user group here.
 and i thought it will be nice to explain why i think it's better to use search engine like solr instead of using database search capabilities or implement your own search by iterate your data structure and looking for matches. before i start counting the reasons let me say that i think solr is good but any search capabilities based on lucene framework the bible of the text search is also good enough. notice that some databases use lucene framework for there search so if you are using these capabilities maybe you don't need solr after all. So let me count some major advantages for working with solr (and lucene) 1. Performance 2. Ranking 3. Flexibility 4. Clustering & Cloud support 5. Solr is free open source Let me provide more details about each advantage
 Performance
Solr is fast, i mean very fast. millions of documents can return result in few milliseconds! this is the whole idea of indexed search engine you spend some time in indexing each string in inverted file and you get really fast search. and search must be ultra fast otherwise nobody will use it.
  Ranking
Search is not about finding is about ranking! the most important thing is search is to provide the most relevant results at the top of the search result. needless to say that the most relevant results has to return first so solr stored the data in a way that most relevant results the boosted documents will have the fastest access. Flexibility
Let's say your user type with typo or write something in singular and the word exist in plural or even write word that just sounds the same of the word. if you don't have lucene as a search framework it is almost impossible to get such results. but in solr you can add plugins for different languages that will support such cases.
Clustering  Cloud support
Today when many applications are SAAS and implements multi tenancy and sometimes you need to search on billions of documents having a tool that allow you to split your work for hundreds of nodes and allow you to work in cores for each customer you have your own core is not trivial. more than that ranking is calculated due to other documents in the system so such capabilities is very hard to implement.
 Solr is free open source
And all of this for free in easy to use interface with the ability to add your own code with very large and quality community that will help you provide enterprise search for your application.