Work
Its what defines me - not!



Frequent Visits


















Subscribe to "Work" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 

 

Wednesday, April 07, 2004
 

DNR Trout Stream Easement GIS Layer

My cube neighbor is creating a database of all the easements owned by the state along trout streams.  It will soon be available in GIS format.  That is, you can download the data and make pictures like this, which is the new data layed over arial photos.  This particular selection is Lower Gavin Brook in Stockton, MN: 


4:23:59 PM    comment []

Tuesday, April 06, 2004
 

I wanted to remove a range of items from a list using the List.subList method. I tried the following:
	// al is defined previously as ArrayList al = new ArrayList();
        List l = al.subList(20,50);
        al.removeAll(l);

That got me the java.util.ConcurrentModificationException

The documentation says that a subList is dependent on the List that it is sublisting from. So, while a sublist is open, it is manipulating the parent list and seems to have a lock on it.   Instead, you can create a brand new ArrayList and fill it with the subList, thus freeing up the sublist so that a future call can modify the original List:

	ArrayList sl = new ArrayList(al.subList(10,40));
    	al.removeAll(sl);
		

So why does

 List = myList.subList(10,30);

get you a different animal than

ArrayList temp = new ArrayList(myList.subList(10,30)); ??

because in the first snippet, I haven't instantiated a new object, I just created a reference to an existing object.   In the second snippet, I created a brand new object.  That's what the word "new" gets me.


6:06:45 PM    comment []

Friday, April 02, 2004
 

Trapping Turtles

This is a turtle tag.  If you are a turtle seller or recreational turtle trapper, all of your traps require one.   The DNR sells about 50 turtle licenses each year.   Three people here have told me they taste like chicken.  If not prepared properly they can be very high in contaminants because their fatty tissues store contaminants from their scavenger diet. 

To prepare a snapping turtle, you chop the head off and let it bleed out for 24 hours because the involuntary movements last that long.  If you don't hang them up while they are bleeding, they can crawl away without a head and get lost.  Turtle is a popular item on the menu of area restaurants west of St. Cloud.  I want to find out where I can try some.

 

 


11:13:33 PM    comment []

Thursday, April 01, 2004
 

Roland just came by the office. He is always interesting  to talk to.  His work is organizing fishing education events. He is putting together a kids fishing training event outside the Twins game on May 10.  The DNR puts on lots of great family events like this.  The schedule for all of these is on the DNR events calendar .   He also told me about two blogs by friends of his: True Life and David Anderson's Lost City.
4:02:37 PM    comment []

Monday, March 29, 2004
 

IntelliJ IDEA If you use IntelliJ 4.0 to check out projects from CVS make sure you click the "Change keyword substitution" to binary button in the CVS checkout procedure. Failure to do this could cause your project to fail to compile since the jar files will be corrupt.
3:03:37 PM    comment []

Wednesday, March 17, 2004
 

Static

 

1 exerting force by reason of weight alone without motion

2 showing little change

  • An early frustration in learning Java is the error:   non-static method foo( ) cannot be referenced from a static context
  • Perhaps you are trying to call a simple method of your class from the main() method.  The main method is a static context.  The quick solution is to instatiate your object with MyObject mo = new MyObject right inside your main method.  now you have an instance of MyObject  
  • A static variable or method is going to persist across all the objects instantiated.
  • Static means that you lose the use of the 'this' keyword because the use of 'this' implies that you have an instantiation of an object.
  • Static means that it doesn't depend on the instantiation of an instance of the object. It still exists and can be called from an instance of the object, but it can also be called without creating the object.
  • The main() method is static because you have to call it to start a java program. That is, you call it before any objects are instantiated.
  • Consider the following class: 
    public class AddMe{
    	
    	static int num = 100
    	
    	static int add(int i){
    		int sum = i+2;
    		return sum;
    	}
    }
    
  • When I want to access the variable num, I can just say, myNum = AddMe.num and get the number 100.
  • I can also instantiate AddMe am = new AddMe() and then call myNum = am.num with the same effect.
  • Same with the add method. myNum = AddMe.add(2) sets myNum to 4 and so does myNum = am.add(2)
  • During my one week java class from Sun, I completed an exercise by using all static methods. I could then call the methods just like I made function calls in PHP or VB. My solution was used as an example of bending Java to act like a procedural language. Which, in case you need to be told, was frowned upon. It avoids all the Object Oriented concepts of Java. You don't even ever need to instantiate a class!

6:55:17 PM    comment []

Tuesday, March 16, 2004
 

New Minnesota weblog.  All about canoe racing.  A Radio weblog. He works at the DNR, in fisheries no less.


11:16:55 PM    comment []

My Findings on HashMaps:
  1. A Map is one type of Collection in Java. Collections are used to hold a bunch of objects. Different Collections let you look up your objects in different ways.
  2. The special thing about Maps is that the way you look up your objects in a Map is with another object.
  3. A Map is like an associative array in PHP. It is a container for key - value pairs.
  4. To get values out of a Map, you iterate through the Map's keys and use the get() method to get the value associated with that key back out.
  5. Map is the interface, Hashmap or TreeMap is the implementation of that interface, just like ArrayList is an implementation of List. So, to make a new HashMap, you would say Map myHashMap = new HashMap();
  6. A HashMap uses the hashCode() method available to all Java objects to take the hashCode of your object so that it can quickly find it when you want it.
  7. with a HashMap, your objects will not be sorted the way you expect
  8. with a TreeMap, the objects are sorted in a way that makes sense.

12:20:32 PM    comment []

Monday, March 15, 2004
 

JavaScript Disable Links

Here is the javascript function I used to disable the link that people often click more than once:

 function disable_links(){ 

// this function disables all the links on the page 

  for(var i=0; i < document.links.length;i++)

  {

      document.links[i].onclick=function () { return false; }

      document.links[i].title = "The exam has been submitted. Please wait for results page";

  }

  return true;

}


12:52:50 PM    comment []

For two weeks I had this really frustrating problem:

When users submitted the online fisheries exam, sometimes they would get an error page while the results would be emailed with no problems. I kept testing it and never got the error. I wondered if the database was crapping out because of too many open connections, I wondered about browsers caching error pages.

Then I watched someone submit the exam. They were like, "it sometimes takes several clicks before it submits"..... click click click. It is second nature to me not to submit a form more than once, no matter how long it takes the server to process the form.

 So, when testing, click all the buttons more than once, because it's a sure bet your users will.

In any case, there should be some code that handles this problem, but I didn't write the thing, I just inherited it.


9:39:39 AM    comment []

Saturday, March 13, 2004
 

I had the hardest time using an ArrayList.  I had an ArrayList full of Fish objects and getting them out with ArrayList.get() and wanting to do some Fish type operations such as printing out data about the Fish and comparing it to another Fish.

To get the third Fish out of the ArrayList it is in, I tried

currentFish = myArrayList.get(2);

The trick is that ArrayLists (and other containers) store all objects as Objects instead of as Fish or Dogs or Cats or Cars or Strings.   This behavior happens for all types of java Collections.  So when you call an object back out of an ArrayList, you have to cast it back into whatever object it is supposed to be 

currentFish = (Fish)myArrayList.get(2);

Further confusion happens because every object has toString() over-ridden and automatically available so that when you think you are getting a string back from an ArrayList and want to print it out, it works fine.

I even had it print out the results of getClass() on the Object I was retrieving from myArrayList and even that told me it was a Fish!  But still, it was being treated like an Object until the cast.


7:57:53 AM    comment []

Thursday, March 11, 2004
 

Added notes on using IntelliJ IDEA GUI builder.
2:50:36 PM    comment []


Click here to visit the Radio UserLand website. © Copyright 2004 mcgyver5.
Last update: 4/7/2004; 4:26:26 PM.
This theme is based on the SoundWaves (blue) Manila theme.
April 2004
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Mar   May