I have broken my body, and now I must repair it.

November 16th, 2009

Let’s talk about what’s been going on inside my body on an average day for the past few years.

I started the day with whatever breakfast I felt like.  Sometimes it would be leftovers, but I’ll pick “kolache day” as a representative sample.  On these days (twice a week) I’d stop by Kolache Factory on the way to work and pick up two delicious bacon and cheese kolaches around 8:30 AM.  This is a somewhat sweet bread roll stuffed with bacon and cheese.  When this hit my stomach, the process of converting that bread roll to sugar started.  It was slowed somewhat by the fats, but we aren’t talking healthy fats here (I can’t find information about what kinds of fats the kolache contained; I’ll just assume the bacon and cheese contributed a good bit of saturated fat.)  The carbs were quickly converted to sugar.  This caused an increase in blood glucose, which caused my pancreas to increase blood insulin.  This didn’t affect me much because lunch was usually at 11 or 11:30.

At lunch, my “I don’t like what’s in the cafeteria” food was a bacon cheeseburger on a wheat bun with tater tots.  Let’s talk about what this did to my body.  The bun, though it is “healthy” wheat, is made from enriched flour which is quickly converted to sugars.  The cheese and meat contain saturated fats.  The tater tots are a one-two punch: finely chopped potatoes are digested into sugar very quickly and the oil is unlikely to use unsaturated fats.  Bacon, as usual, doesn’t contribute much.  I washed it all down with a sweetened tea; I like tons of sugar so we’ll say it’s probably 1 cup of sugar per 2 quarts.  Despite the fat content of the food, the volume of carbohydrates I dumped into my stomach resulted in a huge blood glucose spike.  This caused the pancreas to produce a higher volume of insulin.  At this point let’s diverge to an analogy.

I’m bad at cooking bacon, but it’s because I’m not patient enough to use the tools I have.  I use thick cookware; either cast iron or cast aluminum.  This cookware takes a while to preheat.  I tend to get impatient and start putting the bacon in the pan before the cookware has matched the heat of my pitiful electric stove.  When I don’t hear that satisfying sizzle, I turn the heat up on the stove.  Eventually, the cookware reaches the temperature that the original heat setting would have caused.  This produces the sizzling effect I want and I assume the pot is the appropriate heat.  A couple of minutes later, the pot reaches the actual temperature I have set my stove to, and before I have time to react the bacon is overcooked.

This is what happened in my body every day at lunch.  I dumped a ton of easy-to-digest carbohydrates into my stomach, which resulted in rapid conversion to sugars.  The glucose in my blood is like the bacon in the pan.  My pancreas is in charge of making sure that there’s enough insulin to process the sugar in the bloodstream; it’s like me watching the bacon to make sure it cooks.  My pancreas noticed blood glucose spiking (the bacon isn’t sizzling) so it produced more insulin (the heat gets increased.)  The insulin did whatever it does and brought my blood glucose down (the pot reaches the right temperature and the bacon sizzles.)  But there was too much insulin!  Soon, blood glucose crashed beneath the threshold desired by my brain (the bacon overcooks.)  Since my brain knows it can’t manufacture glucose without fuel, this translated into hunger and a craving for something with easy-to-digest carbohydrates.

Now we’re at 3:00.  My lunchtime dose of carbs guaranteed I’d be short on energy within a few hours; the rapid spike and decline of glucose caused me to reach for the vending machines.  Sometimes I did “good” and ate a banana.  However, that just caused another spike/crash cycle that I didn’t notice because the crash coincided with supper.  My suppertime habits were more varied than breakfast and lunchtime, but I still favored easily-digestible carbs.  I generally ignored bedtime cravings because I knew it wasn’t good to eat before bed.

I was putting my body down a dangerous path.  I wasn’t aware of it, but I was creating a situation similar to diabetes. The rapid intake of carbohydrates led to dangerous levels of glucose, which led to dangerous levels of insulin, which led to cravings for more carbohydrates.  All this time, I didn’t need the carbohydrates and most of this energy was being stored as fat in my midsection.

The Intervention

Last month my employer required a cholesterol screening; it helps satisfy the insurance companies. Glucose? Perfect. Blood pressure? Great! Pulse? Perfect.  Good cholesterol?  Low.  Bad cholesterol?  Not measurable due to other factors.  Triglycerides?  944.

A normal triglyceride count is somewhere between 100 and 200.  Anything greater than 400 is considered high risk for stroke or heart attacks.  1,000 or greater is a guarantee that you will eventually develop pancreatitis; I don’t know what it is but I know for sure if my pancreas regulates glucose I do not want it to be ruined. 944 is my triglyceride count after 10 hours of fasting.  I know that my “normal” count is probably much higher.  It doesn’t take a decade of study to decide that this is an unsustainable state for my body.

The Resolution

My physician wants to do some other screenings, but for the time being has advised me to perform 40 minutes of exercise 4 times per week and consider the South Beach diet.  I’m currently preparing for Phase 1 of South Beach.  In this phase, carbs are very carefully regulated and must only come from hard-to-digest sources.  Years of the carbs-glucose-insulin-crash cycle has made my body respond to glucose poorly; Phase 1 is designed to correct this by completely removing the cycle.  I’m not starting yet, but I am trying some of the foods to make sure I’ve picked things I’ll like eating.  Let’s talk about how today is different than usual.

I started the day with a trip to the treadmill.  I walked on “rolling hills” for 40 minutes and burned 200 calories.  More important: my heart rate was elevated, I required deep breaths, and my body was under stress.  This will increase the efficiency of my heart and lungs.  This will increase my muscle density, which increases the amount of calories I burn at rest (important, since I have a very sedentary job.)  I went back home and fixed a 2-egg omelet with a small amount of diced peppers and a slice of turkey bacon cooked in olive oil (I was patient and let the cookware preheat for 10 minutes!) This provided practically no carbohydrates (a few grams from the green pepper) and an abundance of unsaturated fat from the egg and oil.  Presumably, my free-range eggs contain Omega 3, which is important for controlling triglycerides.  The turkey bacon is 97% fat free; it might contain a little bit of saturated fat but its effect is negligible considering how much less it contains than pork bacon.  There’s cholesterol in the eggs, but from what I’ve read in the South Beach diet book it’s not much to worry about: there’s as much good cholesterol as bad.  I might swap an egg substitute for real eggs later, but I think the possibility of getting Omega 3 from the eggs might be worth it.  I’ll have to ask.

Since breakfast didn’t produce many carbs, I got listless around 10:30.  So I ate a light mozzerella cheese stick.  This put a little bit of fat along with protein in my belly; both take a while to digest and neither has a big impact on blood glucose.  My hunger was satisfied and I did not produce more insulin; it’s a win.

Lunch was a salad: romaine, baby spinach, ham cubes, half a boiled egg, a teaspoon of bacon bits, and 4 croutons.  The 4 croutons are probably the biggest worry but my hope is that the fat from the ham and fiber from the lettuce and spinach will regulate the digestion. I also doubt 4 croutons is a serious amount of carbs; a quick search turns up 4g for 2 tbsp, which means I probably ended up with 1 or 2g of bad carbs.  Not bad, considering my wheat bun, tater tots, and sweet tea added up to roughly 90g; that’s more than a 90% decease in intake.  I washed this down with an unsweetened tea; the caffeine may increase my appetite later but I cannot make it through an afternoon without it.

I’m looking forward to an afternoon snack consisting of some nut mix my wife and I made last night.  Again, it’s fatty, but it’s unsaturated fat.  The fat content ensures I’ll fill up before I eat too many.  Nut carbs mainly come from dietary fiber, which is digested slowly and do not produce the dangerous cycle that quickly digested carbs contribute to. The walnuts are a source of omega-3; this makes them something I need to consider frequently.

I don’t know what supper’s going to be tonight, but I’m going to be more careful than I have in the past.  Since I haven’t really started phase 1 I haven’t communicated the kinds of meals I need to my wife yet, so I can’t expect results to be much different.  Soon, we’re going to try out a few phase 1 recipes to get a feel for what they’re like and which ones taste good.  Once we’ve got enough variety to last the 2 weeks of phase 1, I’ll be well on my way.

My body is broken, and its my fault.  I can fix it, and it’s going to take a while, but the longer I delay this the harder it will be and the more likely I’ll develop a condition that makes it impossible to live normally.

I Joined a Project for Fun

September 7th, 2009

User ident on the XVBT forums asked for some comments and suggestions about his project.  I took a look at it and decided the number of comments sans explanation of fixes would exceed the size of a post, so I asked if I could join the project and make some lessons out of refactoring it.

The project itself is a neat little tool for automating ImageShack uploads.  On the outside, it looks pretty slick.  After inspecting the code, I have a bad feeling that it doesn’t work anywhere near as slick as it looks, but that’s why I’m here.  The application is an almost perfect example of what WinForms development does to suppress good software design practices.  In this ~3,000 line application, 2,600 of the lines are in ClientForm, the main form of the application.  This form is responsible not only for UI interaction, but all of the application logic.  There’s many other errors that are more related to what happens when a novice writes a large application than what WinForms inflicts upon you: dozens of unused methods, huge areas of commented-out code, no consistent naming conventions, etc. There’s at least a wrapper for the ImageShack API, but I haven’t peeked inside of that yet to see if it needs some work as well.  It looks like it was lifted from a blog by a man named Bryce Thomas, then converted from C# to VB.  I’m not sure if any attribution is currently given; if not I’m going to fix that.

The code for the client itself is not under any particular license, but does happen to have this notice at the top of each file:

'*************************************************************
'
' DX Coders
' Copyright 2001-2009 Simple Coders
' All Rights Reserved
' Created: 09/06/09                                   *
' Author: Johnson

' NOTICE:  DX permits you to use, modify, and
' distribute this file in any way.
' DX takes no responsibility on how you use
' this code. It is strictly for learning purposes
' and is not designed to cause harm. If you decide
' to reuse this code please give credit where credit is due.
'*************************************************************

I have entertained the notion that the developer(s) (there is a mysterious second developer involved that I’ve never met) are planning to have me clean up their application for free, then cut off my access to the project and sell it.  I would be disappointed if this happens, but I decided that the experience of reworking an application from a mess into something polished is something I need more than defense against my hobby work benefiting someone else.  The comments above mean that, should they excommunicate me from the project I have no qualms about releasing the source code and promoting the project as a fork under a very permissive copyleft license.

I have one concern at this point.  The code looks like it’s either a mishmash of examples gathered from various forums or the result of running a C# to VB .NET converter on a pre-existing project.  Indeed, one of the more questionable bits of code is admitted to be the result of running a converter on some C# example code.  If you have written an ImageShack upload client and this one looks familiar, please contact me with proof.  I will not work on a project that was ripped off.

As I work on refactoring, I’m going to make posts that detail why I did what I did.  I’m going to cross-post these onto the blog.  I’d normally do them *only* on the blog, but I don’t want to undermine XVBT’s policies by taking discussion of a user problem offsite.  I’m already skirting the edge by taking on a full project.

UI Control Naming Conventions

September 3rd, 2009

Microsoft was kind enough to publish a set of design guidelines for developing class libraries, and I use the book Framework Design Guidelines that is based on them daily. This has settled many disputes over the conventions our team should follow, and it’s the basis of many suggestions I make on the XVBT forums. The guidelines help lay out the practices that the .NET Framework team tries to adhere to when designing types. If everyone adheres to the guidelines, then the entirety of the .NET ecosystem will be consistent and usability will increase.

The guidelines have an odd position in the documentation. I find that most of MSDN and Microsoft’s other efforts are focused on helping the application developer. Contrary to this position, the design guidelines are focused on developers of class libraries that will be used by other developers. This is what I do, so it’s great for my demographic to get some love. However, the lack of focus on application development means there’s some important guidelines that aren’t there.

Chapter 3 of the books involves naming guidelines; you can follow along sans commentary online. The chapter discusses capitalization conventions and how to name every aspect of your code from variables to interfaces to DLLs. One omission that would be useful for application developers is guidelines for naming controls in applications.  I’ve experimented with 3 approaches, and each has its disadvantages.

1. Hungarian Notation

If this is established as the guideline, Hungarian notation is used for each control. That is, a text box for name input becomes txtName and a list view for displaying songs becomes lvSongs. Optionally, a leading underscore might be used, but I tend away from it when using this convention.

One benefit of this notation is familiarity. VB6 developers in particular favor this approach because it follows the generally agreed-upon conventions used in that language.  Another benefit is an increase in understandability.  When you see txtName, it is clear that this is a text box that represents a name.

One drawback is the naming guidelines use a strong DO NOT guideline to condemn Hungarian notation.  Nothing else in .NET uses Hungarian notation. This makes applications that follow the notation seem like they stick out a little. Another drawback is the notations aren’t really standardized. Most people agree on txt for TextBox and lv for ListView because these controls have been around forever, but newer controls like TableLayoutPanel and Grid don’t have agreed-upon prefixes. Also, how do you decide what to use for custom controls, UserControls, and third-party controls? One more drawback is this notation makes code brittle to change. Maybe your prototype starts with a TextBox but later you switch it to a NumericUpDown. This means you not only have to change the control and any logic that worked with it, but you also have to hunt down all references to the variable and rename it. (I admit I’m a relative newbie to Presentation Model patterns and it could be that this is less of a concern in those since the form would likely expose the control as a typed property, but I think it’s still applicable.)

To me, the drawbacks seem to outweigh the benefits. However, this is the convention I learned when I started in VB .NET many years ago, so I find it most comfortable and no matter how many arguments against it I hear, it’s the one I use.

2. Suffixes

When following this guideline, you pick a descriptive name and suffix it with the type of control. Use of camelCase or PascalCase is disputed, but generally I see PascalCase used more prominently with this technique. Using the examples from above, we’d use NameTextBox and SongsListView.

This has practically the same benefits and drawbacks as Hungarian Notation. You’re still identifying the type of control alongside the purpose, and it’s still clear from the variable name what kind of control is at work. This is technically a form of Hungarian notation, so still falls afoul of the DO NOT guideline. The problem with standardized prefixes is eliminated: since you use the full type name there’s no need for agreement. This technique is still brittle if you change controls.

Personally, I find that this convention clashes with how I think about the UI and makes it harder for me to find the variable, but this is probably because I’ve used Hungarian notation for years. I’ve tried following this guideline, but I find that more often than not I forget if I chose ItemCount or NumberOfItems as the prefix, and knowing the suffix doesn’t help me find it. Perhaps my naming discipline is poor, but it just doesn’t work for me.

3. Plain Old Variable Names

When following this guideline, you pick a descriptive name for the control and use that. There’s dispute over casing and usage of a leading underscore, but I find that two camps are the most prominent: PascalCase and _camelCase. Using our example controls, we would use Name and Songs or _name and _songs.

There are a few benefits to this approach.  One benefit is you aren’t using Hungarian notation so you aren’t falling afoul of any DO NOT guidelines. Another benefit is the code is no longer brittle if you change the control type.

Despite the benefits, there are many drawbacks to this approach no matter what casing convention is followed. If we’re writing a custom control or a custom UserControl that needs a text box for a name, then Name is already taken by Control.Name and we’ll have to pick a different name like PersonName. This can lead to accidental use of Name when you meant PersonName, and since you aren’t using the first name that came to mind you’re going to spend a lot of time trying to remember what your 2nd choice was. In addition, this casing convention is used for properties and constants, so if you have many of those your controls will be buried among them in Intellisense. This is why many people use the _camelCase convention, but since this is a very common convention for private fields it’s not much better.  Is _songs the control that represents the songs or a collection of songs? If you’ve got 20 properties with backing fields and 5 controls on the form, you have to wade through 25 entries if you can’t quite remember the correct name. _camelCase also looks particularly heinous when used as the x:Name attribute in XAML.

I find I am always dissatisfied when I use this convention.  If I use PascalCase then I almost always get the controls mixed up with constants. Even more often, the control name clashes with a property that I want to have and I end up having to pick a worse name for the control.  Then, I can’t remember the name I picked.  If I use _camelCase then the controls are buried among property backing fields, and name clashes still happen.  If _songs is the control that represents a list of songs and I want a Songs property, what do I do for the backing field? (There’s a few answers that involve generating the property value in different places, but most of them wouldn’t occur to a novice.) No matter how I try to follow this convention, I don’t like it.

I’m sure there’s other approaches I haven’t thought of, but these are the three I’ve tried. All of them have drawbacks that seem to outweigh the benefits, but I side with Hungarian notation out of familiarity. If there were guidelines to follow, I’d settle on the method they suggest, but there are none so I have a hard time deciding if I’m right.  What do *you* do?

Documenting SyntaxHighlighter so they don’t have to

August 31st, 2009

I upgraded to the new SyntaxHighlighter today in preparation for a couple of posts that hopefully I’ll make by the end of the month. (Topics: explaining and condemning default instances (VB .NET “feature”), a neat discussion of SRP that was generated from an XVBT post, and a possible series on creating design-time experiences for WPF controls.) My installation experience was less than desirable.

There is no documentation for installation on the SyntaxHighlighter wiki, or if there is documentation it’s not linked from the main page. There’s barely documentation for the features as well. There’s four or five “look what I can do” pages that demonstrate its features, but no pages that tell you how you can do these fancy things too. There’s some cool features, but the only way I can figure out how to make them work is to dive into the JS myself. Lame. For example, on the demo page there’s a demonstration of highlighting lines; what’s the syntax for this? Also, what’s the “html-script” attribute do? How am I supposed to find it.

Anyway, here’s how to install SyntaxHighlighter based on my experience:

  1. Copy the scripts, styles, and src directories to a location on your server. (Maybe src isn’t required; I included it just in case.)
  2. On the page that you want to highlight code, make sure to import brushes, import styles, and call the magic code that does the work. For example, if you want to highlight some C# code, your page header needs to include:
    <script type="text/javascript" src="scripts/shCore.js"></script>
    <script type="text/javascript" src="scripts/shBrushCSharp.js"></script>
    <link type="text/css" rel="stylesheet" href="styles/shCore.css"/>
    <link type="text/css" rel="stylesheet" href="styles/shThemeDefault.css"/>
    <script type="text/javascript">
        SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
        SyntaxHighlighter.all();
    </script>
    

    Do not load anything before shCore.js, or you will get errors.

  3. That’s all I would have needed to have an effortless install of SyntaxHighlighter; it’s a shame the documentation isn’t there. Before you get all “it’s a wiki: do it yourself” high-and-mighty on me, go try to add it yourself. You can’t. The leaf pages of the wiki are editable, but I can’t seem to find a way to edit the main page. Perhaps there’s a way to add a new page, but there’s no way to enumerate the pages on that wiki so without a link from the main page any new “Installation” page is going to be invisible. So I would, but I can’t. Hopefully, someone will eventually create an installation page so silly people like me don’t have to spend 20 minutes discovering that the order of the brushes really matters. Or maybe it’ll never happen and this page will be the only documentation for it. Who knows.

Trending Topics Aren’t the Problem

July 29th, 2009

Shel Israel says Twitter’s trending topics aren’t useful. For the most part, I agree. I’ve been watching people game trending topics for months; sometimes to the extent that I expect “trending topic” or “trend” to become a trending topic instead of the target phrase.

But I disagree with Shel’s views that trending topics are the reason why Twitter is of decreasing utility:

But Trending Topics, has become all-too-often a list cluttered and dominated by banalities, contests and silliness that is of no interest or use to a great many people, particularly those of us who use Twitter for business, or to learn about events in the world; nor is not useful for actually meeting new people with whom you share common interests.

I think it’s a little early to declare Twitter useless for networking and business, but it’s getting there. Trending topics aren’t the problem though. Sure, trending topics are less useful these days because you see more #ohnoyoudiint than #iranelection but this is a symptom, not a cause.

The reason Twitter is of diminishing utility and will eventually be worthless is because the general populace is becoming interested. When Twitter was small, its users mainly consisted of social media and programming nerds who recognized its potential as a networking tool. This group of people was most interested in discussion about their niche interests, and Twitter helped bring them together. (I might add that IRC did this long ago, but I will concede that IRC is much less discoverable since you have to find a server and a channel, and there’s fragmentation.) The dream of this group of people was to bring Twitter to the masses, so that everyone could benefit from the wisdom of authorities in their fields.

This is where reality hits hard. There are many individuals that are passionate enough about topics to make it both their career and their hobby. However, “many” in this case is a minority compared to the general population. Most people aren’t passionate about their job, and don’t really care to be. These people want to come home and escape; they want to talk about celebrities, TV shows, and anything else that’s only useful for entertainment value. This is your majority, and when they come to Twitter they’re not interested in talking about Twitter killing newspapers or which framework you can use to write Sprawling Business App 2.0; they want to talk about the guy on Comedy Central or American Idol.

I don’t think Shel is ignorant of this pattern, in fact he states that it happens without making the point I’m making:

This may seem like a trivial topic, but it is not. There was a time when thinkers had great vision for television. NBC pioneer David Sarnoff envisioned bringing opera and symphony into America’s living rooms. News pioneer Edward R. Murrow thought that the distribution of news on television would level abuses by tyrants and corrupt public officials. Educators dreamed of using television to educate the masses.

And we ended up with American Idol.

But yet, it still seems like he’s missing something:

Twitter is the fastest growing computer-based technology in history. There is no end to that growth trend in site. It has the potential of letting each of us find others who share our interests and passions without intermediation by bosses, government, advertisers or anyone.

Is this not what the pioneers of television probably said to themselves? “This technology has limitless potential for enriching the lives of all humanity. People will use this to improve their lives.” Joe Public didn’t care about opera and symphony: centuries of conditioning programmed him to believe these are frilly things to be enjoyed by the rich (good job, aristocracy!) People who had invested their wealth in television were forced to provide programming that people would watch, which led us astray from the initial vision. The same thing happened with Facebook. The early adopters were mostly college students interested in social media, since you had to be a student to sign up in the first place. The potential for communication was realized, and people decided that everyone should have access. Joe Public saw that he could use Facebook to tell his friends what bar he’s at, and never looked farther. It’s the same with Twitter: social media people see an invaluable tool for connecting yourself to people with great ideas, but the populace sees a tool for finding people that like the same kind of parties as you.

This pattern seems as if it will repeat forever. The solution is to keep these tools secret and closed only to those who value the personal connections, but this is analogous to the old aristocracy protecting the secrets of reading and writing from the masses. The populace ruins social media, but deserves the chance to use it for their personal enrichment. Trending topics are not the problem.  The problem is that most people don’t care about enriching their life, and this causes trending topics to be useless.

Ordering of numeric conditional tests

May 16th, 2009

I’m reading Code Complete and something caught my eye in chapter 19. At first I wanted to argue with it, but the more I thought about it the more I liked it.

The idea concerns the situation where you need to test if a variable satisfies an inequality, for example, if you need to know if min < n < max. I’ve always done it like this:

if (x > min) && (x < max)
// -or-
if (x < lower) || (x > higher)

I did it this way because I liked having the comparison variable on the left and the constant on the right. McConnell suggested that the organization should look more like the inequality:

if (min < x) && (x < max)
// -or-
if (x < lower) || (higher < x)

I initially rebelled against this part of the chapter simply because it was not what I liked, but the more I think about it the more I like it. Almost every time I have to code an inequality like this I make a mistake, and I always write extra tests for these cases. I think if I start writing the conditions this way, I can increase the probability that I’ll get it right the first time.

Using a TextBox as an Adorner

March 13th, 2009

I was fooling around with an adorner in a test project and decided to use a TextBox instead of a ComboBox for convenience.  Unfortunately, I found I couldn’t type into the TextBox.  According to Jim Nakashima, this can be addressed by setting the AdornerPanel.IsContentFocusable property, and he’s right.

I am bothered by the “bug” that sends “Delete” input to the designer instead of the TextBox.  I don’t call this a bug, I call it a showstopper.  Oh well, I guess I’ll be able to use TextBox controls in my adorners when we are able to drop VS 2008 support in 5 or 6 years.

Interesting solution to a WPF resource location issue

March 11th, 2009

Design-time is one of my hobbies, and I’ve been fooling around with the WPF designer ("Cider") lately.  I’ve been making adorners do interesting things for the most part and havent fooled around with property editors much, which makes me kind of useless for Blend.

A pattern I’ve been following involves structuring my projects with a folder for each control I’m providing support for.  Each folder has its own resource dictionary in a Resources.xaml file, and the Themes/Generic.xaml includes all of them as a merged resource dictionary.  It works great, but I recently had a problem, couldn’t find the solution, and now that I know what went wrong I want search engines to help others out.

My metadata was loaded correctly, but none of my templates were being applied to adorners.  I thought something was wrong with the merging of the resource dictionaries, so I tried moving a template into Generic.xaml; no dice.  Nothing I did seemed to be making the project pick up the template.  I set up some small proof-of-concept projects, and couldn’t find anything visibly different about what was wrong.  The end of the day arrived and I decided I’d just delete the project and try again tomorrow.

Tomorrow became today, and the project was magically working.  I called a coworker over to witness the event, and he began to point at my project.  "Why do you need that junk in Properties; it’s a class library and you won’t use application settings and resources?"  I agreed; yesterday I’d deleted them too.  In fact, early today I had deleted all of them but our source control decided they were important and resurrected them.  I’m glad it did.

It turns out that in AssemblyInfo.cs, which I clicked on for kicks, there is a ThemeInfoAttribute that tells the project where to find the non-themed and themed resources.  If it’s not there, whatever is supposed to look for Generic.xaml doesn’t look there.  Oops.  When I deleted AssemblyInfo.cs, I broke the theming!

So, if you’re depending on themed or non-themed resources in WPF, don’t delete AssemblyInfo.cs!  Or, if you do, make sure to apply an assembly-level ThemeInfoAttribute somewhere else.  Don’t waste half a day like I did!

Testing Source code posting

March 6th, 2009

Supposedly there’s a markup element for posting code on WordPress blogs.  This is just a test; I’m actually planning some big posts and it will determine if I use the blog or just link to a static page.

public void DoSomething()
{
     MethodCall();
}

Welp, either I did something wrong or WordPress lied to me. I’ll try upgrading this weekend.

*Update:* Turns out I needed to manually install this syntax highlighter.

MSDN’s Community Features Really Suck

February 16th, 2009

I really, really hate to complain about a very large piece of software because I understand the difficulties involved in developing such a thing.  I also don’t like offending people, as I know when people say “x sucks” and there is an author of x then that author can’t help but get their feelings hurt.  However, I feel like the community features are an afterthought at Microsoft’s MSDN site, and I’m really tired of trying to deal with it.  Maybe someone will read this and fix it, but I doubt it.

First, I don’t understand why MSDN is so slow.  I understand it’s a large site servicing thousands of connections per minute, but so is Amazon and somehow I don’t have 10-second delays when accessing that.  OK, fine, Amazon targets a different audience and perhaps their software can be optimized.  That doesn’t explain why if I simultaneously try to visit a blog hosted on Blogger and MSDN, the MSDN blog is still loading 10 seconds after the Blogger page is done loading.  This is true for all parts of the MSDN site: blogs, forums, newsgroups, technical documentation.  What’s the deal?

Next, some community features.  The forum software is pretty neat, but new categories are added at a glacial pace and they’re really dated.  The VS 2008 forums were clearly marked for “discussion of the Visual Studio Codename Orcas Beta” at least until VS 2008 SP1 was released.  I’m just glad there’s a couple of them devoted to WPF.  However, so far I’ve got about 4 active questions with 0 replies; at least in the WPF design time forum (which they still call by its codename for some reason) it looks like the only way you have a chance of getting a reply is to ask a simple question like, “I haven’t opened Visual Studio yet and I need to.  How do I do this?”  So far the most use I’ve gotten out of these forums is a good place to arrange my thoughts while I arrive at the solution myself.

The managed newsgroups are worse.  As part of the MSDN subscription my company purchased, we’ve got guaranteed response times to questions on the MSDN managed newsgroups.  Except it doesn’t look like they’ve updated their newsgroups in a while; there’s no newsgroups for WPF and not even a really good-looking place to pretend is associated with it.  That doesn’t matter though, because it’s impossible for me to configure my MSDN managed newsgroups account.

If you want to get the guaranteed response you paid for, there’s a process you go through to associate an alias with your MSDN account.  I presume this is so some automated tool they have can ping an appropriate person to find someone that can respond to the question.  Since June 2007, when I tried to access this page, I’d get an error message after a 2-3 minute delay; the message basically said “something unexpected happen; try again in 10 minutes”.  A couple of weeks ago, I got tired of it and used the concierge chat to see if maybe I was doing something wrong; it turns out the “Configure” link was broken for everybody and it had to be fixed.  Go figure; a crucial link on a feature they charge money for was completely broken and it went nearly 2 years unnoticed.  It got fixed in a couple of days, I configured a posting alias, then realized that I had found the answer to the question I wanted to ask through trial and error anyway.  Today, I needed to ask a question, so I double-checked that my alias was configured.  “No alias configured.’”  Huh.  Weird.  So I tried to configure it again.  “We’re sorry, this alias is already in use.”  Huh.  Real weird.  So I tried another alias: the old one with a 1 on the end.  5 minutes of waiting later, “There was a problem connecting to the registration service.  Try again in 10 minutes.”  Hey, this sounds familiar!  10 minutes later, I try again with the new 1-suffixed ID.  “We’re sorry, this alias is already in use.”  CURSES! So it seems that if I try to register an alias, it fails for an unspecified reason.  However, it does get so far as to registering the alias because after I get that unspecified error the next error tells me that my posting alias is already in use.  Shouldn’t this be a transaction that’s rolled back on failure?

I tried the concierge chat again, and the person confirmed this is a “known issue with volume license subscribers” and is “intermittent”.  Funny, I’ve been barred from this feature for more than a year and it’s described as an “intermittent” issue.  I wonder if there’s a word for the practice of selling a service but making it so difficult to obtain the service that it’s not used?  Surely someone’s been in trouble for it.

I’m genuinely frustrated here.  The best resource for information about programming is other programmers, and MS has the framework in place to create a really great community of developers.  However, they’ve chosen to needlessly obfuscate the communication process to the extent that I’m getting better answers from programming accidents than the MS “community”.

Also protip if any MS employees decide to reply (occasionally it happens!): if you want me to contact you by email it is dreadfully important that you leave an email.  Someone responded to some WPF comments I had one time and expressed an interest in an email discussion, but didn’t leave an email.  No email on his blog either.  If you don’t leave contact information I can’t contact you.