Wednesday, February 23, 2011

Grab the software you need.

Here's a short list of some of the things that you will need to have to follow along with me.

An actual JDK:

Okay in order to develop with Java you need a Java Development Kit.

I usually run with OpenJDK but you can always choose the Sun JDK. If you go with OpenJDK get version 6. Simply because that's all I'm going to cover for now. At some time in the near future ditch 6 for 7 but for now stick with 6, it is more tested and has fewer bugs in the JVM.

A Java EE server:

You'll need one of these in order to run your crap, er, programs. I like JBoss and I usually prefer it for EE 5 development (RedHat just released a EE 6 server but I haven't had time to test drive it). However, here I'm going to be using Glassfish v 3.0.1. It is a EE 6 server, and version 2.1.1 is a very good EE 5 server, it's what we used at work for some time. I'm going to be using the Web Profile version as opposed to the full version. You can grab that if you want but very rarely do I venture into a need for RMI-IIOP (using the server to distribute logic to clients). Later down the road I may cover RMI but for now I'm just going to cover WebEE.

A database!!:

I like MySQL. PostgreSQL is nice too. I won't get into too many details, in my clique there are some very sided opinions about which is better than the other. Do not forget to pick up the JDBC driver from whoever you choose.

A JPA library:

Glassfish comes with EclipseLink which is an awesome JPA provider. It's also the one that I will be using here. Other than it is provided with Glassfish, I know a good deal of the JPA hints for this stack, so I'm really in my zone with this. If you went out and got JBoss, you'll need to go grab EclipseLink here.

An IDE:

Okay notepad is great and all but at some point you're going to need to ditch it because it sucks as a development tool. Basically at some point everything just blends together and you spend more time trying to parse your source code with your eyes or you spend more and more time with comments to keep everything in some sort of order.

At a bare minimum you need an editor that can do syntax highlighting, this prevents all that black and white running together. One that can do auto-indentation (saves you at least five or ten minutes every day per project), auto-brackets (saves at least two or three minutes per day), and has the terminal very close by is even better (like Kate or gedit.) A full blown-out IDE like Eclipse or NetBeans can shave off thirty minutes to an hour per day per project if you get down in there and learn to really use it.

I'm going to be using NetBeans here for most of the examples. One, because it was one of the first Java IDEs I ever used and two, it was the one my college professor told us to use. See this is why Microsoft is making a killing in our college's in the Untied States, most...(never mind getting off topic).

Go get Netbeans here.


That looks like a lot to go get. Just remember that you are setting up for whatever may come your way. Aside from having some sort of code repo software (like git or so) you're basically using the same tools that a professional would be using for this task.

Well I better get myself off to bed. Cheers!

POJO extends vs implements

In Java we have two way that we implement inheritance either one extends a super class or implements an interface.

In JavaEE frameworks you will see a lot of this and understanding the difference between the two is pretty important.

Interfaces in Java have no actual code to back up the Interface. In other words implementing an interface requires you to add in all the code for the specified members in the interface. So what's the big deal then with interfaces?! They don't save you time do they? Usually an interface provides a hook into a library or a function of the EE server, so usually an interface will hook one object into another or the server proper.

Extending an object, however, provides the base class' implementation if you're feeling a bit lazy. Usually you will extend base classes to make something more specific to your use case. Going from something like a data table to an Employee data table. In Java you only get to extend one super class, as opposed to interfaces (which you can implement as many as those you want). I remember coming from all my C++ to Java and being frustrated at this.


It is also important to know about generics, generics allow your class to apply to more than one data type. For example instead of extending data table into employee data table, one could make data table generic data table<?>. Then you could say data table<Employee> or data table<Student>. Generics are extremely helpful for making common web concepts, like pagination, thumb viewers, and so on. The reason being is that the functionality doesn't change based on data type (A picture swoosher does the same thing to PNG as it would to JPG).

Finally annotations play a huge role in EE development in Java. Annotations allow a developer to add meta-data to their objects. A server can then read in this meta-data and change how it will behave with the object. Annotations only change the user's behavior not the objects. Remember that!


So why the lesson in general Object Oriented Programming? I think some people loose sight of the basics of computer science and that usually tends to lead to bad implementations of concepts.

I remember one time a person creating an interface with the action method to create a step-by-step process. I went back an implemented as a linked list style reader. People could use annotations to guide the reader like @PreCondition, @CleanUp,and of course @Action.

Of course no one is perfect, so I wouldn't say that anything on this blog is the end all, be all for implementations.

Tuesday, February 22, 2011

New Year, New Look, New Goal!

So it's a new year and I've changed the look of my Blogger account!


So I've also decided to realign my goal for info on this blog. The old stuff

will stay but I'm going to be better as keeping to one clear point, following it

through and not get side track too much.

I think it will be better overall this way.

SO! With that let's begin with the first topic.

JavaEE a broad view of what it is...

JavaEE is a collection of many different Java components to create a platform for server programming using Java (VM not language).

Basically it allows you to write software that will run and/or be distributed by servers running a JVM with the needed libraries. It is these libraries that separate JavaSE and JavaEE.

The platform is currently at version six but remember that the EE platform is a collection of components, each with their own version number.

Here is a quick table of some of the components in JavaEE 6. Now this is not a complete list, but this will cover the basics.

Component

Version

Summary

Servlet

3.0

Provides a means for a Java Object to provide a web page

Java Server Pages (JSP)

2.2

Allows the creation of Servlets using HTML files and java code embedded in the HTML code (very much like PHP)

Java Server Faces (JSF)

2.0

Provides a standard MVC library to HTML pages

Enterprise JavaBeans (EJB)

3.1

Provides a means to encapsulate business logic and deploy that logic to clients

Java Persistence API (JPA)

2.0

Provides a standard persistence layer to databases and Object Relationship Mapping (ORM).

Again this is just a brief overview of all that is in JavaEE 6.

Next post will cover POJOs and Interfaces.

Cheers!