Tuesday, February 19, 2008

Windows Embedded. Can it stand against Unix based RTOS?

I thought Unix is something that is being used in Embedded system and windows have no part in it, though I know that there is something called Windows CE (Consumer Electronics) which typically used in PDAs and smart phones. Now next version of windows CE has been released and it is called Windows Embedded. There are 3 different editions of windows Embedded.






Guess in the future Networking devices may use Windows as their RTOS. But I'm sure that Microsoft will do great job is easing the development using Windows Embedded which is some what complicated, but performance-wise time only will answer!! If you have worked in Networking domain, you might be aware that IXIA traffic generator uses Windows as it's operating system.

With these releases it is very clear that Microsoft is more interested towards mobile computing and consumer electronics and recent acquistion of Danger Inc., mobile company confirms that!!

Don't wonder if something like M-Phone is being released by Microsoft.

Sunday, January 27, 2008

Windows Work Environment Tip

If you are using windows as your working environment, it is obvious that you want to open some files in Notepad, though you don't want to open it in Notepad by default. Adding context senstive menu when you right click on a file or folder is pretty simple.

Follow these eight simple instructions to learn about how to do it. Yes, this requires editing Registry, so be becareful.

http://everything2.com/index.pl?node_id=996222

Java 2007 a look !!!

Read through some blog and came to know that Function types and closure are being added to Java standard api and syntax. It never came to my suprise.. that's because I didn't know what function types and closures are? But after reading it, I came to know that I have used function closures without knowing what they are.. It is very common in ActionScripts and Javascript.

Function type are similar to Pointer functions in C/C++. They are special data types for holding reference to functions. So know you can even have local functions. We can use other variables visible in the scope inside the function.

Monday, January 21, 2008

How many to learn?!?!

As a famous saying says "Too much of anything is not good!!", this truly applies to Java Web development frameworks. There are very many frameworks and following are some of the terms you will always find in Java Resumes:

"Java, Struts, Sprint MVC, Ant, Hibernate"

I am not expert at even any one of these. Not even struts!! So if I want to learn something it is spending my worthful time and I should get enough returns on my time! So just made a research online to see how the trends of Java Web development framework varies.

The following are some of the frameworks compared:

I cannot put most of the details/statistics here as information provided is copy righted. So you can read them here.

Certainly JSF seems to be in leading position in terms of Job creation and demand. So guess it's worth learning!!!

Happy learning!!

Looking at C# wearing Java Glass?

I always loved Microsoft products whether it is there operating system or any software development tool. The computer that I first used had windows 95 and from that Windows has always been my favorite operating system. So I have spent lot of time developing small projects only on windows (and till now!). By the time we studied Visual Basic and Java in our high school, I always loved VB, cursing Java for not having any IDE (atleast my teacher didn't introduce any Java IDE to us. But it is there at that time!). Most of the time we have to memorize the syntax of Java, where we do VB just like that. Java lab is always a big problem!! I hated Java to the core!!

But my career made me work on Java and I came to know lot of professional IDEs (eclipse) available for Java which are far better than Visual Basic IDEs. I still love Eclipse IDE more than Microsoft Visual C# express edition 2008 (never had a look at professional version though). As a fan of Microsoft, I thought to take a look at C# from the perspective of Java.

Sure C# had lots and lot of language structs and keyword to code on. But how frequently are they used? I really don't understand the reason for having a struct as well as class. But C# have the concept of Managed Pointers and also allows free pointer manipulating is allowed which is something cool! But I really don't want or expect Java to have those features. I am fine with what Java already has. But still I am learning C# is going to be fun!!!!

Happy coding!

Wednesday, January 16, 2008

finding a good programmer !!!

Please follow this link.

The author explains how to find and recruit a good programmer. I am sure this will be important to us as well when we prepare our resume..!!! After reading that I definitely seem to be a good programmer not considering the fact that the author wrote a raycast engine at 14 (I started programming at 18!)

Good bye!

Monday, January 14, 2008

Flat Button using swing

I always wonder about how people creating such a nice button and swing controls in swing. Swing provides the most customizable user interface. Though I am not expert in it, just tried myself to do something that will give me a better understanding of how all these things fit together.

All the components in swings are rendered by ComponentUI, so a component delegates the painting job to ComponentUI. For example, a JButton will be a rendered by BasicButtonUI (not exactly!). So ComponentUI which renders a component is decided based on the LAF (look & feel) selected. So to create a new look, you just create ComponentUI for all the swing components.

windows look and feel for JButton is provided by WindowsButtonUI.

When I first read, this I thought it's bit difficult to understand, actually it's pretty easy to understand. So I tried to create a Flat Button (you can think of them as buttons that appear on toolbar in standard Microsoft Office App.).

To create your own UI for Button, we start by extending MetalButtonUI, by just overriding some painting function, we can create customized LAF for the Button.

The picture below shows the button that I tried to implement.

Java code below shows how it is done:

public class JFlatButton extends JButton
{

protected PaintProperties paintProp;

public JFlatButton(String text)
{
super(text);
}

public JFlatButton(Action action) {
super(action);
}

public JFlatButton(Icon icon) {
super(icon);
}

public JFlatButton(String text,Icon icon) {
super(text,icon);
}

public void setUI(ButtonUI ui) {
// defaults
if(paintProp==null) {
paintProp = new PaintProperties();
paintProp.borderColor = Color.BLACK;
paintProp.rollOver1 = Color.WHITE;
paintProp.rollOver2 = Color.LIGHT_GRAY;

paintProp.pressed1 = paintProp.rollOver2;
paintProp.pressed2 = paintProp.rollOver1;
}
// override the UI
// always set our UI instead of platform based LAF!
super.setUI(new MetalButtonUI() {
protected void paintButtonPressed(Graphics g, AbstractButton b) {
// if back group paint required
if ( b.isContentAreaFilled() ) {
Dimension size = b.getSize();
Graphics2D g2d = (Graphics2D) g;

Paint paint = g2d.getPaint(); // save to restore

GradientPaint pt = new GradientPaint(new Point2D.Float(0,0),paintProp.pressed1,new Point2D.Float(0,b.getHeight()),paintProp.pressed2);
g2d.setPaint(pt);
g.fillRect(0, 0, size.width, size.height);

g.setColor(paintProp.borderColor);
g.drawRect(0,0,size.width-1,size.height-1);

g2d.setPaint(paint);
}
}

public void update(Graphics g, JComponent c) {
// under normal condition, don't render the background
// on roll over render my custom color
if(model.isRollover()) {
drawBG(g,c);
}
paint(g, c);
}

protected void drawBG(Graphics g,JComponent b) {
Graphics2D g2d = (Graphics2D) g;
Paint paint = g2d.getPaint(); // save to restore
GradientPaint pt = new GradientPaint(new Point2D.Float(0,0),paintProp.rollOver1,new Point2D.Float(0,b.getHeight()),paintProp.rollOver2);
g2d.setPaint(pt);
// fill button
g.fillRect(0,0,b.getWidth()-1,b.getHeight()-1);

// draw border line
g.setColor(paintProp.borderColor);
g.drawRect(0,0,b.getWidth()-1,b.getHeight()-1);

g2d.setPaint(paint); // restore
}

protected void paintFocus(Graphics g, AbstractButton b,
Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
// nothing, focus not rendered!
}
});
// override some properties
this.setBorderPainted(false);
this.setOpaque(false);
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
}

public PaintProperties getPaintProp() {
return paintProp;
}

public void setPaintProp(PaintProperties paintProp) {
this.paintProp = paintProp;
}
}

Code is self explanatory and sufficiently commented. (I don't understand some code, I will always sun's similar implementation. They are commented well! really well!!!)

After reading about this and implementing something with what I learned, really helped me to understand it clearly.

Here you can find something similar to this but with JTabbedPane .. Really good resource..

Happy swinging!!

Saturday, January 12, 2008

Permutation generator !!!!

Unintentionally I visited this site and I felt cool, so thought of sharing (or keeping it for me to use later)!! Never thought generating permutation is so easy and they say this is the fastest permutation generating algorithm.. when algorithms get efficient, always coding gets tougher.. but not this time.. Though I didn't try to write it in any programming language, but the algorithms itself looks pretty simple(especially if i do it JAVA)

Let try to find the complexity of it..

To find the permutation of 'n', it needs to know the permutation of 'n-1', which in turn needs 'n-2'
Once we have n-1 permutation for 'n', we need to duplicate each entry 'n' times and then weave 'n'.
so totally it takes 2n assuming we already know 'n-1'

for n-1 it will take 2(n-1)...

so for n : 2n + 2(n-1) + 2(n-2) + ... 2 = 2(n+n-1+...1) = 2n(n+1)/2 = n(n+1) = O(n^2).. is it right? I think so!!!

Happy analyzing !!!

Monday, January 07, 2008

Turning back @ C++ after very very long time...

After very long time, recently I tried to refresh my C++ skills. Though I never mastered C++ I have done some considerable amount of work. This includes 3D snake game using Direct X (Those good old days in college when I had lot of spare time to do these stuffs even wasting considerable amount of time !!!). I am a visual C++ beginner at that time. (no I am not a expert now.. now I don't know Visual C++ at all!) I downloaded Visual C++ express edition 2008, download was pretty fast despite downloaded file is some couple of 100 MB. Installed it and just opened it. Look and feel is really good, but started little slow (could be because of reading the feeds from Microsoft site to show on the start up page).

I created a new windows form application. I was expecting some huge code generation like MFC, but not. I tried to open the source code and found a following piece of code.

// Test.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace Test;

[STAThreadAttribute] // <-- What is this? - 1
int main(array ^args) // <--- looks like a smiley - 2
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

// Create the main window and run it
Application::Run(gcnew Form1()); // gcnew ! gcnew - garbage Collector ! - 3
return 0;
}

I couldn't even understand syntactically some 3 lines.

1. Guess it could be annotation (I was working in Java for sometime)
2. Template based collection classes (Java generics equivalent)
3. gcnew - garbage collector - wow! garbage collector in Visual C++, cool!!!

These are my assumption, I will try to explore it a little more after sometime.. I felt definitely I need some exploration to understand these things. Let us see what I am upto!!!

Happy coding!

Thursday, January 03, 2008

Strange Connection - Java with Assembly language

It might be surprising to know that it is possible to call assembly code directly from Java, even though Java doesn't even give you the freedom (rather problem) of handling pointers. (Don't say all native are assembly code after all!). It was reading this blog. I never done any JNI as such and but have some understanding of how it works. After reading this I felt like I never understood JNI completely. To understand this article to some extends you need good understanding of Java, JNI, Assembly language programming. Though I am unable to completely the follow the Assembly code, it gave me a fairly good idea about how it works. Really great article. In a similar article the author also explains about calling Java program from Assembly.. Sick !!!

Happy Coding!

Wednesday, January 02, 2008

Feel free write a buggy code...

Reading through this blog and I was amazed to see how even the most experienced programmer makes simple mistake. This blog shows that Sun's implementation of Binary search which had a bug and it was undiscovered for some 9 years..! Though this is a extreme case (binary search fails if the array contains some billion elements.. :) ), it is still a bug..!

So don't feel bad if your code has some bugs..! Just chill out!!!!

Do you love your code?

Every programmer feels happy and satisfied once he completes his project and same with me as well. I was reading through this blog and I learned we should not love our code. If you love your code, you have the following problem:

1. When you find some bug later in your code, you might hesitate to tell this to people. (appraisal at stake!)

2. You will not be open to comments or enhancements

3. You will never think about enhancing your code. We should always look for enhancement.

So I should start hating my code...!

Sunday, December 30, 2007

Swing Fuse - Style Injector

Just reading through some blogs and I found about Swing Fuse. So I just went on to read little more about it. Programming in swings for over an year, I never thought or wished you need such a feature. But when I saw Swing Fuse, I wonder how could I spent an year without even thinking something like will be required.

Swing Fuse will be very much useful when we create rich client application. Swing fuse is not for traditional swing programmer who use Swing as it comes from Sun. (like me!) But when you create rich looking applications swing fuse comes really handy. When you work with rich client apps, UI and colors are most important and it keep changing. So hard coding them in a code is not a good idea and swing fuse is the solution for this. Just inject the UI information.. That's it!! pretty cool ah! Didn't try this out.. but looks promising... More about Swing Fuse is here..

http://www.javalobby.org/articles/swing-fuse/

Keep Swinging till then.. Good bye..!

Friday, December 28, 2007

Microsoft surface

Microsoft surface is a cool technology from Microsoft and it defines a new way to interact with the computers.. Very impressive.. waiting to see it, guess it will be available in US by end of 2008 and surely will take some 1 or 2 years to reach India.

Great... Have look here!

http://www.on10.net/Blogs/larry/first-look-microsoft-surfacing-computing/Default.aspx

Java IDE wars !

When I first started Java programming in school days, I never loved Java as I love it today. That's mainly because of the lack of IDE (actually I didn't aware of one). In good old days, when we started learning Java, we used notepad to write java code. At the same time we learnt VB, which comes with a cool IDE. I never knew that such thing exist for java as well...

But my ignorance didn't last for a long time.. I came to know about Eclipse and later exposed to couple of other IDE. Still I love and use eclipse in my day to day work. I tried using Netbeans, but I didn't like it.. Some basic features like a. Progressive search (available in 6.0), b. Call Hierarchy etc. are not available in NetBeans (to name a few). There are other IDEs which I haven't used yet.. Some IDEs comes for free and other for cost.

This podcast compares the various IDEs and the feature of IDEs in 2008.. But still Eclipse rocks and I will continue to use Eclipse .....

http://www.javaworld.com/podcasts/jtech/2007/121807jtech007.html

Read-Only Collections...

Recently I was looking at some open source code and I found out that there is utility function in Collections class which could come handy. When you have mutable Collection object and you don't want anybody to edit (add/delete item) the list, you can just derive immutable version of the same object using the following function..

Collections.unmodifiableList();

If somebody tries to edit the derived list, they will get a neat UnSupportedOperationException. You might wonder why would you need such a list.. If you are working on project with some 50 odd people and you need to make sure that your list (which could be used in some other place) should not be modified by any other fellow programmer, this is the right way to do..!

Happy programming !

This could really come handy in some scenarios as I said above..

Good Bye!

Monday, October 09, 2006

Java and Vista not playing well together....



Well, we all are dreaming about vista the new operating system from MS. Eventhough we have many good news about vista, there are few bad news about it too... When the project was initially started, Vista has got hell lot of features, but as days passes by MS stop many planned features of vista, atleast for this release. I got a newsletter explaining that Aero Effect of Vista is not coming along with Java GUI stuff. Take a look at the news letter I got...

********************************

Two items at dzone.com caught my eye this week and seemed worth mentioning to you. First, barring the occurrence of some major unforeseen problem, Microsoft is just one final test version away from releasing the “golden master” of its new Vista operating system. This is really big news for both Microsoft and the industry as a whole, even if Vista has lost several of its more intriguing features during the years of its development. Vista is the next wave of big business for Microsoft and for legions of ISVs, system integrators, OEMs and resellers whose economic prospects are tied in with those of the industry leader. (Note: I have to tell you I made a Freudian slip when first typing the previous sentence, typing “bug business” rather than “big business.” Of course, “u” and “i” are very close to one another on the keyboard) Many billions of dollars are at stake with Vista, numbers so huge most of us probably cannot even begin to comprehend their scale. For Microsoft to be just one final “test version” away from finalizing its next big thing is major news for our whole industry, if not for the global economy.

The second item was a disconcerting one, at least one the surface of things. It appears that Vista and certain desktop Java applications do not play well together. One of the most prominent features of Vista is the “Aero” graphics effects that give the Vista UI its distinctive, high-gloss appearance. In testing at eWEEK Labs it was discovered that running Swing or Eclipse SWT applications can cause this slick-looking Vista eye candy to be completely disabled, at least on the recent pre-release build 5728 of Vista. If you’re interested in more details, then a nice discussion of this problem and its possible causes and solutions is available in the forums at Javalobby.

So, let’s put two and two together. Vista is just one final test version away from being released to production, and Java desktop applications are somehow disabling the slickest and most visible part of the new Vista interface. I don’t know how you feel about it, but I think this is potentially a very sticky situation. I have not heard any indication that this problem is the result of some new conspiracy involving either of the former archrivals, Sun and Microsoft. On the contrary, it seems to be a genuine case of a regrettable technical problem that is getting noticed very late in the game, perhaps too late for it to be fixed before Vista is finalized. Another interesting dzone.com link last month, “Microsoft's Process: What it takes to get a bug fixed before Vista ships” made clear how impressively difficult it is to get changes made to Vista. Judging from that description, it will be a minor miracle if this Java/Vista problem is successfully resolved. Ooops!

Courtest : http://www.javalobby.com

************************* Newsletter ends ***********************

This too from javalobby...

Interesting, it seems that in the most recent post-RC1 build of Vista (5728) when you run Java applications (either Swing based or SWT-based, like Eclipse) not only are the Aero/Glass effects disabled for the individual application, but completely disabled on the desktop until you close the Java application.

*****************************************************************

Well, some argue that it's Vista fault, it's related to OpenGL Driver...

It's related to OpenGL usage. You may need to download an OpenGL driver from Khronos that is native Vista compatible, otherwise it will an old non-Vista aware OpenGL driver which I've heard disables the Vista compositing stuff. You either have to uninstall your 3D card specific OpenGL driver and let the default MS Vista OpenGL->DirectX wrapper work, or, you need a new Vista approved OpenGL ICD.

It's not Java specific. Any OpenGL app that is windowed and not full screen will cause the problem. I think only NVidia offers a beta ICD driver for Vista that is compatible with Aero.

******************************************************************

I'm waiting for Vista... but hell i need to buy a new PC to run that.... :(