Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, October 06, 2008

Revision Control

If you worked on software in collaboration with multiple developers, then you've probably used (or wished you used) some sort of revision control system. The Google Search Volume Index plot below suggests some trends surrounding the currently available tools.
(Note: by no means is this very scientific, due to the fact that people searching with these terms could have been searching for something entirely different.)

CVS, although huge in its time, is on the decline, while SVN, Git, and Mercurial are on the rise. I have used plenty of CVS and SVN to be ready for change. I am now using Git which I have really liked so far. If you have already been using SVN as I had, I would recommend the Git-SVN Crash course to get started quickly.

Saturday, August 02, 2008

Eclipse for Web Development

Well, I've been doing quite a bit of programming lately, however, it has been in a number of different languages. Naturally, I have considered Eclipse as a possible editor. Vanilla Eclipse is usually geared to toward Java development and can become tricky and tedious to setup for Web Development (hence the rise of Aptana). Eclipse can be great to work with, but only when you can get it working how you'd like. The following update sites may be helpful to get Eclipse setup how you hope to have it:

JavaScript
http://download.macromedia.com/pub/labs/jseclipse/autoinstall (JSEclipse)

Python
http://pydev.sourceforge.net/updates/ (PyDev)

PHP
http://update.phpeclipse.net/update/nightly (PHPEclipse)

Java Tapestry
http://m2eclipse.sonatype.org/update (Maven2)
http://jettylauncher.sourceforge.net/updates (Jetty)

Currently, all of these plugins can be loaded into a single installation of Eclipse Europa. However, I'm not sure that they are all compatible with Ganymede (latest version of Eclipse).

Saturday, May 24, 2008

Save R Plot in EPS format

Here is a code example of how to save an R plot in EPS (instead of PS):
postscript(file="testplot.eps",
paper="special",
width=10,
height=10,
horizontal=FALSE)

yvalues = runif(50)
plot(yvalues)

dev.off()
The variation is adding paper="special" and horizontal=FALSE.

Friday, May 16, 2008

Java Programming Notes

Java Programming Notes is a handy Java reference by Fred Swartz. In his words, he explains:
These Java programming notes are written to fill in missing or weak topics in textbooks that I've taught from. Many pages are useful for reference, but not as an ordered tutorial. Some pages are still rough drafts, but I'm slowly working on fixing them.

Sunday, May 04, 2008

Virtual Host Setup

To add a virtual host on your local machine (running apache), do the following two things:

1. Add a virtual host definition to your apache configuration file, like this:

<VirtualHost *:80>
ServerName sitename
DocumentRoot "/location/of/your/site/"
</VirtualHost>

2. Add a corresponding line to your HOSTS file (on my Mac, it is located at /etc/hosts).

127.0.0.1 sitename

You should then be able to access your site in any Web browser by going to:

http://sitename

This then allows you to develop locally in an environment nearer to how it will likely be deployed.

Friday, May 02, 2008

Abstract classes and Interfaces

In response to some of the questions asked in class today, I compiled some properties of interfaces and abstract classes that should help guide your choice when deciding when to use an Abstract class or an Interface as a parent class.

Neither an Interface nor an Abstract class can be instantiated. Both can be used to as a template for concrete (implemented) child classes.

Interfaces
  • example interface definition:
public interface Monkey {
public double getWeight();
public void setWeight(double w);
public void walk();
public void talk();
}
  • fields (i.e., members, variables) are not allowed
  • all methods are implicitly abstract
  • a child class can implement many interfaces in Java
  • child classes must implement all methods
Abstract Classes
  • example abstract class definition:
public abstract class Monkey {
private double weight;
public Monkey(){
}
public double getWeight(){
return weight;
}
public void setWeight(double w){
weight = w;
}
public abstract void walk();
public abstract void talk();
}
  • may have members (e.g., weight)
  • may have implemented methods (e.g., getWeight, setWeight) and abstract methods (e.g., walk, talk)
  • a child class can only extend a single parent class in Java (multiple inheritance is not allowed)
  • child classes must implement all of the parent's abstract methods
Section 4.4 in Data Structures and Problem Solving in Java discusses this more extensively. 

This talks more about when you might use one, the other, or both. Furthermore, I found some questions and answers about the two that interviewers like to use. ;)

Java Tutorials

Sun provides some excellent tutorials that cover most aspects of programming in Java. Learning the Java language is a set of tutorials, or "trails", on the following fundamental topics:
The content of these trails is also available as a book, called The Java Tutorial, Fourth Edition.