March 31, 2005

Diet Dr. Pepper

If Diet Dr. Pepper tastes more like regular Dr. Pepper, why bother selling the one that's worse for us? Are there consumers that demand the calories? We wouldn't need healthful alternatives if producers only made stuff that's good for us.

In case you would like to ask them yourself, you can call up 1-888-DR-PEPPER. In addition to talking to a customer service representative, you can listen to prerecorded answers to some of their frequently asked questions. I'll save you a call by answering their number 1 FAQ here: no, Dr. Pepper does not contain prune juice. Now you know!

Posted by Matthew at 09:23 PM | Comments (0)

Lecture musical

From the folks that brought you the Library Musical, here is the Lecture Musical.

Posted by Matthew at 04:38 PM | Comments (0)

March 30, 2005

Back

About a month or so ago my dad started experiencing pain in his lower back. Despite several tests, the doctors sent him back home without a diagnosis because they couldn't find anything. Finally, an MRI turned up a lump along his spine. A biopsy confirmed that his cancer had come back. We knew this day would come because this type of cancer never just goes away. The timing was a bit surprising because he had been undergoing routine blood tests to looks for signs of its return; but those tests did, and still continue to, come up negative. That's why the doctors were very surprised to find the tumor.

Radiation therapy starts today. For now that means he won't have to go back to the hospital. Up next might be chemotherapy or another stem cell transplant. It's so difficult to go back and forth between sick and well. And just when we think we've moved past something, we wind up right back where we started. It's just so...frustrating.

Posted by Matthew at 08:09 PM | Comments (1)

March 25, 2005

Duct tape flower

A while back i had made some duct tape flowers for a friend. I recently had someone ask me how i made them and i thought i would share the instructions here. First, the finished result:

duct tape flower

(complete directions available after the jump)

It's fairly easy to make; you just need a few supplies: duct tape, scissors, and some wire. I picked up both of my spools of wire from the floral aisle of a craft store. I like to use 24 gauge for the petals. This won't be seen so it can be any color. I'm using a thicker silver 20 gauge wire for the stem and stamen. Pliers with the ability to cut wire also come in handy.

supplies

Start by cutting lengths of the 24 gauge wire about half an inch longer than the width of the duct tape. Try to make them as straight as possible. Here's a tip: it's a lot easier to straighten the wire before you cut it. Just run your hand down it a few times. You will need 10 of these pieces. Start pulling off a long piece of duct tape and place the lengths of wire about and inch and a half apart from each other on the sticky side starting about 3/4 of an inch from the end of the piece of tape. The lengths of wire should almost touch one side of the tape and hang over on the other.

lay out the wire on the tape

Once you have a few pieces of wire on the tape, cut another piece of duct tape as long as the first and lay it over the other, trapping the wires between the two sticky sides. Then, cut the tape half way between each of the pieces of wire.

separate petals

Next, cut each of these new pieces into the shape of a petal. They all don't have to be exactly the same; variety looks nice. When done you should have 10 petals.

shape petals

I also choose to make the flower appear more interesting by adding in a curly stamen. I wrapped some of the silver wire a few times around a pen, then bent it with the pliers. If you do this, you may notice its hard to get the very end to be curly. I suggest just cutting off the part at the end that wont bend property after you pull it off the pen. I made two of these to go in the center of the flower.

form stamen

It's time to bring all of these parts together. I cut off a thin strip of duct tape for this purpose. If you happen to have some actual floral tape, that works well too (although i prefer the silver duct tape to the green floral tape).

cut thin strip of duct tape

Next, gather all the petals. Line them up so the bottoms of the petals (not necessarily the wires) come together. Optionally, add in your stamen to the middle of the stack. Now, overlap this wire bundle with the wire you will be using for the stem. (I like to leave the stem wire attached to the spool and cut after the flower has been formed.) After you've worked the stem wire into the center of the petal wire bundle, take your thin piece of duct tape and tightly bind it all together. Go up and down a few times over the petal wires until everything seems secure.

bind all the parts tightly with duct tape

Finally, bend down each of the petals to start forming your flower. I also like to cut off an extra long stem and form it into a spiral to act as a base to hold the flower part up.

Actually, when i first learned this technique, i did it with masking tape rather than duct tape. If you do that, you can paint your petals any color you want before you make your flower. In that case, you would probably also want to look into picking up some actual floral tape. This is a weird tape that doesn't actually get sticky until you pull it tight. It's not super sticky but its very flexible.

There you go! If you make your own be sure to let me know!

Posted by Matthew at 05:36 PM | Comments (9)

March 22, 2005

Teaching versus tutoring

My programming class is starting to bug me again. Yesterday's class broke down into a two hour question and answer session about our homework that's due tomorrow and the practice exam that we received. We covered no more than 5 minutes of "new" material. This thing used to happen back in high school. The teacher would assign the homework, no one else would do it, and we would spend all class going over it. I sat and wondered why i wasted my time the night before actually completing the assignment.

Answering specific questions isn't teaching; it's tutoring. Student should be expected to put some forth some effort outside of class to try to complete the required work. If problems arise, they might choose to consult the textbook for some help. I'm pretty darn sure most of my classmates haven't looked at the book since they bought it at the bookstore. If the student is still stuck, he can stop by during the professor's office hours for assistance. Our instructor even booked the classroom an hour before class starts to be used as an informal study group. That would be the perfect time to ask about any problems that may keep one from completing the assignment.

I'm guessing there are so many questions in the first place because we haven't spent enough time on the fundamentals of programming. We don't have time for the fundamentals because class is overrun by questions. I'm not saying all questions are bad; but there is such a thing as a stupid question. Questions should be used to clarify rather than instruct. I feel like the teacher has lost control and he doesn't even care. I'm guessing it's a lot easier to answer questions rather than stick to lesson plans.

I have one last thing to complain about. Here's part of one of the problems on the practice exam where we are supposed to follow the code and write down what it outputs:

int x=3,y=5,z=16;
if(x > z - y && z > 5* y || z > z % x)
   if(x+y>z)
      System.out.println("England");
   else
      System.out.println("Germany");

This code sickens me. It's so contrived and purposely obscure. Beginning programming students should only see good examples of code with well-named variables and proper commenting. We should be able to understand what the code is trying to do. If we can do that, then we can work an identifying logic errors or reasons why the code may not do what the programmer things it will. Learning the gritty detals of Java syntax and order of operations shouldn't be as important as learning to understand and appreciate the art of programming.

Posted by Matthew at 10:05 PM | Comments (4)

March 18, 2005

Composing code with the composite pattern

I've been reading up on design patterns for a while now. While i haven't implemented that many myself, i'm familiar enough with them to recognize when a problem comes up for which they provide a solution. Such was the case when we started developing a template system for the website we were working on.

I'm well aware of the fact that page templates typically never work as hoped but i wanted to try to do something to hide the CSS stuff from the programming stuff. At first i thought there would be only 6 or so different page layouts. If that were the case, we were just going to make 6 different ASP.NET user controls and include them on the pages which called for them. Then, on the code behind, we would call methods of the specific template user control to add child controls to each of the "holes" on the template.

The idea seemed reasonable until we quickly realized that the number of templates was quickly growing. Our designer was simply using a four column grid structure and each page would have elements that may stretch across one or more columns and varied in height. Instead we decided to switch to a format where each page would configure a generic template for this specific purpose. This generic control would nest template elements to achieve the desired outcome. This code required a way to be able to effectively work with nested controls.

When i started to think about these child controls, i was reminded of the composite design pattern.This pattern exists specifically to deal with tree like structures. It's built with the idea that there are two types of items in your tree: those that contain other items and those that do not. Each of those two types of classes inherit from a base component class. This base class defines the methods that both the classes that contain other classes (composite classes) and those that do not (leaf classes) must implement. The composite classes can contain collections of the generic component class so it can either contain either composite or leaf classes.

In the case of my template system, i created a class called TemplatePanelNode to act as the component class. This was an abstract class that ensured that each of the child classes had a height and width property as well as implemented a ToControl() method. The ToControl method must return a System.Web.UI.Control object. This is because i will append this output to the page and allow the standard page rendering function to actually draw it.

I chose the term TemplatePanel to refer to the leaf classes. This is where you could actually attach other web controls to be rendered within that "hole" of the template. These objects all had a private "div" HTMLGenericControl. The public AddControl() method would add controls to the Controls property of this private instance variable. The overridden ToControl() method would simply return this control.

The composite classes were called TemplatePanelContainers. This has a method called AddRow() which uses a ParamArray to accept any number of TemplatePanelNodes which means you can pass in either TemplatePanel or other TemplatePanelContainers. We add a row at a time to help enforce some of the grid requirements. These elements are added to a private strongly-typed collection of TemplatePanelNodes. It's The overridden ToControl() method creates a System.Web.UI.WebControls.PlaceHolder to which it appends the values returned by each of the ToControl() methods of the objects in its private collection.

Being able to use the pattern saved me a lot of time and gave me a great place to start. It's nice to build upon the collected knowledge of developers rather than start from scratch all the time. While this type of template system may not be the best long term choice, i can at least be confident the code will work as expected.

Posted by Matthew at 03:59 PM | Comments (0)

March 14, 2005

Mario Kart and the art of programming

I would qualify my Mario Kart: Double Dash playing these past few weeks as aggressive. I first picked up the game a while back when my sister was in town. We always played the old N64 game together and worked as a team to get gold metals in all the cups. We got the 50cc cups with not too much effort but the weekend came to an end before we made much progress on the 100cc races.

It took me a lot more time to get past that darn Star cup than i thought it would. I had to get accustomed to the feel of the different cars and weapons to find something that worked for me. I would occasionally have a good run, but it took a lot of practice to achieve the consistency necessary to get the gold. After two weekends of work, i finally got passed my roadblock.

I assumed that each new challenge would be incrementally as difficult, but that turned out not to be the case. Once i had achieved a certain level of skill, it turned out to be relatively straightforward to complete the "more difficult" races. Even the sixteen track cup only took two times through to get the gold. Once you know how to work the cart, it only takes a few laps to adjust to a new track.

The phenomenon of having to put in a lot of work to accomplish basic goals and then comparatively little effort to achieve more complex goals reminds me a lot about computer programming. Once you learn the general concepts involved with solving problems with computer code, you starting thinking like the computer. I've noticed that now that i've had experience with many different programming languages, i find picking up new ones to be fairly easy. To learn a new language, you just have to focus on the differences and sometimes the differences can be small. Many languages have similar ways of accomplishing a given task.

The revelation is not hard to come to when you compare Java to C#. In fact, most true object oriented languages have so many common that traits that generic design patterns have been developed to cover all of them. The only difference in implementation is in the syntax. More often when a programmer get the sense that there "must be" some way to accomplish a particular task, he find that he's right. Usually the answer can be found by just knowing which part of the documentation the answer will probably be in.

These idea were reinforced by the the MSDN presentation on designing progressive APIs. It's nice to know that some people put together classes with the idea that someone should be able to make an educated guess as to what a class might be named or how it might work and should be reasonably confident they are making the right choice. Thanks to the wonders of Intellisense , it's often not necessary to read documentation any more.

Ok, wow. I guess i should probably stay away from Gamecubes and computers for the next few days before i just go completely nuts. I'm going to bed.

Posted by Matthew at 11:08 PM | Comments (1)

March 13, 2005

No title, no render

It's odd, but if you if you put a self closing title tag (<title/>) in the header of a web page, IE 6 renders a completely blank page. Yet another weird Internet Explorer quirk.

Posted by Matthew at 06:10 PM | Comments (1)

March 10, 2005

Finally getting around to ASP.NET

I've only tackled the occasional project in .NET since it's been around. Most have of those have been fun and/or interesting desktop apps. I had never tackled a large scale ASP.NET app. I was hesitant mostly because it was hard to see how all this object oriented code would work with a web app. I understand how normal web pages work and i wasn't sure if i was comfortable with some of the layers ASP.NET put on top of that.

It just so happens that we're in the midst of redesigning one of our larger client websites. I figure now is as good a time as any to just jump in and see what happens. We're off to a good start so far. It's going to be so much better as far as being able to reuse code and consolidating business logic in a central place. It's also nice to be able to use the wonderful object oriented fundamentals of things like inheritance and interfaces. I've also been following the MSDN Designing .NET Class Libraries series and it just sounds like fun splitting up all the functions the site can do into classes with easy to use APIs.

So anyway, i guess we'll see what happens. I wish version 2.0 of the framework would come out soon so we could use some of those features, but oh well. I hope i don't regret this.

Posted by Matthew at 11:31 PM | Comments (0)

March 07, 2005

Gypsy at Civic

I neglected to mention that i saw Gypsy at Civic this weekend. I was pleasantly surprised by the show. I was expecting another empty, silly musical but found a bit more.

The performances were all very good. I was familiar with nearly all the songs but had never heard them in the correct context of the show. All the technical stuff seemed really tight as well. Act one is a bit long but things really pick up in act two. I believe the whole production was around 2.5 hours.

I also got the sense that the show was trying to say something. It examined the delicate balance between a parent and her children. It also explored the fine line between following your dreams and becoming obsessed with a fantasy. I thought it actually gave me something to think about. However, let me warn you that if i was able to pick up on this, the message probably isn't so subtle because normally this stuff goes over my head.

I thought i was going to get through this show without stepping backstage, but i was wrong. Mary Jo asked if i could fill some holes in the fly rail schedule and, since i'm on spring break this week, i could help out. I'll be down at the theater this Wednesday - Friday. If i remember correctly, there were a lot of flies going in and out so i should keep pretty busy.

If you would like to see the show, it runs though March 19. I recommend you do.

Posted by Matthew at 10:29 PM | Comments (1)

March 05, 2005

Making reading fun

I'm so excited. My first issue of Make magazine finally came in the mail today. It's full of a lot of great stuff. Reading about all these cool projects is really inspiring. I love being a geek.

Posted by Matthew at 10:33 PM | Comments (1)

March 03, 2005

Flocabulary

This just cracks me up. The folks at Flocabulary put SAT vocabulary words and their definitions into hip-hop style songs that you can purchase and repeat to increase your word power. They have sample tracks at Sparknotes. They lyrics are too funny to take seriously.

Posted by Matthew at 09:04 PM | Comments (1)

March 02, 2005

Sarissa flip-flop

I've been using Sarissa for a while now every time i need to do some sort of client side scripting involving XML. It's a nice wrapper around the browser specific XML objects to allow you to run the same code in both Firefox and IE without too much fuss. I've been working on a tricky XSL script for the past few days and i kept running into a problem. I wanted to rule out the possibility that the unexpected results were coming from Sarissa so i stopped by the site to make sure i had the most recent version. I didn't. I've been using version 0.9.0 and the latest is 0.9.5.1. I thought i could just swap files and give er another go. That turned out to be far more difficult than i had expected.

The older file used IE's API as the standard and reshaped the Mozilla stuff to match. At some point when those version decimal places changed, they decided to use the Mozilla standard instead. I'm not saying it's the wrong choice, but it just took me a while to adjust because i have never had to use those objects before. I spent a good part of a day refactoring my code to use the new objects. I'm very surprised that methods like selectNodes and selectSingleNode are IE specific. The XML DOM seems so useless without those (unless i'm missing something). Luckily the latest version does include support for such methods though the inclusion of a second script file.

In the long run, i'm sure they made the right choice. Hopefully Safari will soon support full XML / XMLHTTP / XSL capabilities, and when they do it's probably safe to assume they will use something close to the Mozilla standard. It's always nice to have help fighting the cross-browser wars.

I finally got the code up and running again only to learn that Sarissa wasn't my problem at all. The quirk seems to lie somewhere deeper in core of Firefox. I'm still playing with it to figure out exactly what's going on.

Posted by Matthew at 08:23 PM | Comments (0)