Tuesday, October 12, 2010
Angry Unicorns
My students in CS222 are working in pairs on a two-week project, a little RSS analyzer. This was the halfway point, and we used our meeting today for each team to give a status report. After giving my introduction, I sat down so that student teams could, at their pace and discretion, come up and give their status reports. The first team came up rather quickly and did a fine job. After they collected their peer evaluation forms and sat down, there was a delay while the rest of the students considered whether or not to go next. I started a doodle, which turned out into a nearly-complete rendition of Strong Bad:
As the second group of presenters finally came to the front, I informed the class that I was one leg away from completing a sketch of Strong Bad, and that I didn't know what would happen if I had completed Strong Bad, but I'm sure it wouldn't be good.
We spent the next 50 minutes or so hearing status reports, at which time there was another lull, although by my estimation, about 20% of the class had not yet presented. So I started sketching again...
Once complete, I informed the class that I had completed my angry unicorn, and so I assumed that no one else wanted credit for presenting today. This was the first time I made any statement about the presentations being "worth credit," although the students knew that I was jotting down evaluations using the same rubric as their peers, and that I would email these later.
Immediately upon mentioning credit, there was hubbub and three more groups got up to give status reports. One of the groups had very little done, but they gave a great honest report. Another "group" was missing half, but the sole attendee gave a great synopsis of the team's status.
Most likely, it was mention of credit that made these last few get up and present, but I like to think it was the threat of angry unicorns.
Friday, October 8, 2010
All my thoughts, or, three-in-one
- The present state of higher education
- The various responses to this state
- How these responses point to a new vision for higher education
- Readings to support this
Java Workshop
- "Java" refers to a language, an API, and a VM. It's good to be aware of this overloading of the word so that you can see how the whole system fits together, especially with the proliferation of languages that run on the JVM.
- Java has primitive types and reference types. Primitive types are just boxes that hold values, but reference types are for objects, the fundamental building blocks of OO systems.
- All of the primitive types have similarly-named reference types. For example, there's
intand there'sInteger. The difference between these reveals an important insight into object-oriented software design. Whereas anintvariable is just a box that holds a value, anIntegerinstance is a representation of the idea of a number. Consider the following code.
Here, x is just a box that holds an integer, and so we can sayint x = 5; Integer y = 5;x=7, and that means we're putting a different value in the box. On the other hand,yis five. We cannot sayy.setValue(7)any more than we can assert that 5=7 in mathematics. - It's good to recognize that
y=5is not free: it's using autoboxing to convert anintprimitive into an instance ofInteger. While it's true that premature optimization is the root of all evil, you shouldn't write code that creates unnecessary objects either. - It is critical that a Java developer builds a functionally-correct mental model of
classes, objects,static, methods, and fields. A blog post is not the right way to help you, dear reader, to identify the problems in your own mental model. The good news is that my services are for hire. ;) - There are four access control modifiers that you should know so that you can read code:
public,private,protected, and package-protected (which has no keyword). However, you should really only ever usepublicandprivate, so you just saved half your allocated brainspace on this topic. - To understand classes, abstract classes, and interfaces, I used an example like the following.
A few highlights of this example:public interface InningListener() { public void strikeOut(); public void walk(); public void balk(); public void beaned(); public void hit(); } public abstract class AbstractInningListener implements InningListener { public void strikeOut() {} public void walk() {} public void balk() {} public void beaned() {} public void hit() {} } public class Inning { private final List<InningListener> listeners = new ArrayList<InningListener>(); private int strikes = 0; public void addInningListener(InningListener listener) { listeners.add(listener); } public void strike() { strikes++; if (strikes==3) { fireStrikeOutEvent(); strikes=0; } } private void fireStrikeOutEvent() { for (InningListener listener : listeners) { listener.strikeOut(); } } } public class Demo { public static void main(String[] args) { Inning inning = new Inning(); inning.addInningListener(new AbstractInningListener() { public void strikeOut(){ System.out.println("Strike out!"); } }); for (int i=0; i<3; i++) inning.strike(); } }
- This is an example of the Observer design pattern.
- The abstract class provides default empty implementations of the methods in the interface so that implementors—like the one in
Demo—can provide implementations of only those methods that they care about. This keeps the code from getting cluttered up with no-op implementations. - This pattern can be found throughout
java.awt.event. I tend to do something a little more idiosyncratic involving inner interfaces and inner classes, but that's for another day.
- If you're doing I/O, it's good to know that the
InputStream/OutputStreamfamily of classes is for byte-level I/O,Reader/Writerfamily is for character-encoded content, and theniolibraries are for blazing fast access to hardware buffers, and so can be ignored until you need it. To me, the critical classes to know areBufferedReaderandPrintWriter.BufferedReaderhas the amazingly-usefulreadLinemethod, allowing line-by-line access to a stream, and aPrintWriterbehaves exactly likeSystem.out. - The classloader trick will load a resource from the classpath whether you are running in Eclipse, from a command-line, from an executable jar, in a servlet, or on Java WebStart:
Thread.currentThread().getContextClassLoader().getResourceAsStream("whatever.png"); - Here's a slapdash tour of the collections API:
List<T>defines a sequence. There are two useful implementations,
LinkedList<T>andArrayList<T>, which come with the usual caveats implied by their names.Set<T>defines a set, in the discrete mathematics sense.
The two common implementations areTreeSet<T>andHashSet<T>, but you should use the latter because you're always providing a usefulhashCodemethod in all of your Java classes—or else you're doing it wrong.Map<K,V>defines a dictionary, an associative array, a lookup table—choose your favorite mental model. Again, we haveTreeMap<K,V>andHashMap<K,V>, and you should use the latter and overridehashCodein all of your classes.
- Finally, use guava.
I think that's everything we covered, except for some of the more specific questions. I hope this post is helpful to someone looking for a birds-eye view of Java. As I mentioned at the workshop, when I started using Java in 1998, there was not much to learn and there was basically one place to go to get started. Now, I imagine that novices can be easily overwhelmed by the immensity of just the standard libraries. By the way, the good news here is that the best place to go for an introduction to Java—as long as you aleady know something about programming— is still The Java Tutorials.
At what point intervention?
There are various things I can do to help as a Product Owner who is also the lead software architect. I could invest time in developing a robust technical design document that describes the pieces of the architecture that are not yet in place. I could run through the product backlog and come up with reasonable estimations for every PBI so that I can make a product burndown chart to show studio velocity.
The key dilemma I keep coming back to, however, is this: at what point to I just sit down and write some code? The game is already based on an entity architecture kernel that I provided, and I am one of the principle stakeholders in the success of the project. I see some of the students seriously struggling with code that, to me, is at most a two-hour job. There is value in having students struggle through these problems so that they can develop problem-solving skills and learn to deal with frustration. On the other hand, one of the best ways to learn is by working with someone more talented. At what point is it better for me to just show them how to write it rather than trying to coax it out of them? For that matter, how do I know when it is better for the project for me to add modules or refactor modules students have already created? These questions make me nervous, and I think it's because there's no "undo" button for teaching.
In my mind, I keep coming back to the Confluence project, where I worked right alongside Carrie and Josh to build that system, and it was good: the system worked and they learned. For that project, I had release time to develop it, and both students received independent study credits, and I don't have any doubt that we did the right thing. 3:15 Studio is formed out of a "regular" class, with an order of magnitude more students. Does that mean it is any different?
Wednesday, October 6, 2010
Civilization, War, and Learning
Last night, I finished my first game of Civ V. I used the default settings, which were for beginning players, and I happened to be playing as the British Empire. My civilization developed much faster than the opposition, probably more because of the low difficulty setting than any clever strategy of mine. There are multiple ways to win the game peacefully: scientific leadership, diplomacy, and cultural development. Because my civilization was advancing so much more rapidly than my opponents, I took the classic gamer's optimization approach: military victory. After all, why wait for my inevitable cultural victory when I can just send my superior army to crush the opposition and annex their land to mine, thereby winning the game?
As my army crushed the opposition, the in-game music turned from pleasantly ignorable and ambient into rather dark and sad compositions. Every time I declared war and sent my troops over their borders, the music set the mood not of a glorious conquest, but of grief and despair. As my navy bombarded coastal cities, they caught fire, and I could hear the screams of civilians. As I destroyed the last city of the Indian empire, Gandhi appeared on the screen and congratulated me on destroying a kind and peaceful people. As I defeated my last opponent, I received the end-game screen, an image of WWI-era soldiers marching over a barren land, and again the music set a somber tone.
Here is a great example of the power of learning in games, following the themes in Koster's Theory of Fun. The game is clearly designed to be fun, and there is a sense in which my military victory was enjoyable, but even more than that, it made me think. The formal elements of the game (the rules) combined elegantly with the dramatic elements (the music and story) to produce a unique experience. Most games I play follow a single hero who single-handedly destroys the vanilla-evil opposition, and there was much rejoicing. In Civ, I actually felt guilty for destroying these other civilizations just so that I could "win."
I hope to be able to draw on this in my current efforts with the Morgan's Raid game (as well as the potential Underground Railroad project), where there is a similar lesson we wish to subtly teach: although the player takes the role of John Hunt Morgan, he is neither inherently a hero nor a villain, but the Civil War was undeniably an ugly and painful thing. We have an interesting design constraint in the game as well. Since it is designed for 4th grade students to play in schools, it's likely that it will be played without music, in crowded labs or during free time. It was the somber music of Civ that moved me the most; I can only wonder what would have happened if I had been playing without my speakers on, since I can never go back to my first experience.
Wednesday, September 29, 2010
Demon JHM: Final boss of Morgan's Raid
I think I have to go rewrite the design document now.
Sunday, September 26, 2010
Contemplating creative inquiry: a call for partners
One of the unique features of Ball State is the Virginia Ball Center for Creative Inquiry, known locally as "the VBC." The center supports seminars that: explore the connections among the arts, humanities, sciences, and technology; create a product to illustrate the interdisciplinary study; and engage the community in a public forum. The faculty and students who spend a semester at the VBC are completely committed to the project: the faculty member is relieved of all other teaching and university service responsibilities, and the students earn full-time credit for their participation. The seminars themselves are held off the main body of campus, in the beautiful and inspiring Kitselman Center.
I am considering applying to run a seminar in the next academic year, having talked the possibilities over with a few key people, including my department chair and the director of the center. A VBC seminar would be the natural evolution of my work on game design and development. All of my previous projects share a common shortcoming, namely that they have been shoehorned into 3-credit experiences under conventional university scheduling constraints. A VBC seminar is an opportunity to collaborate with students in a legitimate studio environment. In practical terms, we would really be an indie game studio.
I would like to use the seminar to create a game, created by following principles of agile software development. The two missing specifics are the community partners and the game itself. One compelling idea is to build upon my experience with the Morgan's Raid project to make another explicitly educational game for school-age children, potentially on the Underground Railroad. I already have collaborators and potential community partners for such a project, and creating software for K-12 has a high impact factor. Another option is to make something subversively educational. I agree with Raph Koster's theory that fun and learning are intrinsically tied, and it would be a great design exercise to make something superficially "simply fun" that, in fact, teaches 21st-century values.
This post is both a reflection and a call for partners. If you are part of an organization that has a compelling story to tell, or are in the games industry and want to explore strategic partnerships on community-focused developments, or you have a crazy idea that just might work, let me know. You can leave comments here of course, or you can email me (firstname.lastname at gmail). VBC application materials are due at the end of the calendar year, so there's time to bounce ideas around.
Thanks for reading. By the way, if you're a BSU student who will be around next year, think about participating and spread the word. I want the cream of the multidisciplinary crop!



