Monday, April 16, 2007
Web Programming 1000
Well, I went to the University of Lethbridge and we had four-digit course numbers. So think of it as Web Programming 101 with a U of L flair.
The Eclipse IDE
In general, I like the Eclipse IDE. It's free, it's pretty rich as far as features:- Autocompletion
- API navigation
- quick switch to different classes/files
- the always-popular code-colouring/syntax-highlighting
- integration with lots and lots of different web servers
All but the last one I use quite often. I fought and I fought with the Tomcat integration plug-in. Sure, it installed just fine but I could not deploy an app to it to save my life. So, in my disappointment, I turned to ant.
Apache Ant is a program/framework which allows you to specify different targets (typically dist, deploy, test, clean) with tasks (including compilation, moving, copying, deleting, running certain programs). Gustavo, who I work with, helped me with learning Ant and I am excited with it. It means you don't have to be bound to an IDE for making your projects work (although compiling inside an IDE is a good way to work the bugs out) and your directory structure can be whatever you want it to be.
Directory Structure
I don't know standards, best-practices or conventions when it comes to directory structures. I know what tomcat wants when you deploy an application to it (since that's what I've been working on) so I have set up a directory structure that I'm comfortable with and I let my ant tasks put stuff where it needs to be.
Here's my directory structure:
Project folder
- Java
-com/org
-continue ad nauseum
The java and subfolders are where you'll find the java source code for the classes that I have written.
-Dependencies
-jars
-tlds
The dependency folder with its subfolders is where you will find the external classes/programs/libraries that I use in my project
-html
-jsp
-javascript
-html
The html folder is where you will find the front-end code - JSPs, HTMLs, javascript files, etc.
-web.xml
-struts.xml
-validation.xml
these files are stored directly under the main project directory. web.xml describes the application - entry points, etc. struts.xml does the same thing if the project is a struts 2.0 project. validation.xml describes the validation required on some web-pages. It's just an example of the xml files that will be under the main directory. Obviously there could be more.
I'm pretty much a beginner on this stuff, myself. I want to learn more about web.xml and struts.xml and figure out how to frame these files properly.
That and the specific ant tasks are what I'll write about next time.
Labels: Java, web programming 1000
Friday, February 16, 2007
Making the leap to Java 1.5
This was supposed to be a big feature that would save some typing, save some needless work and let things happen simply, the way the SUN intended.
Not so much.
There's no NULL handling behind the scenes, so with every autoboxing operation you do, you're just setting yourself up for an NPE. Forget it. Forget the three seconds of typing time you're saving and just leave the code the way it was. Obscure? Fine. Fuck it.
Don't use Objects, ever. Ever. Use primitives or you'll get some NPE you'll never chase down. The Classes have enough static members that use primitives that you'll never have to use an Object (hopefully) and then you won't have to worry about whether you're unintentionally autoboxing a stupid Object and setting yourself up for debugging hell.
Just use the primitives, man. And forget about autoboxing.
Until more later on,
Liam
This still exists?
So my first post this year in Intuitive Techniques will be this:
JAVA IS COMPLICATED.
All you people out there who say that Java is easier than C++ have no idea what you're talking about.
Sure there are a couple of things about C++'s memory management that are tricky, but Java has way more to it. Add to that the learning curve with all sorts of code-generation, frameworks, web programming and just about every kind of technology you can add and still call it a Java project and you have COMPLICATIONS.
Java-type and Java-based technologies on my current project:
Java (duh)
Ant tasks
JSP
Javascript
Apache Struts
JBOSS
Tomcat
Weblogic
Apache Struts-Bridge (it really is different from Apache Struts)
Liferay portal
Portlets
IntelliJ IDEA (which is the best IDE I've ever used)
QCommon - our own architectural framework
JUNIT
Put all of these together and you have a recipe for disaster. Somehow, though, the team I'm on has been able to keep up with a demanding schedule. I just wish I didn't feel like I was drowning most of the time.
I'll catch up. It's just a matter of when.
Yours in bugs,
Liam
(Next up: Java 1.5 -or- how to make something complicated easier to mess up.)
Labels: Java