The Abomination of Anonymous Inner Classes

| No Comments
I have long held the opinion that the feature of anonymous inner classes in Java (and, truly, any language) are an abomination, an unnatural perversion having no place amongst all things Holy and True.  There are others who share this opinion of mine, for various reasons.

My primary reason for having such a severe dislike of those things is because they completely destroy the flow of the code.  In the middle of a method -- nay! even worse -- in the middle of a method call, suddenly there's code being laid out which will be executed in some other flow, most likely through some other thread -- nay! still worse -- suddenly there's another class being defined!  Lordy lord, what horrible thing to do to your code!

Let's look at a simple little example:

public class FindConfigFiles
{
  public void loadConfigFiles (File basePath)
    throws IOException
  {
    File[] configFileLIst = basePath.listFiles(new FileFilter ()
      public boolean accept (File toCheck)
      {
        return toCheck.getName().endsWith(".xml");
      }
    );
      :
  }
}


EEEK!  Don't do that!  Blech! Blech! Blech!

Instead, consider something like this:

public class FindConfigFiles
{
  static protected class ConfigFileFilter
      implements FileFilter
  {
    public boolean accept (File toCheck)
    {
      return toCheck.getName().endsWith(".xml");
    }
  }

  public void loadConfigFiles (File basePath)
    throws IOException
  {
    File[] configFileLIst = basePath.listFiles(new ConfigFileFilter());
      :
  }
}


Ahhhh.  Much better.  Just the act of turning that anonymous inner class into a named inner class worked magic on that little snippet of code.

That particular inner class only sported one line of meaningful code.  Now imagine if the code in the inner class had to be a bit more involved.  Even if the inner code were as small as 5 lines, the impact is still staggering.

You know, when all is said and done, the thing that really confuses me about this is that it seems most Java engineers don't even notice, or perhaps simply don't care, about the defilement they are incorporating into their very own code.

Bian: Metrics Tracker

| No Comments
What am I doing starting another project?!

Bah, I ask myself that every time I start something new.  Some projects are destined to be worked on indefinitely and some are fated for abandonment, a few even become completed.  But there will always be new ideas to be exercised and vetted out.

I've always been frustrated with the workout tracking and journaling systems out there.  They just don't track what I want to track in ways I want to track them.  (I'm very selfish, you see.)

So, my latest little coding project is to come up with a system which will allow me to track my workouts the way I want them to be tracked.

Like the wide variety of projects I work on, I also do a lot of different types of workouts:martial arts, running, hiking, skating, gym weights, kettle bells, rowing, yoga... and so like that.  I want to be able to track hiking by elevation change, hiking duration and sweat level; but I need to track gym weight work by machine weight, repetitions and sets.

My bian system should be able to handle both beautifully, gracefully, seamlessly, and flawlessly.

And if my system can do all that, it can probably track just about any kind of metric.  Thus, I am not building a workout tracker, but a metrics tracker!  Tadaaaa!

Drawing: Pretending You're Not Looking

| No Comments
This was a piece I did a few years back.  I wanted to draw a tease, something that hinted at something more, but at the same time pulled you in. 

I intended for it to be modest, but then I went and snuck a nipple in at the last moment.  Oops. 

Pretending You're Not LookingPretending You're Not Looking

Xenia: Wiring It All Up

| No Comments
The first thing I did this weekend was check the voltage on the new batteries.  They were each between 13.33 - 13.40.  I think at full charge they should be at about 16.92 volts, and fully depleted they're at about 10.80 volts.  So these are maybe a little less than half-charged.

Next up I wired everything for the controller.  Aiyah!  What a pain!  The contactor-resistor-switch setup for this KBS Kelly Controller is just a lot of stuff to have to mess with for a scooter. 

I wanted everything to be clean, so I used "professional" connectors wherever I could.  Which maybe wasn't so professional, I don't know.

I had a problem wiring the switch in because the wires were too small (22 gauge) to fit into any of my connectors.  So I ripped apart the switch and rewired it with 18 gauge wire.

Serene took a few pictures throughout the process:
Xenia WiringXenia WiringXenia Wiring
I also revisited the mounting bracket for the motor.  I added a couple bolts to go all the way across to the other side of the frame, and hooked them to the bracket with hex connectors.  I think that's much more stable now. 

You can see the new bolts on the right side of this pic (click through for a better view):
Xenia Motor Bracket
Now I'm just hoping I can get some time to finish this up in the next few days.

Xenia: Mounting the Motor

| No Comments
The folks over at ModifiedElectricScooters.com really didn't like my idea of using the casing of the old 500 watt motor as a bracket for the new little 2800 watt one.  So, I've been thinking about how to make a bracket for this thing instead.

One detail of the new motor is that almost the entire casing rotates as the motor turns.  One of the ends doesn't, and that's where the bolt holes are.  At some point I realized that I could put the sprocket on the same side as the bracket.  And that led me to the solution I'm trying out now.

I went down to the hardware store with my wife this morning and grabbed a metal electrical box cover.  The biggest they had was 4" diameter, and I paid an extra 43 cents to get one with a knock-out in the middle.  Of course, then, my lovely wife wanted to pick out and buy a bunch of plants and pots, so 2 hours and something north of $100 later I finally got home.  Yes, I do love that woman.

Anyhow, back to my bracket:  When I got home, I used a little jig that came with the motor to draw the hole positions onto the metal cover.  I took a hammer and nail and tapped a little starter indent as close to the middle of each of those positions as I could.  Then I drilled them and punched out the knock-out hole in the middle.  That got me an almost perfectly sized bracket, like this.
Xenia Motor Bracket
The motor bolted on perfectly, and I rewarded myself with a can of Pepsi.  Mmmm, carbonated high fructose corn syrup.
Xenia Motor BracketXenia Motor BracketXenia Motor Bracket
I had ordered a 6mm sprocket when I ordered the motor, so I put that on.  I had to spray both the sprocket and the shaft with WD-40 and tap it with a mallet (ever so gently) to get it on.
Xenia Motor Bracket
When I was at the hardware store I had also picked up some bolts, nuts, washers and a few spacers.  I was trying to line things up so that the sprocket on the motor would line up with the sprocket on the wheel.  I had measured everything before-hand, but I forgot to account for the motor shaft... So, everything is off by about 1/2 an inch.  Heh heh.

I'll have to pick up some longer bolts and see how it all fits.
Xenia Motor Bracket
Since the bracket is just kind of sitting out there in space with a motor on it, I'm a bit concerned that the torque from turning the chain is going to make it flop around.  I added some big fender washers and extra nuts to try to brace everything.  But that might not be enough.  We'll see when I get the electronics working.
Xenia Motor Bracket
My final little exercise of the day was to plunk all the components in the frame and see how they fit space-wise.  I wasn't expecting it to be such a tight fit!  The controller and contactor take up quite a lot of space, and those batteries really aren't much smaller than the originals (though they are a lot lighter).
Xenia Motor Bracket
Next up will be wiring it all together.

Xenia: Parts Pix

| No Comments
I rather expected the new LiFePo batteries to be significantly smaller than the same capacity SLAs.  But they were only a little smaller.
Xenia BatteriesXenia Batteries
The charger, however, was significantly larger.  Heh heh.
Xenia ChargerXenia Charger
I didn't expect the new Brushless motor to be much smaller, but it's positively tiny.
Xenia MotorXenia MotorXenia Motor
The motor has me a bit worried.  For one I'm concerned that it won't be able to produce the amount of torque I'll need to propel myself.  But I guess I'll find that out soon enough.

My my biggest concern is that I can't figure out how to mount that little thing.  It's just too small.  It's like one of those little cell phones that were trendy back in the late '90's that you could barely hold on to.

So far my only idea is take apart the old 500 watter and see if I can mount this motor inside the case of that motor some how, some way.  Maybe I'll come up with a better plan...

Xenia: Getting the Parts

| No Comments
It's been a bit over two weeks now since I ordered all the parts for my 1300 watt stand-up scooter project. 

Most of the parts arrived within a few days of the initial order.  I have a nice little cache building up in the den of all the shiny new parts.

But the motor... the motor did not show up.  I checked my order confirmation emails and found that I had received an email about the motor saying, "Your order has been sent to the warehouse for processing." 

I waited, each day watching as delivery trucks drove past my house without stopping.  I waited, each evening pulling up the web site showing the motor just so I could gaze at it wistfully.  The weekend came, but the motor didn't.

One day, midway through the second week, I forgot to watch vigilantly.  It was a busy day, I was preoccupied, I was distracted.  Suddenly, I realized I hadn't been watching for the delivery trucks.  My motor could be here, out on my porch, just waiting for me to open the door and pick it up!  I gasped and ran to the door swinging it wide... but there was no motor on the porch waiting for me to pick it up.  The porch was empty.  The porch was empty.

Another weekend came, and the motor still didn't.

Finally, I went back to the web site from which I'd ordered the motor.  I found that there was a status next to my order that said, "Processing."  I then found a note that said that the motor was on back-order and there was no expected date of delivery.

WHAT?!

I turned red in the face all the way up to the top of my bald head.  I got up and walked to the living room then marched back and sat down in front of my computer again. 

Amidst a flood of good old American self-righteous indignation, I canceled that order.  And it felt good!

It took a few minutes for me to realize that I had no motor, that no motor would be showing up, that I had to find another motor for this project.  (sigh)  Asearching I went, to find me a motor that would fit my needs. 

I never did find one that had the shaft-size I needed.  And I couldn't find a 6000 watt beastie either, at least not for a reasonable price.  So, I ordered a 2800 watt one; since I'm only planning to push 1300 watts anyhow, it's still way overkill.  And I ordered a new front sprocket to fit the shaft of the new motor I ordered.  Great.

Now imagine my surprise when the motor showed up on my porch The Next Day.

Right.  So, I got the parts, I'll take some pictures and throw them up.

Drawing: Inner Discovery

| No Comments
I can't draw.  But I can pretend, hey. 

My usual method of pretending is to find a picture I like, trace the key features, then shade it the way I like it.  Even with my cheating, it still comes out looking childish, compared to a real artist.  But it's fun and relaxing, and some of them don't look too bad.

I just finished a piece done this way.  I think the proper way to phrase the medium is "graphite on paper."  Which means I scribbled with some pencils on a piece of paper I snitched from the printer tray.

Even so, this is my favorite one so far.

Inner DiscoveryInner Discovery

We Lost the Jellybean

| No Comments
We had our second ultrasound a few days ago.  We lost the baby.

There were no warning signs.  Everything was looking good, no cramps or bleeding or anything.  But when the doctor did the ultrasound, the baby was much too small, and she couldn't find a heartbeat.  She got another doctor to look, also.  It was a miscarriage. 

Serene got a D&C Saturday while I distracted her with tall tales about dinosaurs and Japanese gardens. 

I'm surprised at how hard it hit us both.  It's been a hard few days, with a lot of sudden bouts of tears.  The littlest things set us off.  Like when we were on our way to get the procedure done, we walked past a birthing class and I suddenly couldn't see anymore.  I hadn't realized how much we had already bonded with our little baby.

It's been hard to tell everybody.  Every phone call brings everything right to the surface again.  But it's also been very therapeutic talking to people about it.  A lot of people have gone through similar experiences, and have good and encouraging perspectives on it.

Still hurts though.

ABuddy: Architecture Diagram

| No Comments

I put together an architecture diagram to show the components, the data stores, and how they interact.

ABuddy Architecture Diagram
There are 3 entry points, all along the top.  Two of them are launched by cron jobs, the last is launched by a web service request.

The Klepto guy pushes new quotes into the Duke's data store.  The Duke will then later enrich those quotes.  Both stores get queried by the Professor during analysis, and the results are published into the report to the user.

Find recent content on the main index or look in the archives to find all content.