Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

For some reason or another today I was curious about this question: If you flipped a coin ten times, what are the odds that the coin would come up heads ten times, or tails ten times)?

I'm sure there is a way to determine this statistically, but I don't know how to do that, so, being new to Ruby, I wrote a little Ruby simulation program -- essentially a Monte Carlo simulation of the problem -- to find the answer. (Pretty boring, I know, but hey, I was bored, interested in learning Ruby, and didn't feel like reading any more of The Stand right now.)

Assuming you are the root user on a Linux computer, here's a quick example of how to run a program with a Linux crontab entry as another user. Specifically in this example, the program being executed is run as the user nobody.

I recently started to model an application that makes extensive use of web service calls, and my customer asked me to include a UML sequence diagram to show the flow of calls in the system. This prompted me to wonder, "What is the correct way to show distributed systems (like a web service) in a UML sequence diagram?"

If this link is correct, in a UML diagram you show remote systems as actors.

I was just modifying a Perl program so I could use a regular expression (regex) to search a Perl array for all less-than (<) and greater-than (>) symbols, and replace those with their HTML equivalents tags ("&lt;", and "&gt;", respectively).

Here's the source code I created to perform this Perl array search and replace operation (a Perl replace regex operation):

As a small business employer, I've watched the cost of health insurance increase by 200-300% over the last four years. Last year we were "fortunate" to have an increase of only around 10%. It's gotten to the point where paying health insurance for a family is well over $1,000 per month now.

Here are a couple of notes I just sent someone on how to get started writing a software requirements specification.

They may be a little vague, but I hope they show my intent, or perhaps my frame of mind, when writing a software specification.

Fred,

Here are two notes on my mental approach when writing software requirements specifications:

I don't know if you've ever had UML use case burnout, but I think I just hit the wall. Here's a link to some use case prose that shows I've written way too many use cases recently.

Maybe this is a good way to know when you need a vacation?

 

Question: I want to show how my application classes are segregated into packages. Is there a UML diagram for this?

Yes, you pretty much named it. A UML package diagram is good for demonstrating the packages (or packaging) in a software application, as well as the dependencies between packages.

 

Question: I want to look at the relationships between the classes in my software application. What UML diagram should I use?

UML Class diagrams are very good for showing the static relationships between classes, such as inheritance and aggregation, one to many relationships, and many other class relationship details.

Question: Is there a UML diagram to visually show the processes in a system?

Yes, you can use use case diagrams to represent the use cases (processes) in a software system. Use case diagrams show the actors in a system, and the ways in which these actors use the system.

This is why I use the terms "use cases" and "processes" interchangeably. IMHO, "use case" is a fancy way of saying "process", or perhaps more accurately, user-initiated processes, or event-driven processes.

 

Question: What UML diagram can I use to show how my application will be distributed in the real world?

Use a UML deployment diagram. They can be used to conceptually show the physical nodes and software components that will be distributed in a software application.

 

Question: What UML diagram can I use to show how an object state changes during its lifetime?

A UML state diagram will do the trick. A state diagram is very good for showing how an object state changes over the lifetime of a software application, and the triggers (triggering events) that cause the state to be changed.

 

Need to show how objects collaborate during the lifetime of a software application? You'll want to use a UML interaction diagram -- either a sequence diagram or a collaboration diagram.

I prefer the sequence diagram, because the time sequence of events it displays more easily demonstrates the interaction of objects over time, but other developers prefer collaboration diagrams.

 

Question: I want to visually model a multi-threaded software application. Can UML help?

Yes, UML activity diagrams can be a great tool for visually modeling the flow of control in a multi-threaded application. A UML state diagram can also be used to show the states objects can be in during their lifetimes.

 

Question: I want to visualize the activity in a use case ... what UML diagram can I use to do this?

Use an activity diagram. These UML diagrams are good for visual workflow modeling. Swimlanes in UML activity diagrams can also show the behavior of different actors within a workflow process.

 

Following a speech two days ago, I'm struck by how very little we use the Unified Modeling Language (UML) on our software projects. Occasionally I'll create some activity diagrams to model how users get their tasks done, but that's about it. Typically when we create a software requirements specification this is what we deliver:

Some times when exceptions occur when users are running a Java JFC/Swing application, it's nice to be able to show them a long message about what happened, i.e., something more than a one-line message. To that end I created a really simple Error Message Panel (ErrorMessagePanel.java) that you can use with the JOptionPane to display long messages.

Here's a link to a Code Kata site. It discusses the importance of practice in the software industry. It seems like the basic theory is "If musicians and athletes believe that practice is extremely important, why don't developers (and organizations that develop software)?"

At the moment I'm not aware of any software organization that takes time out for skills practice, unless training on new products or languages counts ... and I don't think it does. Kudos.

Here is some sample Java source code that shows a simple technique to display a GIF, JPG, or PNG image using a Java ImageIcon and JLabel.

Java array FAQ: Can you share some examples of how to create arrays in Java (Java object arrays)?

While I generally work with lists and maps in Java, I occasionally need to create object arrays in Java. Since I don't use arrays that often, I thought I'd share some examples here so I can have a handy Java array syntax reference.

A simple Java String array

I work with the String class a lot, and here's how to create a String array in Java: