-
The answer is NO. It does not. There are a few things you must be aware of when creating ASP.NET applications.
I ran some experiments where I intentionally set random values into different types of variables, and then slept for a random amount of time in the web service before returning the same variable to the caller. Then I hammered the web service with hundreds of simulataneous requests. It was pretty easy to see which variables were thread safe in this context, and which ones weren't. The non thread-safe variables had a different value by the end of the function more than 50% of the time. The safe variables were always the same regardless of how many threads I had running.
Note that the behavior appeared to be the same regardless of whether you are using IIS or the ASP.NET development server, and regardless of whether you are running retail or debug.
Here is the logic behind the threading model. ASP.NET creates a thread pool for your web application. Your class is instantiated once for each thread, and requests are queued on a per thread basis, your method will not be re-entered while it is executing. So doesn't this solve everything? Not quite.
Referring to the code below, the following types of variables are OK to use in ASP.NET:
- Local variables inside a method
- Member variables in your WebService class
- Member variables in a helper class that is local to your method.
- Member variables in a helper class that is referenced as a member inside your WebService class
- The user's session. (Session storage appears to be local to the thread)
The following types of variables are NOT thread safe and must be locked with the "lock" command or avoided if you want to ensure they won't change out from under you.
- Static variables in your WebService class
- A static reference to a helper class that contains member variables
- A helper class that contains a static variable
- the application value collection.
Here is a code view of the above:
public class Service1 : System.Web.Services.WebService
{
int MEMBER_VARIABLE = 0;
static int STATIC_VARIABLE = 0;
helper MEMBER_HELPER = new helper();
static helper STATIC_HELPER = new helper();
class helper
{
public int HELPER_MEMBER_VARIABLE = 0;
public static int HELPER_STATIC_VARIABLE = 0;
}
[WebMethod(EnableSession = true)]
public int LocalVariable(int value)
{
helper LOCAL_HELPER = new helper();
// THREAD SAFE
int LOCAL_VARIABLE = value;
MEMBER_VARIABLE = value;
LOCAL_HELPER.HELPER_MEMBER_VARIABLE = value;
MEMBER_HELPER.HELPER_MEMBER_VARIABLE = value;
Session["Hello"] = value;
// NOT THREAD SAFE
STATIC_VARIABLE = value;
STATIC_HELPER.HELPER_MEMBER_VARIABLE = value;
helper.HELPER_STATIC_VARIABLE = value;
Application["Hello"] = value;
}
}
Hopefully this is helpful to you. If you have any questions related to this, please let me know and I'll dig up the answers!
-
Last week I was in Sacramento, California at the IEEE Info Visualization conference. It was great learning more about the latest research in human/computer interaction as it relates to information. Plus, there was a lot of brutally cool graphics to look at. They had a poster contest, not to mention an art display, and a number of product demos and seminars. There was also a contest to create a visualization for interacting with an entertainment database.
The keynote speaker was one of the graphics editors from the NY Times. He talked about some of the behind the scenes work that's done to find the "best" way to present information - in some cases it takes them several iterations to find the right representation. Other times, they work on an incredibly short deadline, starting only hours or minutes before their press deadline. They also make online visualizations. Some of the more interesting online interactive charts can be found here and here.
One of my favorite charts was this human head. Yes, it really is a human head chart. The hair represents several dimensions at one time by using different characteristics. The different items were: length of the hair, the hair color, the branchy-ness (whether the hair has split ends), and the density and location of the hair (from front-to-back). Kudos to the students who came up with this one!
Theoretically, you could bind real data to each of these characteristics if you had a data cube containing at least 5 dimensions - let's imagine the head represents the greater Seattle area. You could picture the front of the head is North Seattle, and the back of the head is South Seattle. Hair growing in each area may represent the population density in that area. The hair length might represent the average income, and the hair color might represent the level of education, and the split ends might represent crime rate. This is based on the theory that split ends are bad, so I think that works. Given that these dimensions are all independant characteristics it is possible to represent any combination of data. For example, you could have a light colored hair that is either long or short, just like a dark hair can also be long or short. So looking at the overall picture, you could detect trends - for example, is most of the short hair dark colored? This implies that less education results in less income. What if you find an area where the hair was light and short, this means the people are highly educated but still aren't making much money. They must have selected the wrong major, or perhaps it represents an area where people are more highly educated but still in school, near the University District for instance.
It's interesting to compare this human head display to the charts most people really use - imagine if the next version of Excel had a human head chart! That sounds a bit nuts, but why not?! Why should Office only produce conservative professional businessey looking graphics? Well, I have a theory that there are hundreds of visualizations that people could dream up besides the usual lines, bars, and pies. Some of them would certainly be off-the-wall like the human head, but others would be both innovative and useful to others. And to be fair, some of them would be completely incomprehensible. I call for a revolution of sorts - let there be so many visualizations that we need to invent some way to search through all of them and rank them. I'm ready to go solve that problem; I've been thinking about it for the past few weeks.
If you have an interest in data visualizations - I want to hear from you. Send me email if you've got something unique to share. I'll publish the best links I get in a future blog post. Also if you are a coder, and you want to make thinking about visualizations your day job - send me your resume. I am currently hiring.
Now, I'll leave you with another link which will probably keep you busy for at least 30 minutes if you haven't seen it before: Data Visualization Modern Approaches
-
This week I thought I would respond to a question about Scrum that I received in email.
I am trying to understand how various companies handle prioritization of of their product backlogs. To this end would you be able to shed some light on how this happens at Microsoft? Specifically, I would like to know:
i) What prioritization methodologies are employed?
ii) How are interrupts handled within a sprint?
iii) Is there a clearly defined interrupt policy?
iv)How is prioritization implemented within escrum?
Below Hamsa M weighs in with her opinion, speaking from her experience on a few different teams (not all teams in Microsoft follow these conventions)
Prioritization is basically driven by the product’s goals and objectives. If your product is all about user friendliness, then the user-friendly features would automatically be on the top of the list. For us, we set some guiding principles around the product, they are agreed upon by our stakeholders and the team uses them to prioritize the features. This offers the best ROI for the time available.
I am not sure what kind of interrupts you mean. In general, additions to the product backlog items are not allowed to be added during the middle of the current sprint. This is per the Scrum guidance of Ken Schwaber. For a sprint, there can be planned interruptions like vacations, trainings etc., and unplanned interruptions like sick leaves and customer incidents. Planned interruptions should be handled in the sprint planning meeting to calculate the team time commitment for the sprint and reduce available hours. For unplanned interruptions, the team uses the daily meetings to see if it can still pull the sprint tasks and successfully complete the sprint goals; or whether any of the low-priority goals/tasks need to be adjusted. The product owner can help address the questions on the priority, if any.
Within eScrum, the product owner can set the priorities for each of the product backlog items. In addition to that, the order field can be used to sequence the items with in a set of prioritized items. For example: if you have 10 priority 1 feature items, you can assign a order for each of the item from 1 to 10 or any other numerical order value, so if the team can pick up only priority 1 items, they can focus on the items by order ranking.
If you have other comments on this topic, please feel free to post a response.
As a note to those who might be waiting for eScrum to be re-released, I have learned the team decided to take some more changes before doing another external release, so it may take a few more weeks to show up. The next release should address the primary issues that have surfaced, and will definitely have an automated setup (which I have previewed and it looks great). Please hold tight, and if you find any other issues, please be sure to post them in the forum
-
I suspect a lot of people wonder how Microsoft does its software development internally. Does Microsoft use the development tools we sell such as Visual Studio? Do we use custom internal tools? or (gasp) Open Source tools?
The answer is ALL OF THE ABOVE. There are hundreds of teams in Microsoft, and nearly every team does things a little differently. Long ago, everything was very custom and proprietary. But increasingly, the tools created by our own Developer Division are becoming widely used by internal teams. Visual Studio Team Foundation Server is one such tool; TFS brings together key resources such as bug (issue) tracking, source code control, and builds. It's also a platform for creating other development tools! One major advantage to creating custom tools on the TFS platform is they immediately scale. TFS features such as an extensible backend and data warehouse, and unified security administration make custom tool development highly efficient, and greatly reduce maintenance costs.
This week, you are offered the chance to see one of the internal tools that Microsoft uses; eScrum is now available from the Microsoft Downloads site. eScrum is an increasingly popular tool used by over 50 teams within Microsoft . It is a combination package that includes a template for Visual Studio Team Foundation Server, as well as an Ajax based web application. The eScrum template provides users of TFS the ability to create and track scrum artifacts such as product backlogs, sprint tasks, retrospectives, and burndown reports. The eScrum web application allows users to access their scrum artifacts from any machine with an IE6 or IE7 web browser. In addition Visual Studio users can access their data via Microsoft Excel or Microsoft Project thanks to the integration layer provided by Visual Studio.
Scrum project management is gaining a foothold within Microsoft, especially among smaller teams who want to take advantage of the benefits offered by an Agile development process. Teams often start learning the Scrum process by using index cards or post-its, or perhaps using Microsoft Excel to organize their tasks. However, after some time many teams outgrow these techniques and search out more comprehensive tools that give them greater visibility into their own behavior. One of the key principles of Agile development is that participants are self motivated and have a desire to improve their productivity and overall efficiency. eScrum provides comprehensive reports that track metrics such as velocity, estimation accuracy, cumulative flow, and burn down.
For internal Microsoft teams, eScrum is a hosted service managed by the IT department. Unfortunately, this is not the case for the rest of the world. If you want to download eScrum and install it, be sure to follow the instructions carefully. You must have Windows Server 2003 and a licensed installation of Visual Studio Team Foundation Server (2005). There are several dependencies which must be installed separately from eScrum in order for the web application to function. These dependant packages were not included in the install package due to licensing restrictions or company policy. The external release of eScrum also has a few configuration steps that must be performed manually. This includes modification of web.config as described here.
The team that originally developed eScrum has been monitoring the MSDN Power Tools forum and is interested in the community response. As a result of customer feedback this week, the team is currently working to improve the setup process and plans to post an update to eScrum in the next several days which will include a fix for the aforementioned issue.