Learning Java: Day 13

Working With Swing Components

Component is the more correct term for what I've been referring to as widgets. Those are the things you put in a GUI, or the things that the user sees and interacts with. Almost every thing you can stick in a GUI extends from javax.swing.JComponent.

Chapter 13 of Head First Java covers the layout managers for JPanel and JFrame, creating scrollbars on textboxes, making lists, and finally, creating the BeatBox midi player.

Fact 1: Different layout managers have different policies and you have to memorize what they are if you want your buttons/textboxes/lists/etc to be placed where you actually want them to be.

Fact 2: BorderLayout is the default layout manager for a frame; FlowLayout is the default for a panel.

Fact 3: When you add a component to another component, the added component is controlled by the layout manager of the background component.

Three layout managers: border, flow, and box.
BorderLayout: the BorderLayout manager divides a background component into five regions (NORTH, SOUTH, EAST, WEST, CENTER). You can only add one component per region to a background controlled by a BorderLayoutManager. This is the default layout manager for a frame.

FlowLayout: the FlowLayout manager lays out components from left to right, top to bottom, in the order they were added, wrapping to a new line when needed. This is the default layout manager for a panel.

BoxLayout: the BoxLayout manager places components from top to bottom, one per line.

Most of my time spent in this chapter was typing the code for the BeatBox and then debugging it prior to compiling. Debugging might be the most useful skill I'll learn as I work my way through the book.

School is starting on September 8th.  I still have 5 more chapters and 2 appendices to work through before school begins.  I've gotta work faster!

Learning Java: Day 12

Do It Yourself Graphical User Interfaces

Chapter 12 of Head First Java  goes over the ins and outs of creating GUIs - Graphical User Interfaces. We learn to deal with Event Handling and Inner Classes while moving from command line inputs and outputs to creating our first graphical anything.

This chapter has taken me four days to get through; in part because it's a long chapter, partly because I've been busy with the house and family, but mostly because it's been difficult for me to understand.  Not to mention my self-induced buggy code. On the other hand, I'm getting MUCH better at debugging my code.

To make a very long story short:

Import the javax.swing package when you want to put a window on the computer screen.
JFrame is what makes a window to put your widget (button, text field, image, over a dozen different types) on.

An Event is what happens when the user does something with the screen widget (i.e. clicks a button.)

Each widget needs a Listener to tell the class that an event occurred.

Import java.awt.* when you want to use the java Graphics components for drawing, filling, setting colors, and manipulating those aspects of 2D drawing.

If you want more than one widget in a window, use Inner classes.

We created three versions of the midi player:
  1. The player gave a sound-only output of ascending piano notes.
  2. The player gave an output of ascending piano notes while printing "la" in the command window for each note that was played.
  3. A new window was created with a randomly placed rectangular box with randomly selected fill-color for each randomly selected piano note (64 times)
Yay! I'm finally creating graphics and sound!  It's still a little foggy but it's a start!




Learning Java: Day 11

Exception Handling
Anytime you work with computers, stuff happens. The server is down. The network is offline. The file is corrupted.  As a programmer you need to write code that can handle the bad times; problem-handling code for when you can't guarantee that the file will be in the right directory, the server will be up and running, or the Thread stays asleep. Chapter 11 of Head First Java covers this kind of problem anticipation.

We will be building a MIDI Music Player.  Over the next three chapters we'll learn to create a graphical user interface (GUI) and a multi-user BeatBox Drum Machine. Today we learn what is required to create a MIDI player and how to handle exceptions.

Risky Business
When your code calls a risky method -- a method that declares an exception -- it's the risky method that throws the exception back to you, the caller. You have to read the API docs to see if there is risky behavior in the code.  The method has to declare the exceptions it might throw. The API docs then tell you WHEN you might get that exception, such as resource restrictions because the object (in this case, the sequencer) might already be in use. It's up to you to write code to deal with the problem.

Checked Exception vs RuntimeException
RuntimeExceptions occur because you've got flaws in your code that need to be fixed before the code will compile.
Checked Exceptions happen while the program is running and are caused when a method throws an exception with the keyword throw,  followed by a new exception object:
     throw new noJuiceFastException();
Methods that might throw a checked exception must announce it with a throws Exception declaration. Methods can throw more than one exception.

Try/Catch
A try/catch block tells the compiler that you know an exceptional thing could happen in the method you're calling, and that you're prepared to handle it. The compiler doesn't care how you handle it; it cares only that you say you're taking care of it.

  • Exceptions are polymorphic
  • Write a different catch block for each exception that you need to handle uniquely.
  • Multiple catch blocks must be ordered from smallest to biggest.
Making Sounds
You need four things:
  1. Sequencer: The thing that plays the music
  2. Sequence: The music to be played...a song
  3. Track: The part of the Sequence that holds the actual information
  4. Midi Event: The actual music information (notes to play, how long, etc.)
Today we use command line arguments to experiment with sounds. Next chapter we create MIDI events using a very crude video that pulses to the beat of the MIDI music. 

Onward...

Speedy Pasta Skillet Recipe

Saturdays are busy days around our house. House-cleaning, laundry, bed-linen-changing, ironing; it's a day that calls for easy meals. This recipe is one I learned to make as a young teenager and have fed to my own family as the kids grew up.  It's always been a family favorite; it's tasty, cheap, quick to make, and can be modified to use whatever you have on hand.  It's a great main dish when you're too pooped to put much effort into cooking.

This recipe takes about 1/2 hour to make if you boil the noodles at the same time you cook the ground beef. It will feed about 5-6 people if you include a salad and another side dish.

Speedy Pasta Skillet
1 pound ground beef
1 cup onion, chopped
1 clove garlic, minced
1/2 cup green onion, chopped (optional)
1 cup eggplant, peeled and chopped (optional)
1 teaspoon oregano (optional)
1 teaspoon parsley flakes (optional)
Salt and pepper to taste
1 6-oz can tomato paste
1 cup grated cheese (optional)

1 pound rigatoni pasta, cooked to al dente

chopped tomatoes and cilantro for garnish (optional)
grated Parmesan cheese (optional)

Set a large pot of heavily salted water on the stove at high heat.  When the water comes to a boil add your pasta.  Turn the heat down to medium and allow the pasta to boil until it's still a little firm (al dente). Stir occasionally to keep the pasta from sticking to the bottom of the pan. Drain.

In the meantime, brown the ground beef, onions, green pepper, garlic and eggplant together in a large skillet. Drain any excess fat from the skillet. Season with the herbs and salt and pepper to taste. Add tomato paste to the meat and mix well.  Add the grated cheese and mix again.  Add the drained pasta to the meat and mix well.  If desired, garnish with chopped tomatoes, cilantro, and grated Parmesan cheese. 

Notes: All of the optional items are additions to the original recipe. You can use any kind of pasta: elbows, shells, wheels, tubes, whatever you have on hand.  Use any vegetable that your family likes. I've used peas instead of eggplant.  A relative uses frozen lima beans. Chopped kale, chard, or spinach would be lovely. Substitute Italian sausage for the ground beef. Use a pound of chopped mushrooms instead of ground beef for a vegetarian version. Use cheddar, mozzarella, Monterey Jack, Swiss, or something entirely different for the cheese or don't use any cheese at all. The variations are endless.

Learning Java: Day 10

Numbers and Statics
We are what we repeatedly do.  Excellence then, is not an act, but a habit.
- Aristotle
Today marks the halfway point in the book, Head First Java. Yesterday I was wondering why I was so determined to learn this programming language, especially since it is not even remotely similar to my upcoming Master's degree studies of acupuncture and Oriental medicine. Java is difficult for me to learn and frequently I've felt really, really dumb because it's taken so long to wrap my mind around some of the concepts. I've told people who've asked me why I'm bothering to learn programming, that I want to be able to create Android phone apps for use in my master's studies, so therefore I need to know Java (since the phone apps are created in Java). But I think the answer lies deeper than that. 

I want to learn Java because it's difficult for me.  I want to conquer this subject. I want to learn Java because it's just one of the many things I want to learn or do before I die. So let's get on with it...
______________________________________
STATIC
The keyword static lets a method run without any instance of the class.  This is used when you don't need to have an instance of the class (like when using the Math methods). 

You call a static method using the class name

Example:     Math.min(66,99);
You call a non-static method using a reference variable name
Example:     Werewolf Jacob = new Werewolf();
          Jacob.howl();

Static variable: value is the same for All instances of the class.
Static variables are shared.
All instances of the same class share a single copy of the static variables.
Instance variables: 1 per instance
static variables: 1 per class

FINAL means it can never change
A final variable means you can't change its value.
A final method means you can't override the method.
A final class means you can't extend the class (i.e. you can't make a subclass).

MATH
Converting a String to a primitive value ('parseInt', 'parseDouble', or 'parseBoolean'): 
     String s = "2";
     int x = Integer.parseInt(s);

Converting a primitive number into a string (easiest way is to concatenate the number to an existing string)
     double d = 42.5;
     String doubleString = " " + d;

     double d = 42.5;
     String doubleString = Double.toString(d);

FORMAT
%,d means "insert commas and format the number as a decimal integer."
%.2f means "format the number as a floating point with a precision of two decimal places."
%,.2f means "insert commas and format the number as a floating point with a precision of two decimal places."
Formatting Dates (Use java.util.Date when you want the current date and time):
%tc gives the complete date and time: String.format ("%tc", new Date()); 
          Fri Aug 17 23:58:29 HST 2012
%tr gives just the time: String.format ("%tr", new Date());
          11:58:29 PM
%tA %tB %td gives the Day of the week, month and day
     Date today = new Date();
     String.format ("%tA, %tB, %td", today,today,today)(there's an easier way but I can't get it to format correctly on this screen)
                    Friday, August 17

Use java.util.Calendar for date manipulation.
There are a LOT of methods in the Calendar API and a lot of Calendar Fields.
And we finally end with practice and exercises.  This was a very LONG chapter. My brain is fried...


Learning Java: Day 9

Constructors and the Garbage Collection
Have you ever run a software program that slowed down after you'd been working for a while, and it got so bad that you had to close the application and restart it in order to continue working?  That's what happens when the programmer doesn't pay close attention to getting rid of objects when those objects are done doing "its thing".  Those abandoned objects continue taking up RAM, so much so that eventually you run out of memory space and have to close the program in order to free the memory space up again.  Java automatically takes out the trash for you.

Chapter 8 of Heads Up Java covers how objects are created, where they live while they're alive, and how to keep or abandon them efficiently.

There are two areas of memory that are important in Java; the Stack and the Heap. 

The Heap is also known as "The Garbage Collectible Heap".  The Heap is where ALL, ALL, ALL objects live. The instance variables that belong to the object live inside their objects on the heap, too. 

The Stack is where method invocations (like go() and doStuff() and main()) along with local variables live. A local variable is alive until its method completes. A local variable is in scope only within the method in which the variable was declared.  You can only use that local variable while its method is actually running.  As soon as the method is completed, the variable is popped off the Stack and goes into garbage collection.

How Objects Are Created
  1. Declare a reference variable:                     Dog myPuppy = new Dog();
  2. Create an object                                      Dog myPuppy = new Dog();
  3. Link the object and the reference            Dog myPuppy = new Dog();

Constructors
A constructor looks and feels a lot like a method, but it's not a method.  It's got the code that runs when you say new. It's the code that runs when you instantiate an object. The thing that separates a method from a constructor is the return type. Methods must have a return type, but constructors cannot have a return type.

Overloaded constructors means you have more than one constructor in your class.  To compile, each constructor must have a different argument list.

How Long Does an Object Live?
An object's life depends exclusively on the life of the references referring to it.  If the reference is considered alive, the object is still alive on the Heap.  If the reference dies, the object will die and will be picked up by garbage collection.

3 ways to get rid of an object's reference:
  1. The reference goes out of scope, permanently 
    •  // the reference dies at the end of the method
  2. The reference is assigned another object       
    •  // the first object is abandoned when the reference moves
  3. The reference is explicitly set to null       
    •  // the first object is abandoned when the reference is 'deprogrammed'.
This chapter end with exercises, a puzzle and a five-minute mystery.

Hiking Oahu: Aiea Loop Trail

This is the beginning of my hiking series.  My health has improved since doing the juice fast so I've been increasing my exercise levels. I'd like to write weekly about different hikes around Oahu.  The Aiea Loop Trail is my first hike.
Aiea Loop Trail
Distance: 4.8 miles
Level: Easy
Time: 2 -3 hours if you are in relatively good shape
Location: At the end of Aiea Heights Drive. Follow H-1 to Moanalua Highway (Hwy 78). Take the Aiea cutoff to the third traffic light, make a right turn at Aiea Heights Drive and follow it about 3 miles up to the end of the road.
Hours: April 1 to Labor Day: 7 a.m. to 7:45 p.m
After Labor Day to March 31: 7 a.m. to 6:45 p.m.
Entrance Fees: None
Services/Facilities: Restrooms, showers, camping area, picnic tables, trash cans, drinking water, payphone, hiking trail.
Caveats: Go on a sunny day, otherwise wear boots and clothes you don't mind getting muddy.  Take drinking water. Although it is ranked easy, the trail is uneven with crisscrossing tree roots, many fallen trees that you have to cross over or go under, and there is about 1/2 mile of muddy trail even on the driest days.
Keaiwa heiau (photo from Wikipedia)

Yesterday was a sunny, cool day; perfect for hiking the Aiea Loop Trail.  This trail is located in the Kea'i'wa Heiau State Recreation Area. The Kea'i'wa Heiau is at the park entrance.

This particular heiau was a place of healing where illnesses and injuries were treated with herbs by the kahuna and his students. The heiau is thought to have been constructed in the 16th century by the Oahu chief Kahuhihewa and his kahuna Keaiwa. The 100' x 160' area is enclosed by a 4' high wall of stacked lava rock. The central halau (large thatched structure) is no longer there.

The trail is not particularly scenic although there are several spots where the forest clears and you can see out into the distance.  Most of the time you are hiking through forests. Much of the fun comes from noticing the changes in the forest types.  We counted 9 distinct forests. 

Distinct Forests on the Trail
Eucalyptus: is at the very beginning of the hike and the air is redolent with the citrus-y/menthol smell of eucalyptus. The trail is dry and easy at this point.

unripe strawberry guavas
ripe strawberry guavas
Strawberry Guava: I think this was the second forest we passed through. These plants are considered an invasive species but they provide yummy snacks along the way.  The majority of the plants held green fruit but I found several bushes that had ripe berries.  I think that most of the fruit will be ripe in October. The trail was dry and easy through this section.
Huge koa trees
twisted but alive Koa

Koa: The koa forests repeated a few times on the hike. The trees were huge, straight-trunked monsters in the protected areas and twisted, gnarled grandfathers on the windy ridges. The straight trees appeared to be over 100 feet tall. These must have been the types that were cut down and hauled off the mountains to be made into canoes.  Some of them seemed to be the girth of 4 large men.  The gnarled trees frequently had most of their foliage missing but managed to keep some growth going.
Hapu'u
Uluhe (false staghorn fern): These native ferns create thick mats of vegetation that prevent invasive plants from taking hold.  They cover entire hillsides along the trail.
Hapu'u Fern: The indigenous hapu'u were definitely not as well-represented as the hill-covering uluhe, but there were spots where they were relatively thick. Instead of crowding out other plants, the hapu'u seemed to happily share their space.

Lemon Guava: These guys fooled me at first.  I thought they were really old strawberry guava trees.  The mature trees were 30 to 40 feet tall and their leaves were about twice the size of their strawberry cousins.  The fruit were slightly larger than the strawberry guys but still tasty.
Norfolk pines

Norfolk Pine:  Gorgeous growths of these pines are found in several places along the trail. Their seeds were sprinkled all over the younger trees from the older ones above.  Seeds cover the trail in places.
Ohi'a lehua

Ohia Lehua: Another native, the lehua shows up in a couple places along the trail.  Several of the trees are pretty majestic-looking though it's hard to tell from the photo.

Bamboo: There was only one section, I think, where there was a concentration of bamboo.

yellow ginger
Kukui: These beautiful trees were mainly concentrated close to the bottom of the valley near the stream bed along with the Yellow Ginger. I could smell the ginger before I saw them.

There was about a 1/2 mile stretch of very wet trail before getting to the stream bed and then isolated spots going back up the trail.  Amazingly enough, there weren't any mosquitoes while we were there.  I'd imagine that traveling this trail right after a rain would make the entire loop a muddy slog AND filled with biting insects.
Clidemia

Edibles
As I've reviewed comments from other sites about this trail, I haven't read anything about the abundance of edibles along the way.  Besides the two types of strawberry guavas, there are also purple berries from the weed Clidemia (also known as Koster's Curse).  These prolific plants have tiny, fuzzy blueberry-like berries  a little below knee-level.  

Orange lilikoi
Orange Lilikoi: This passion fruit cousin is also known as water lemon. This plant doesn't have the three-fingered shape leaves of yellow or purple lilikoi. It isn't a prolific fruit-bearer and the fruit is rather small but it's tasty and less tart than the Yellow Lilikoi which is also found along the trail. 

Thimbleberry: This raspberry cousin is found in a few places along the trail.  The fruit is tiny but supposedly tasty.  The fruit was still white while we were there so I didn't get to sample any.

Mango: I spotted several mango trees along the trail.  I have no idea if they actually produce fruit but the potential is there.

Rose apples
Rose Apple: We found one small rose apple on the trail that had obviously fallen from it's tree.  It was tiny and not fully ripe.  These guys look a little like yellow strawberry guavas but they have a large brown seed in the middle instead of tiny guava seeds.  The fruit tastes perfume-y.

View Points
Halawa Valley and H3
There were three distinct views from the clearings.  The first lookout was of Halawa Valley with a section of the H3 freeway running through it. A bench is provided so you can sit and enjoy the view.
Kapolei area
Kapolei Area was the second scenic view.
Pearl Harbor was the third scenic view.

It was a very misty/voggy day as we hiked so my photos don't capture the beauty of the views. 

albino cricket
This was a very enjoyable trail.  We ambled along so it took us much longer than the average 2-3 hours that it takes younger people.  It was good exercise, it was interesting, and it wasn't too difficult for a recovering computer potato who spends far too much time in front of the computer.

I hope you'll enjoy the hike, too. 


Learning Java: Day 8

Interfaces and Polymorphism
Chapter 8 of Head First Java makes my head spin.  Here they explain how to use the Java keyword interface (this is not a GUI interface nor the generic word 'interface') so subclasses can inherit from multiple 'trees'. Therefore, a class from one inheritance tree can extend a class, and implement an interface, while another class might implement the same interface, but come from a completely different inheritance tree.

Did that make YOUR head spin, too?

When using interface you make all the methods abstract so that any class that is in a IS-A relationship MUST implement (i.e. override) the methods in the interface.  You use an interface when you want to define a role that other classes can play, regardless of where those classes are in the inheritance tree. Got that?

  • When you don't want anyone to make a new object of the class, mark the class with the abstract keyword
  • An abstract class can have both abstract and non-abstract methods.
  • If a class has even one abstract method, the class must be marked abstract.
  • An abstract method has no body, and the declaration ends with a semicolon (no curly braces).
  • A Java interface is like a 100% pure abstract class. It defines only abstract methods

Example from the book:
Pet
abstract void beFriendly();
abstract void play();

To DEFINE an interface:
     public interface Pet {...}    //use 'interface' instead of 'class'

To IMPLEMENT an interface:
     public class Dog extends Canine implements Pet {...}

A class can implement multiple interfaces
     public class Dog extends Animal implements Pet, Saveable, Paintable {...}

Remember: A Java class can have only one parent (superclass), and that parent class defines who you are. But you can implement multiple interfaces, and those interfaces define roles you can play.

We are still learning concepts in this chapter so there is no programming yet, just exercises and puzzles.

Hoo boy...

Learning Java: Day 7

Inheritance and Polymorphism

After two days of being too busy to work on java, I'm glad to finally be back. I begin to feel antsy if I'm away from the computer for too long.

Chapter 7 of Heads Up Java teaches inheritance and polymorphism concepts.

Inheritance should be thought of as a top down thing: children inherit from parents, not the other way around. Inheriting code from the superclass above it should have an "is a" relationship. Example (Cup is the superclass, CoffeCup is the subclass of Cup, and EspressoCup is the subclass of CoffeCup) ExpressoCup is a CoffeCup AND EspressoCup is a Cup.

Inheritance means you avoid duplicate code by having all the common code in one place and letting the subclasses inherit the code from the superclass.  If you need to change behavior you just have to make the change in the superclass, then all the subclasses see the changes too. This makes it so you don't break the code further down the line when you have to make modifications.

A subclass inherits all public instance variable and methods of the superclass, but does not inherit the private instance variables and methods of the superclass.

Polymorphism is used in making arrays. The superclass is the array type, the subclasses fill the array, and the superclass method is used on each member of the array.
Example:

MarineLife [] marine = new MarineLife [5];
marine [0] = new Fish();
marine [1] = new Squid();
marine [2] = new Crab();
marine [3] = new Shark();
marine [4] = new MantaRay();

for (int i = 0; i < marine.length; i++) {
     marine[i].eat();  // when 'i' is 0, a Fish is at index 0 in the array, so you get the Fish's eat() method. When 'i' is 4, you get the MantaRay's eat() method.

     marine[i].hide(); // same with the hide() method.

You can then use the polymorphic arguments and return types.
Example:
dave.approach(lionFish); 

class Diver {
     public void approach(MarineLife m) {
          // try to get close to MarineLife at the other end of the 'm' parameter
          m.curious();
          }
}
The 'm' parameter can take ANY marineLife type as the argument, and when the Diver approaches it tells the MarineLife to act curious.  Whichever marineLife is called, that's whose curious() method will run.

class Photographer {
 dave.approach(whaleShark); 
     public void takePhotos() {
          Diver dave = new Diver();
          Shark whaleShark = new Shark();
          Fish lionFish = new Fish();
          dave.approach(whaleShark);
          dave.approach(lionFish);
     }
}
The Diver's approach() method can take any marineLife you give it. As long as the object you pass in as the argument is a subclass of marineLife, it will work.

You can override a method from the superclass (the subclass Shark has a different method for 'curious' than the subclass Squid)

You can overload a method from the superclass (the subclass Crab adds more stuff to the superclass method for 'eat')

The chapter ends with exercises and puzzles.

Sautéed Kale Recipe

Sautéed Kale
Some days I just need meals that are really quick to make. I rarely cook anything right out of a can or box, so on days where I'm pressed for time I reach for my "almost instant" recipes.  Sautéed kale fits the bill 'to a T'!

This is an incredibly easy recipe to make.  Butterfly LOVES it and will eat almost an entire bunch of kale.  She doesn't eat it all simply because I make her share. :-)

1 large bunch of kale
1/4 cup hulled sunflower seeds
3 tablespoons oil
1 teaspoon toasted sesame oil
salt and pepper to taste

Slice kale into sections (very roughly 2" squares), discard the tough end pieces of stalk.

Heat the oil in a large sauté pan over medium heat; add sunflower seeds.  Sauté for about 1 minute.  Add kale pieces; sauté until wilted.  Pour sesame oil over the kale and mix in. Salt and pepper to taste.

That's it!  Kale is very healthy for  you and tasty to boot!

Banana Flower Soup Recipe

One of the banana plants that I put in the ground two years ago has a stalk of baby bananas! I had wanted to learn to cook banana flower ever since I saw them at the Chinatown markets, so we cut the end flower pod off our tree. The pod wasn't as big as the ones you find in Chinatown but it seemed large enough to experiment with.

I read that raw banana flowers are bitter until you soak them in salted water.  I sliced about 1 1/2 inches off the stalk end of the pod and discarded it.  The rest of the pod was thinly sliced, as if it were a small head of cabbage. I put the slices into a large bowl of heavily salted water and then poured about 3 tablespoons of lime juice (or use lemon juice) over everything.  After making sure it was all mixed well, I left it to soak for an hour.
Sliced flowers soaking in salt water

After soaking, the sliced flowers were rinsed several times really well then left to drip dry while I got everything else peeled, grated, chopped and ground.

I used my food processor to grind the ginger, chilies, garam masala, and turmeric into a paste but a mortar and pestle might work just as well.
Ginger Chili Paste

I had never eaten banana flower before so I wasn't sure what to expect.  I think their consistency is like lightly cooked cabbage. The soup's flavor is very mildly spicy.  I thought the "depth" or "background flavor" of the soup was lacking so I added about 1/4 teaspoon of Kaiulani Kona Coffee seasoning and 1/4 teaspoon of Kaiulani Chinese 5 Spice seasoning. (disclaimer: I don't own any stock in the Kaiulani Spice company nor do I have any affiliation with them, I just like their mixes.) The two seasoning additions made a big difference in rounding out the flavors in the soup.

Oh, one other thing: the soup is good right after cooking but tastes so much better after sitting in the fridge overnight.

Banana Flower Soup

  • 1 prepared banana flower
  • 1 cup of raw shrimp
  • 1 can or 14 ozs thick coconut milk
  • 1 ½ inch piece ginger peeled and grated
  • 1 stalk of lemongrass, or 1 tblsp sliced
  • ¼ tsp tumeric
  • ½ tsp garam masala
  • 2 large jalapenos, or serrano chilies if you prefer a spicier soup
  • salt and black pepper to taste
  • oil for cooking
  • water
Method
1.     Mix coconut milk with half as much water and heat with prepared banana flower, half the ginger and the lemongrass.
2.     In a heavy pan slowly heat the oil. Blend together the garam masala, tumeric, remaining ginger and chillies until a paste is made and add to the oil. Cook stirring until the aroma becomes intoxicating and the oils separate in the pan. Add the shrimp and stir fry until cooked all the way through. Add this to the coconut / banana flower mix. Stir thoroughly and simmer for 20 minutes, adding more water if needed, season to taste and serve.
3.     This soup can be prepared a day in advance and heated before serving. Allowing it to rest overnight will give time for the flavors to blend and harmonize thoroughly.



Peanut Butter Cookies Recipe


Breakfast Food Cookies
Cookies don't last long at our house.  They are the first thing attacked in the morning (Butterfly tries to convince me that they are legitimate breakfast food even though she knows I'll insist that she eat a real breakfast), and the final snack of the evening. Yes, I do cook nutritious meals; the family snacksters just like homemade cookies.

This recipe makes the best peanut butter cookies that I've found so far. The recipe below is doubled from the original recipe so that we have enough cookies to last for several days, otherwise, the cookie bandits consume them within a day or two and I have to bake again. If you want a smaller batch, just divide the recipe in half.

Note to Hanai Big Sister: Your favorite cookies are at my house. You should drop by...

Peanut Butter Cookies
Makes 6 dozen cookies

½ cup shortening
½ cup butter (1 stick), softened
1 cup peanut butter
1 cup granulated sugar
1 cup brown sugar (packed)
2 egg
2½ cups flour
1 teaspoon baking powder
1½ teaspoons soda
½ teaspoon salt

Mix shortening, butter, peanut butter, sugars, and egg thoroughly. Blend all dry ingredients; stir into shortening mixture.  Chill dough.

Heat oven to 375°F. Roll dough in 1¼” balls.  Place 3” apart on lightly greased baking sheet.  Flatten crisscross style with fork dipped in flour.  Bake 10 to 12 minutes.  Makes about 6 dozen 2½” cookies.




Learning Java: Day 6

Using the Java Library
Today, in chapter 6 of Head First Java, we are upgrading yesterday's simple version of the DotCom game from a 7-cell/1 dotcom company to a 7 by 7 grid with 3 dotcom companies.

This is a computer automated version of Battleship where the computer randomly sets the three dotcom companies within the grid and the user has to guess where they are. This is still played at the command line and is rather primitive but it's a good learning tool.

I'm surprising myself; as I slowly traverse through the book I understand more of the code. I really did wonder if I was ever going to understand this stuff.  It makes me happy to know that I am STILL CAPABLE of learning difficult material.  It gives me hope that I'll be able to be competitive in graduate school even if java programming requires a vastly different skill set than acupuncture and Oriental medicine.

This chapter explains the arraylist which is so much "smarter" than regular arrays. The arraylist grows and shrinks as objects are added or removed, you can declare and create specific types of objects, you can just "ask" it if it holds a certain object rather than have to loop through each cell, and many other "things" it can do that I haven't learned yet.

We learn new boolean expressions (those are the yes/no type of expressions) And, Or, Not, and NotEquals.
Most important of all, we learn how to look up libraries of java utilities that are pre-written and can be used anytime simply by including an import  at the top of your code. So much code is Already Written for me! Woo hoo!

Short post today.  Most of my practice time was spent debugging my game.  Debugging code is an important skill to learn.  Surely I'll get faster as time goes by.

Tomorrow, besides another java post, I think I'll add a new recipe to this blog. Unlike programming, almost everyone is interested in food...


Learning Java: Day 5

Writing a Program
Yesterday was filled with errands, a doctor appointment, and testing breadfruit recipes for an upcoming recipe book (not mine; I'm just a tester).  I ended up with only two hours to work on learning java before my brain turned off and I had to go to bed.   Today I'm trying to catch up...

Chapter 5 is where I get to create a real game program.  In this case, it's a very simple version of Battleship although instead of ships we're killing Dot Coms. Supposedly, that makes the book a business expense... The book hasn't covered how to create user interfaces yet so everything is still command line driven.  Somewhere in chapter 14 I'll get to learn the really cool stuff but right now I'm still figuratively learning to tie my shoelaces.

What we are learning in this chapter:

Loop de loop
Loops are used to allow the program to cycle through a bit of code over and over again until a certain condition happens. There are three types of loops: while, for, and enhanced for.

While is used when you don't know how many times you need to repeat the loop; you just want it to continue looping until some condition is met. A game where you keep going until you get "killed" would be an example.

The regular for loop is used when you know how many times you want to cycle through the loop. You normally set the counter to zero to start and then specify how many cycles to do. You might use this type of loop when printing out the lyrics to "100 Bottles of Beer (On the Wall)".

The enhanced for is used for traveling through the members of an array (and other "collections" that I haven't learned about yet) You can think of this type of loop as the "for each" loop because it reads "FOR EACH thing in the collection do this...." You might use this type of loop in a children's game, "for each cupcake in the tin, frost it".

We also learn how to make big numbers fit into small numbers (like a long to an int) by chopping them down to fit the space using the cast operator. The result is like chopping off all the numbers after the decimal point and just leaving the whole number.

And we learn to change a string into an int. Don't ask.

The final task was to create the Simple Dot Com game. After working and working at fixing errors in my game code, it finally works. That's HOURS and HOURS of fiddling.  But The Game Works. Yea! Now I can go to bed.