One of the best explanation of the restful web architecture on the net can be found here. The concept of expanding the design from a null architecture is simply mind blowing.
Category Archives: Programming
Subversion Branch and Trunk Sync – Hands On
Subversion has got concept of branches and trunk. Usually the accepted approach is to keep the trunk stable and do all unstable work on the branch. I am going to document how you can create a branch from a workspace using the trunk of a subversion repository. Further I will show how to pull changes done on the branch back into the trunk and vice-versa.
Please replace the localhost:8443
with your subversion URL, the /svn/cjpcs_repo/trunk
with your trunk folder and the /svn/cjpc_repo/branches/temp/abhinav
with your intended branch folder.
First we create a branch from a workspace checked out to trunk. In this snippet we are creating a shallow copy of the trunk into a branch.
svn copy https://localhost:8443/svn/cjpc_repo/trunk https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav -m "Created a personal branch for abhinav"
In order to start using the branch we need to checkout the branch into a workspace. In this snippet are checking out the branch into the current folder.
svn checkout https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav .
Now you can make some changes on the branch workspace and commit it. Now we need to merge the changes done on branch into the trunk. So go to the trunk workspace and execute the following command. The first command updates the trunk. The second command pulls in all the changes from the branch into the current workspace. If the merge causes some conflicts you need to resolve it manually.
svn update
svn merge https://localhost:8443/svn/cjpc_repo/branches/temp/abhinav
Now commit the merged changes into the trunk. The first command commits the merges done into the trunk and the second command basically confirms the merge.
svn commit -m "Merging changes from the branch"
svn log
That’s it. Your trunk is updated with the changes done on the branch. The same approach can be applied for updating the branch with all the changes on the trunk. The following short snippet summarizes the commands you should execute in your branch workspace to achieve a sync with trunk. If there are conflicts in the merge you need to resolve that manually.
svn update
svn merge https://localhost:8443/svn/cjpc_repo/trunk
svn commit -m "Merging changes from the trunk"
Creating console based applications in Java
Writing a console based app might sound strange to some Java programmers but for some specific purposes writing a console based application is a necessity. For example let’s say I have write an application which needs to be monitored via SSH. In that either we have to come up with some elaborate command line arguments or special purpose log files. However another approach is write the application and give it a text based GUI which is accessible via textual console like putty, konsole, xterm, gnome-terminal etc. The closes thing that comes to mind is ncurses coming from the C world. We have something similar for Java also available and based on some reports I feel that they are stable enough to be used in any production environment which have need for a light weight, low bandwidth textual client.
- Lanterna – 100% Java solution. Very interesting.
- Blacken – Not a curses library an has it’s own renderer. The API is however curses-like.
- Java Curses Library – It’s built upon the Unix curses windowing system.
- Charva – A reliable tool that allows rapid building of UI using OOP approach. Existing UI programmers will definitely like it. It however uses JNI.
Production helper utility for Java team
I have been thinking about going through some of these tools to get more productive in deploying / delivering Java based web apps to the team:
Drop Jar is a helpful tool to share jar files.
Drop Wizard is a helpful tool for delivering production read jar files.
Spring Boot allows developers to create web apps easily using convention over configuration.
Shade Plugin allows a Maven based build to overcome duplicate / incompatible versions of libraries. If you have been bitten by incompatible log files you know what I mean.
Reactive programming
Reactive Programming seems to be the rage nowadays (as observed in blogs and newsletter). Out of curiosity I looked it up and was impressed with what it is capable of. Turns out that this is a declarative approach which allow code to react to changes in referenced values.
Let’s understand it from the perspective of a spread sheet. Lets say cell A1 has the formula “=B1+C1”. Now typically we expect that if we change the value in B1 or C1 then the value of cell A1 will be updated automatically.
Keeping this example in mind now lets see how this can work in programming world. Lets say we have an expression that says A = B + C. When this expression is executed in our code then the value of A is updated whenever this expression is ‘executed’. Once this is done the value of B can be changed or the value of C can be changed without reflecting on the value of A. To enforce a ripple effect back to A like we observed for cell A1 in spreadsheet we have to devise elaborate observers / listeners on the values of B and C to update A whenever the value of B or C change. In a real life production environment this simple expression can be replaced with more complex algorithm or data flow and you have a situation which can quickly get out of hand and might be difficult if not impossible to debug.
In reactive programming we react to changes. So in the above situation the value of variable A will be updated as and when the value of B or C changes.
This concept has been well explained in a dzone article.
Eclipse Maven – Download Sources and JavaDoc
Eclipse Maven integration has improved quite a bit and I find it somewhat comparable to the excellent Maven integration provided by Netbeans. I recently required to debug third party jars and I needed their sources for this purpose and as a general practice I always download the javadoc for any third party library I use. This is easily done in Eclipse using the following approach.
Do it per project
Do it for all projects
Problem found with GWT installation on Chrome
Problem found with GWT installation on Chrome
The idea with GWT is that you need to install a Google Web Tool Kit Plugin on Chrome to realistically debug GWT application in your browser. On Firefox browser the plugin is already outdated and probably discarded so Firefox is no longer an option. However on Chrome we still have a plugin and it should work ideally. However my efforts to debug my GWT apps hit a road bump when I encountered the following error when starting chrome.
At the time of starting chrome:
In the Extensions view:
At the moment I just re-dragged the GWT plugin into chrome and resumed my work but I have a haunch that this is not the end of the problem and it will come back to haunt me. I did some search on the internet and I found the following link where people have discussed this problem. The most potent solution which I have not tried yet is listed here for future reference.
Link #1:
https://code.google.com/p/google-web-toolkit/issues/detail?id=7569
Quick fix that might help:
1. Right click on the chrome icon>Properties>Shortcut
2. Add in target: –enable-easy-off-store-extension-install
3. Open chrome and navitage to extensions ( chrome://chrome/extensions/ )
4. Drag and drop on it the plugin (should be in your download folder if you tried to install it before and didn’t succeed)
Link #2:
http://stackoverflow.com/questions/11901915/installing-gwt-plugin-in-chrome
I think the easiest way to install the plugin is, to load the google chrome Browser with the flag –enable-easy-off-store-extension-install With this flag you disable this “feature”.
Link #3:
http://techie-buzz.com/browsers/chrome-blocking-extension-apps-scripts-chrome-web-store.html
Finally Solution:
I finally gave up after trying all the above approaches and none of them actually worked. I hit the following link:
https://www.google.com/chrome/browser/?platform=win&extra=devchannel
I downloaded the latest devchannel version of Chrome and re-installed the GWT Developer Plugin. This seems to have fixed the problem, however I am not really sure how this has affected my chrome installation’s stability but atleast GWT Dev Plugin works and it’s good enough for now.
Old Games and Old Memories
I had been digging in my email account for some reasons and voila I found the binaries of two games I developed around year 2000. These games were written in FoxPro as I found FoxPro very interesting those days. I used to develop financial apps in FoxPro and I still believe that it was a good development platform albeit not suitable for game development but anyways these two were simple text based games. I just downloaded the binaries and they still work but via ‘DOSBox’ which is a Dos emulator shell for newer windows version.
I developed these games to basically promote the services of the company for which I did freelancing. I figured that with some free games floating around people would find out about this company. Actually the plan failed miserably as I don’t think we made any new contact that way. But the games still work and it feels nice to see them operating after all these years. I would have loved to tweak around the source code if I still had it 🙁 but those were the days when I had still not learnt anything about Version Control and Backups.
I still remember the pride with which I included my name ‘Abhinav Anand’ in these game titles. I loved putting my name in everything I did and I still feel that branding is important for your work.
Gradle the build and dependency management tool
I recently had a chance to evaluate and Gradle and I am impressed by the Groovy based scripting feature it provides. It is really possible to make sophisticated build scripts using scripting constructs like looping and if checks. The functionality to selectively disable parts of the build on the fly and make build decisions based on some condition really makes it a winner and a clear choice for Java based development. It has support for using Apache Maven and Apache Ant build scripts as well inside the Gradle build script which means current investment in Apache Ant and Apache Maven remains intact. I think I am going to give Gradle a serious try in my next project and if it performs as I hope for I am going to switch to Gradle for good.
I am die hard Apache Maven fan for all my Java based development and configuration need. In spite of all the criticism it has received over the years I have remained a staunch supporter of Maven. I delved in Apache Ant whenever I needed some extra punch in my Maven build scripts. The XML based configuration although at times felt very verbose but it did work and it was possible to write portable build scripts that worked everywhere. However if Gradle allows me to write Groovy based scripts inside my build script then I think its time to switch to Gradle.
JavaFX on the Horizon
When JavaFX was launched in 2007 I had thought that Sun had already lost the race of RIA and RCP platform to Silverlight and Adobe Flex. Plus the fact that JavaFX required the developer to learn a new scripting language was a big turn off. Although it’s not a big deal to learn something new but re-training an entire team on something new when a better replacement is available was simply a tough thing then. I could have designed some of my projects using JavaFX but I consistently used Swing as I felt it was the better framework.
Fast forward to 2011 JavaFX was re-launched and the need to learn a new scripting language is no longer there. It is possible to reuse developer’s Java knowledge and become productive in JavaFX. If I had to start a new Java Desktop based project I would definitely try JavaFX before delving in Swing. Agreed Swing is a proven and mature UI framework but there are limits to what Swing can do. Maybe JavaFX has a future now that Oracle is pushing JavaFX 8 later part of this year. JavaFX 2 to JavaFX 8 seems like a quantum leap in terms of version and maybe it might counter balance Swing in terms of performance and maturity, but again who knows the future 🙂
I personally think now that Silverlight is a stalled technology and it’s unbelievable that Microsoft was not able to push it to dominance. It is grimly evident with the news that Netflix ditched Silverlight in favor of HTML5. Adobe Flex looked like a clear winner 6-7 years ago but given the fact that now it is open source I think it is clear that Adobe is politely walking with away from Flex with some contributions from it’s end now and then from their ‘dedicated team’.
This brings us back to JavaFX and I must honestly say that I still find it unbelievable that it is still around and might become the UI framework of choice of Java based desktop application software. I don’t think JavaFX has a future inside browser but it might become a framework of choice for Java’s desktop requirements.
For browser based development nothing beats HTML5 I think. Love it or hate it I think it is bound to be around for considerable time to come. It however remains to be seen how well it is supported by different browser both on mobiles, tabs and desktop OS.