Brian Button from the patterns and practices team gave a session bright and early Friday morning that was great. He covered how to write frameworks. What’s interesting is that he focused on writing frameworks as a non-technical problem since he’s seen too many frameworks that solve the wrong problem very well. J
- Rules for Framework development
- Clients come before frameworks.
- Be sure that you are solving the right problem.
- Quality, quality, quality.
- Be an enabler: You can’t solve every problem, so solve many problems but allow for extensibility points.
- Creating frameworks is a people problem.
Brian stress that it’s impossible to write a good framework without a real application using it. It will end up missing the mark. He suggests, instead, writing several applications and harvest a framework from the common parts of the application. This resonates with me because I believe it’s very difficult to write code that’s intended for reuse. I write code for use, and if it needs to be used elsewhere, I’ll harvest it into a shared library.
Brian was very bold at this Microsoft conference, and I applaud him for this. He stressed automated testing, and he said that here and now there is NO EXCUSE for not writing automated tests. Bravo! Brian contends that functional testing is a waste of a tester’s time. The thought is that testers are too valuable for functional testing that could be covered with automated testing. Testers should be testing the harder things.
Brian shares my frustration about sealed classes in the .Net Framework. He has encountered parts of the framework that are sealed, and when he needs to extend them, he can’t. Sealed classes are hard to write testable code against. He made a good point that I hadn’t thought of before: If you seal a class, you are saying “I can predict the future, and this is all that this class will ever need to do.”
Finally, Brian advocates these in creating a framework.
- Do open planning.
- Practice open prioritization.
- Show visible progress.
- Don’t allow surprises.
- Resist the urge to create something new. Harvest frameworks from existing applications.
- Encourage quality throughout the project. Lead by example and testers rule!
This evening, I had the privilege of meeting the woman behind microsoft-watch.com, Mary Jo Foley. I snapped a picture of her sitting next to Ian Cecys.
Party with Palermo was a big, fun success. We had about 30 folks at the hotel bar, and the beer was flowing. Everyone had a great time talking about all sorts of geeky things, and we finally called it quits at 12:30 am.
You can see some pictures here: (only works with IE) http://codebetter.com/blogs/jeffrey.palermo/archive/2006/05/11/Party_with_Palermo_2006.aspx
- 2.0 Framework assemblies have been NGENed to reduce JIT compilation. This helps with memory usage when running multiple AppDomains in a single process (multiple applications on a single web server).
- Another new feature new in ASP.NET 2.0 is the AppDomain unloader. This is configurable by time of inactivity. If an application is idle for that amount of time, the AppDomain is unloaded to free up memory. This is configurable in the <hostingEnvironment /> element (idleTimeout setting). He demonstrated this feature by attaching the EventLog with the health monitoring feature to write an event when the AppDomain unloads. This feature is great for hosters because it will allow them to serve more customers on a single server (customers who have a small application with light traffic).
- Small assemblies still take up 64k of memory. Some customers run into problems when loading many, many (hundreds) of small assemblies in a worker process. This leads to memory waste because there will be unused space lost between assemblies. This situation is when someone has an application with way too many assemblies. The real solution is to refactor the solution to collapse code into fewer assemblies, but hosters can’t always compel their customers to do that, so Microsoft is providing a mitigating solution for this scenario.
- This scenario could also happen with applications that use the App_Code directory many small assemblies are created at runtime.
- SGEN is a new utility to combine assemblies into a fewer number.
- Using Web Application Projects avoid this problem scenario because developer will decide how many assemblies their application needs.
- Large directory structures: ASP.NET relies on file change notifications. This can hiccup with large directory structures. This problem is expanded when the files are on a network share or network-area storage.
- One thing we can do is change the registry to configure FCN (file-change notifications) to “1”. This will stop ASP.NET from spamming the network share with FCNs. A side-effect is that changing the web.config won’t cause an AppDomain recycle automatically. This is a solution to allowing the application file to be on a network share, but it’s a change to operational behavior. No longer would the website be recycled, but when changing files, the recycle would have to be done manually.
- For most of us, this problem will never come up, but it does occur with very large directory structures.
- ASP.NET also recycles AppDomains when too many directory changes occur or too many file changes occur.
- Other file-system changes:
- New in ASP.NET 2.0, a directory deletion now causes an app-domain recycle. Being aware of this can be beneficial if needing to delete directories.
- A workaround for this is to make a directory junction using linkd. This makes a virtual folder node. File-change notifications don’t flow over virtual folders, so ASP.NET won’t receive the event, and the app-domain won’t be recycled.
- Asynchronous page processing: If a page has a long-running task (like calling a web-service of a 3rd party vendor), the page can set this to run asynchronously. This releases the current thread back to the threadpool while the long-running call happens. When the long-running call finishes, the request will grab a thread again and complete. The allows the thread to be available in the threadpool for other requests when, otherwise, it would be sitting there doing nothing. This helps application performance on a fewer number of threads.
- Unhandled exception behavior:
- ASP.NET 1.1 suppressed unhandled exceptions on child threads.
- ASP.NET 2.0: The process is terminated. This is a big change.
- If this is a real problem for you: go to the aspnet.config (in the framework directory) file and set <legacyUnhandledExceptionPolicy enabled=”true” />
- To track down the error, you can trap the unhandled exceptioin event and log what happened before the process shuts down.
- ASP.NET sets a limit of cache per process. This is a problem if you try to shove 1GB of stuff into the cache. Cache scavenging starts at 90% usage of cache.
- We can use the perf counter to track: ASP.NET Apps v2.0.50727 – Cache Total Entries. What might happen is shoving a lot of stuff into the cache, and the system immediately starts to clean it up. We can also avoid sliding expirations because it can cause stuff to never drop out of the cache.
- Cache limits: 800MB is a normal limit for cache. As an ASP.NET application is running over many days, virtual memory can become fragmented. For a 32bit box with 2GB of memory, 800MB is safe for fragmentation. X64 architecture makes this limit go away.
- You can go into application pool settings for IIS and change the limits. There is also a new <caching /> config section that can be used.
I’ve started a Tech Ed Foldershare for digital pictures. Check
out foldershare.com if you don’t know how it works. I’ve started
it off with some pictures of Party with Palermo. I’ll make
everyone interested a contributor.
The end result of this is that for everyone who participates, we’ll all
get each others’ pictures. Whatever pictures you contribute will
be passed around to all who sync up.
You can email me through my blog, and
I’ll send you a personal invite. This can be really cool if we
have a handful of contributors. This will also work if you just
want to get all the pictures but don’t have any to contribute.
The main repository is on my personal server, so it’s online all the
I’m organizing some Chat Backchannels for the breakout sessions at Tech Ed. Currently, a session is a speaker and a sea of people watching. Chat Backchannels have been very successful in other events. This is how it works. Attendees who have laptops open up the chat screen during the session. Participants can post questions and answers. The bandwidth for communication and learning grows with the number of participants. Perhaps someone wasn’t clear of the last point of the presentation. Another attendee can help clarify, and it can have a pretty good debate as well!
Here is how it will work:
When you attend your session, log into MSN chat. Go to a chat room with the name of the room you are in. For instance, if you are in room 109 AB, go to room “teched109ab”. Start the name with “teched” and finish it with the room name. No spaces and all lowercase. I’ve created some already, but if a room doesn’t already exist, create it. You are the first one connected. Other people will then connect, and the chat will begin. Here are some links to some rooms:
When creating a room (if you have to), when you type in the name, make sure you munge it together and make it all lowercase so that others will find it when typing it in.
Pass the word. This is a grass roots movement that I will be asking the speakers to support. Please blog about this to pass the word. If you know any speakers, encourage them to announce this at the beginning of their session to kick start the chats.