Archive

Posts Tagged ‘Java’

So You Want To Be A Programmer. . .?

April 17, 2011 4 comments

This Article is already published in the Digital Natives Newsletter (Links In The Chain) April 15, 2011 Vol. 4 Best Practices issue

So you want to be a programmer? You want to write web and desktop applications. You want to develop software for the iPhone and the Android market You want to be a solutions provider to companies and individuals alike. Let me share tips that will help in your quest to be one of us – the geeky do-gooders!

Already Published

Like any other profession, IT requires determination, patience and willingness to persevere. The begining could be very challenging and intimidating because you might find it hard to figure out some ugly looking write-ups called “codes”. You would wonder why a line – JButton buttonObject = new JButton(“Click Me”) – should create a button with “Click Me” written on it in Java (a scripting language). You might even be thinking about wireless internet connections as some voodoo from the west.

Being a PROGRAMMER or a SOFTWARE DEVELOPER is not rocket science. It’s not as hard as many make it seem. Those codes that scare you seem to me as the easiest part of our profession. Once you understand the structure, the rules and the syntax, basically the ‘logic’ of why codes are written in programming language, the rest is easy.
Also, note that the more you code, the more you try out examples in the book you are reading, the eaiser it will be for you to master the coding techniques of the language. I remember my NIIT (an Indian school in Nigeria) days. I would always volunteer to do the coding, ever willing to help a mate identify errors in his/her code. By the end of the first semester, my coding skills was actually faultless.

Once you master coding, the rest depends on how well you can think. Don’t wait for your instructor to tell you what to do. Go ahead and give yourself a pet project. It could be as simple a project as creating a database of students in your college with information on their names, grades and activities. Build it in bits. As your knowledge grows, let the software you are building grow in functionality as well. Who knows, it just might turn out to be a gold mine for you.

In my case, the pet project I did at NIIT, Hospital Management System, kick started my career and put me on the IT radar in Nigeria. I travelled different states, met high-profile people, addressed a cross section of medical practitioners, all at the age of 22! Since then, it’s been one challenging project or the other.

You also need to start thinking like a computer. Start viewing life and events around you with an IT lens. You walk into a resturant, order a pie and a drink totalling $10. If you pay less than the total, the computer rejects. What do you think is happening there.? Consider this statement

If amount paid < 10. . . . tell customer money incomplete else
Print reciept for customer.
If a Java programmer were to right this, its simple
if(amount < 10)
{
showMessage(“Customer money incomplete”);
}
else
{
printReceipt();
}

Another example. Imagine you are playing the FIFA 2011 soccer game (Sorry, I’m a game freak 🙂 🙂 with a mate and at the end of the first half, the match analysis is displayed showing that your team had 3 corner kicks and 2 offsides. What comes to your mind? It means there is a ‘variable’ to store value for each of those game highlights. The variable is set to zero at kickoff and incremented by 1 anytime you win a corner kick or caught offside. At the end of the half, the variables are retrieved and presented to you. If you did not win a corner kick, the variable remains zero. Does it make sense?

Case Study

Bottom line here is how logically you can break down or tear apart any situation in daily life and apply it to programming. This will determine your pace of learning as well. Start paying attention to the things you normally ignore. From your ATM machine telling you “Insufficient Funds” to your webmail application returning an ‘Invalid Login’ message. The more you understand the dynamics behind these simple things, the faster it will be for you to come up with solutions to problems related to IT, technology, finance, pharma, healthcare, education and even entertainment and sports industries (think about cricket match analysis on your TV).

Again, don’t expect that you will master the syntax or grammar of coding in a day or learn computer languages immediately. The more you write them, the eaiser they are for you to recall.

Note also, that not everyone will end up being a coder, however, a good understanding of the intricacies involved will help. So, for instance, if you decide to be an IT Project Manager or an Application Specification Developer amongst other fields, you should have the basic understanding of coding and programming.

Finally, you need a writing pad. As the wind blows new ideas to your direction, write them down. What kind of idea it is, who will it affect or who are the target audience, what do you need to bring it to life, revenue generation strategies and so on, should be penned.

A good place to start learning about programming languages is here:

Java http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/

PHP http://php.net/manual/en/tutorial.php

.NET http://www.w3schools.com/aspnet/default.asp

Your comments are welcomed. . .!

javax.imageio.ImageIO and JTDS JDBC Driver to the Rescue

October 19, 2010 1 comment

A friend of mine back home in Nigeria, a VB developer hollered at me sometimes last month to ask how he can retrieve blob data containing images stored in a MS SQL database and save them to the local disk. The database contains over 6,000 records. I’m sure there is a way to achieve this in VB, apparently he does not know. . . I completed the task in minutes. . .

It’s been a long time I worked with MSSQL and I think I only used it once since I graduated from school in 2003. Don’t ask me why, ask MySQL. . .lol

First, I don’t have MSSQL installed on my laptop which means I have to write a database independent code which should work for both MySQL and MSSQL. .

I quickly setup a database, created a table and populated it some of my pictures. At the end, I had 30 records in my table. First, we run our select query. .

//To store the image ID
String imageID;

// To store the binary stream retrieved from the database
InputStream in;

//Path to save Image on local disk
String imagePath="c:\pictures\";
File file;

//Will be used to store the image;
ImageIcon icon;
Image image;

PreparedStatement st=cn.prepareStatement("select ImageID, BlobImage from tblImages");
ResultSet rs=st.executQuery();
while(rs.next())
{
	imageID=rs.getString(1);
	in=rs.getBinaryStream(2);

	//Store the retrieved image ina byte array
	byte[] b= new byte[1024];

	//Store the bytes in java.awt.Image object
	image=Toolkit.getDefaultToolkit().createImage(b);

	//Convert java.awt.Image to javax.swing.ImageIcon;

	icon= new Imageicon(image);

	//Convert the java.awt.Image to a BufferedImage
	BufferedImage bi= new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
	Graphics2d g2d= bi.createGraphics(icon.getImage(),0,0,null);

	//Create the file name. Our encoding is JPEG
	imageName= imageID+".jpg";
	file= new File(imagePath+imageName);

	//Now lets write out the image to our file path
	ImageIO.write(bi, "jpg", file);

}

This worked perfectly well with mySQL but there was a problem when he used it with MS SQL. He complained that only one image is retrieved and saved, and then the ResultSet closes. I figured out that the relationship between JDBC and MSSQL is not a rosy one. I tried JTDS driver, repackaged the application and sent to him. It worked perfect and retrieved the 6000 images in the database in 25 minutes but there was another problem. he could not log in to MSSQL with windows authentication. I sent him a dll file that was shipped with the JTDS package to paste in c:\wondows\system32 and that fixed it.

Below is the UI
Screenshot

Mark My Word

August 27, 2010 1 comment

If you a programmer. . .Mark My Word.

I know Java even though I havent been to Indonesia.
The Java I know is not in Malaysia or anywhere near Asia.
The java I know was discovered in a Coffee shop and not the one hit by Tsunami and washed ashore .
I SWING alot and I enjoy it. . .Swinging back and forth with different frameworks, components and libraries. . .
And anytime you see me not SWINGing,
i’m either preparing some JavaBeans with netBeans for the Web thing. .
JSP as the sauce and some JavaScript thing. . .
I tell you, I’m the next big thing. .
Aand when i’m stressed out,
pushing pixels is what blows me out
Rather than coding in a languages with syntax like CIN and C-OUT
or better still get on java .NET and check posts out. . .
(sighs)
Shannon Hickey, Romain Guy, Krill are those who clear my doubts. . . lol

.Enough!!! let me say the truth now. . .I’m a Java Programmer. I Swing for breakfast, JSP/Java Beans for lunch and I starve for dinner. . .U can check out some of my works here. . .you will love ’em. . .Mark My Word. . .!

Ok lets talk Islam. . . I’m a muslim and i will die as one. Islam is the reason why i’m refered to as a book worm. Islam is the reason why I’m truthful and sometimes thought a fool. Islam is the reason for loving, caring, helping and tears shedding. Islam is the reason why i know Allah the creator, not Ilah the god of the Idolator. Islam is peace which encourages me to give my heart’s piece to those in need. . .I encourage u to study Islam and find out what it is that makes us proud. .

I’m in love with Poets and poetry. Amir Suleiman from USA and Sage Hasson from Nigeria being my favorrites. . .

hiphop in its originality is equal to Poetry. . . I listen to Nigerian hip hop acts like Modenine and Modenine and Modenine alone. He’s by far the only African rapper (after ProVerb of South Africa) that awakes the mental though process. . .

So here, we will be talking Programming, Islam, poetry and Hiphop. . .

Even if u have a memory of low ram, you will still mark my word. . .!