javaranch’s forum migration – want to know more?

The JavaRanch Journal about the forum migration is out.

Since I was involved in the details of the project, I wrote quite a bit.  It contains:

  • My overview of why we did it, what technologies we used, the timeline and process
  • Pauline’s interview with Ulf, Ernest, Bear, Amit and myself
  • My article on the data migration including analysis.
  • A cute interview where Ernest talks in elvish along with a cute extended analogy he wrote comparing the forum migration to a physical farm move.
  • A Lucene article from the Lucene in Action authors.  (JForum uses Lucene making it relevant to the migration.)

educating software developers

Reading  Bjarne Stroustrup on Educating Software Developers really got me thinking – about questions I see from students at JavaRanch/reading, how my own education fits in and what I would like to see from new college graduates.

Yet while Stroustrup agrees that Java has been used to dumb down CS programs, ultimately, “the problem is one of attitude, more than an issue of programming language.

As the quote shows, he doesn’t just talk about a simplistic view of things.  It was one of the most thought out articles I’ve read in quite some time.

My view from JavaRanch and reading

Few students see code as anything but a disposable entity needed to complete the next project and get good grades. Much of the emphasis in teaching encourages that view.

This is definitely a problem.  One of the manifestations of it is students who try to get help on one specific programming assignment (or worse – purchase a solution.)  No thought is given to how not thinking about the assignment is going to hurt the student of future assignments or classes.  It’s like math – you can’t get away with not learning how to do algebra if you expect to do calculus.  Similarly, you can’t expect to write a complex program if you can’t write a simple one.

Better are the students who do the assignment of course.  But it’s still a disposable entity in most courses.  There are a few that build it up over the course of the semester such as the LISP course that I took.  In my mind, these are the best kind because they force students to look at code they wrote weeks/months ago.  Reading code instills an awareness of the impacts of style down the road.

Essentially all had their code littered with “magic constants.” They had never been taught that was bad style – in fact they had never been taught about programming style because the department “taught computer science; not programming.” That is, programming was seen as a lowly skill that students either did not need or could easily pick up on their own.

Showing examples of “good” and “bad” code is still rare in teaching programming.  This is true in both academia and in books.  When I read the Dietel Intro to Java book, some of the examples were quite long.  (The Swing methods spanned pages.)  I saw many instances of things that could have been extracted into methods.   Now this is a book that does teach programming so the “computer science” thing isn’t an excuse.  I’ve seen this in other books as well.  If the first lengthy code students see uses the “throw tons of code into one method” approach, how are they expected to know better?

Similarly, many books that teach JSP have examples with JDBC code in the JSP.  This is something that is considered horrible practice by industry and not a stylistic thing.  When people post questions on JavaRanch mixing JSP and JDBC someone will typically point out that is bad practice.  The poster usually comes back saying he or she read it in a book or that’s what the teacher said to do.  Again, how is a beginner supposed to know not to do things like this when all signs indicate this is how things work.

My education

As an undergrad, I was in a Computer Science program.  This covered the range of topics you would expect – theory, practice, programming (in a few languages, data structures, etc), database, networking, etc.

We did have a software engineering course where we built a larger system as a class.  While it covered the phases (design, etc), I don’t remember much emphasis on clean code or testing.  To be fair, I took this class the first semester it was offered.  It likely got better after that.  The current course description reads “Principles of software engineering including the software life cycle, reliability, maintenance, requirements and specifications, design, implementation, and testing.”  So I have hope that it teaches more of the important skills now.

As a graduate student, I studied “Computer Information Technology” which was a mix of more practical topics – general industry themes, management, communication, programming (one language) and design.

What really jumped out at me in the programming class was that we were asked to peer review each other’s code.  This is a good thing – code review is an important skill.  Then I saw the checklist.  One of the things we were supposed to check was “whether the code compiles.”  I attended grad school while working full time as a Java developer.  I had enough experience to know that code that doesn’t compile isn’t useful.  It’s better to have compilable/runnable code that doesn’t do as much.  I flat out refused to review code that didn’t compile.  My “review” of such code was one line long – “doesn’t compile – doesn’t work.”  The problem here is that academia is willing to accept and grade code that doesn’t compile in some instances.  Would that fly at your job?  It wouldn’t at mine.  Nobody can claim something is “done” if it doesn’t compile.

What I’d like to see

Education should prepare people to face new challenges; that’s what makes education different from training. In computing, that means knowing your basic algorithms, data structures, system issues, etc., and the languages needed to apply that knowledge. It also means having the high-level skills to analyze a system and to experiment with alternative solutions to problems

I absolutely agree with this.  However, I don’t think think education should conflict with training.  I’m all for training entry level hires and interns.  However, I don’t think it should be necessary to re-train them to unlearn bad habits taught by a college.

So, brush up on your communication skills.

Another thing that it would be nice for schools to acknowledge.  My business minor taught communication and writing.  My computer science major barely recognized they exist.

Learn your first language well. That means trying it for difficult tasks. Don’t obsess about technical details. Focus on techniques and principles.

Learn another programming language; choose any language that’s quite different from what you are best acquainted with. You can’t be a professional in the IT world knowing only one language. No one language is the best for everyone and for everything.

Don’t just do programming. Computing is always computing something. Become acquainted with something that requires your software development skills: Mediaeval history, car engine design, rocket science, medical blood analysis, image processing, computational geometry, biological modeling, whatever seems interesting. Yes, all of these examples are real, from my personal experience.

All good advice.  Learning multiple languages certainly makes you stronger.  And learning a business domain makes you able to relate programming to the real world.

javaranch/jforum – nailing down a threading problem

Similar to the thought process for debugging a performance problem, here’s one for debugging a threading issue:

  1. In Production, we have a problem where the threads in a forum listing disappear showing only one or two threads in their place.  We found a workaround pretty quickly (clear the cache), but want to stop the problem from occurring.
  2. For the better part of a week, we found it puzzling.  A couple moderators noted that the problem seemed to crop up after moving a thread from one forum to another.
  3. We still haven’t been able to reproduce the bug on demand.  It sounds like something threading related.  These tend to be the mysterious looking bugs.
  4. All right.  I’m going to sit down and look at the relevant code now.
    • I know the problem has something to do with the TopicRepository class which is where this data is stored.
    • I see clearCache method that empties the cache is in fact called when we move threads.
    • I also see addAll resets the forum list.  This seems to not be called since we only see a post or two.  Hmm.  Let’s see where this is called.  I see; it’s called when someone requests to view the list of topics in a forum.  The code gets the topics from the cache.  If there aren’t any topics cached or the cache reports as “not loaded” for the forum, it gets them from the database and loads the cache.  Clearly this isn’t happening.
    • I also see a method that adds a single topic to the cache.  It is called when we post announcements.  This looks promising.
    • I tried locally to reproduce the bug and got it!  We weren’t posting announcements though.  Then I searched the code for other calls to this method.  There is another call when we “update board status” which happens after someone replies to an existing thread.  Eureka!  This must be what’s happening.
  5. Now I can reproduce on our sandbox server on demand.  (see path below.)
  6. How to fix.  Well the topics being non-empty doesn’t seem like something I can control.  Looking at the other part – the loaded flag – seems more promising.
  7. I see the flag isn’t cleared in the clearCache method.  I’ll add that in and see what happens.
  8. The bug goes away!  Great news!

The path that causes the bug to manifest:

  1. open two threads in the Test Forum
  2. move a thread from Test Forum to Another Test – this clears the cache
  3. in Test Forum, add a post to an existing thread – this adds one topic to the the list
  4. reload list of threads for Test Forum – now it thinks there is one topic in the list and doesn’t look for more
  5. you only see the one edited thread in the list