<CharlieDigital/> Programming, Politics, and uhh…pineapples


SharePoint “Feature”: Pain In The Ass…

Posted by Charles Chen

Just to share some findings on working with SharePoint features:

  • The Elements.xml file that you include with your feature deployment cannot contain XML comments; if it does, you will encounter an error when you try to activate your feature using STSADM.exe.  Why?  Who knows.

  • The <type/> element in the Elements.xml file, according to the schema documentation, can only occur once.  This seems to imply that you will need a different Elements.xml file to subscribe to each event type that you want to handle.

  • And of course, Microsoft does not include the list of valid values (and if they do, it's not easy to find in the documentation).  Instead, I pulled the values using Reflector from the SPEventReceiverType enumeration.

The following is the enumeration listing:

public enum SPEventReceiverType {
ContextEvent = 0x7ffe,
EmailReceived = 0x4e20,
FieldAdded = 0x2775,
FieldAdding = 0x65,
FieldDeleted = 0x2777,
FieldDeleting = 0x67,
FieldUpdated = 0x2776,
FieldUpdating = 0x66,
InvalidReceiver = -1,
ItemAdded = 0x2711,
ItemAdding = 1,
ItemAttachmentAdded = 0x2717,
ItemAttachmentAdding = 7,
ItemAttachmentDeleted = 0x2718,
ItemAttachmentDeleting = 8,
ItemCheckedIn = 0x2714,
ItemCheckedOut = 0x2715,
ItemCheckingIn = 4,
ItemCheckingOut = 5,
ItemDeleted = 0x2713,
ItemDeleting = 3,
ItemFileConverted = 0x271a,
ItemFileMoved = 0x2719,
ItemFileMoving = 9,
ItemUncheckedOut = 0x2716,
ItemUncheckingOut = 6,
ItemUpdated = 0x2712,
ItemUpdating = 2,
SiteDeleted = 0x27d9,
SiteDeleting = 0xc9,
WebDeleted = 0x27da,
WebDeleting = 0xca,
WebMoved = 0x27db,
WebMoving = 0xcb

Of course, these values are in hexadecimal and for some reason, the <type/> element insists on the integer values.  So just be sure to convert the value to integer (try using Google for that).

Filed under: Uncategorized No Comments

Google: Server Error

Posted by Charles Chen

Whoa.  This is a first:


Filed under: Miscellany No Comments

Am I Just Being Compulsive?

Posted by Charles Chen

I waked up this morning with some notices that new code has gone into our main repository.

So of course, I perform a checkout to get the new code and what do I get?  Argh!  The commiter added the _svn directories (possibly from a previous working copy) into the repository!  So of course, the checkout fails and I need to revert to a previous version.

Now I'm a little annoyed.

Then I go in and check the directories to confirm that indeed, the _svn directories were checked in like any other directory.  I also find that our naming rules, which I had thought we all agreed on, are not being followed.  In addition, we had discussed building all projects off of the main solution and building sub-solutions from that main solution trunk.

Nope.  We have a solution sitting in it's own directory.  To top it off, it's a solution file that doesn't follow naming conventions.

Then there are other various little things which just add to the morning frustration; the use of "Sharepoint" instead of "SharePoint", "Engr" instead of "Engineering", inconsistent naming of image files, the existence of an App_Data directory (why is there an App_Data directory in this solution???????), referencing obsolete libraries (I could swear we discussed this)...

These little things all matter in the end in creating a sense of professionalism and coherence in the final product when DLLs and classes are named according to guidelines, file naming is consistent, and spelling (misspelled words in code annoy me to no end) is correct.

Man, these things just grate me so much.  I dunno, am I just OCD about my code?  This kind of stuff just drives me batty.  It literally freezes my brain until the issue is resolved.  Nobody seems to care much about the artistry and craftsmanship that goes into their code...that is until we need to do a customer or partner facing code review, then the only code they want to put up for review is mine...


Filed under: Rants No Comments

Wait, what?

Posted by Charles Chen

So CNN has a video on the mythical Japanese Gyroball.

After watching this, I'm more curious about their dubious use of information from the Net.  From YouTube, specifically.  Uh, when did random people commenting on YouTube video logs count as newsworthy sources?  And when CNN pulls something like this, do they have to contact that commenter for permission to use the comment?

But in any case, speaking of the gyroball, for anyone interested, there is a great little (skit?) article over at ESPN by Patrick Hruby.

Filed under: Uncategorized No Comments

Automatic Properties in C# 3.0…Why?

Posted by Charles Chen

One of the new features in C# 3.0 makes absolutely no sense to me: automatic properties.

I have two issues with this approach. First, Wouldn't it make more sense to just have VS ask: "Do you want to generate a public property" when a user creates a field (like when VS detects the user adding an event handler)? From the description, it seems like the private field doesn't get generated until compile time, meaning the class writer is working against the public property as well. This seems odd since one of the main scenarios for using public properties and private fields is so that the class writer can manipulate the internal data representation without affecting the external interface. Scott himself mentions:

The benefit of this is that from a type-contract perspective, the class looks exactly like it did with our first (more verbose) implementation above. This means that -- unlike public fields -- I can in the future add validation logic within my property setter implementation without having to change any external component that references my class.

Which leads me to wonder why the developer would not just write the private field declaration and auto-generate the get/set methods instead, a much more logical approach to class design which leads to more legible code.

I can appreciate that it saves space in the code view by omitting otherwise "useless" lines, but don't code regions already accomplish the same thing?

Seems like a pretty useless feature to me that ultimately leads to more abstract code (less readable, in my opinion).

Aside from that, the code usage itself looks suprisingly similar to an abstract class.  From a design standpoint, if it's not clear what the validation logic or some other property masked logic is at the moment, if it's not clear how the internals of the class should function, wouldn't it make sense to program against an abstract class and put the actual logic into concrete classes at a later time when that logic is available?  It seems to me that what the automatic property is saying about the class is that: "I know what my external interface looks like, but I don't know what my internal representation and logic should be", which is one of the reasons we have abstract classes, right?  So that we can substitute the actual representation of the internal logic of the class at any time down the line while maintaining the external interface contract.  I dunno, just seems like a useless and otherwise bad feature to me.

One of the other main features, LINQ, already has me shuddering in anticipation of the nasty code that I'll inevitably have to face down the line.  Can you imagine the horror of code mixed with complex data queries in any application of significance?  For the same reasons that one would put a public property as a facade to a private field, it only makes sense to use a stored procedure, view, or table valued function as a facade to the underlying data (now I could see a case being made for it with a framework that allowed the queries to be loaded and cached dynamically at runtime from external files with a cache refresh callback on file change).

Filed under: .Net, Rants No Comments

Caloric Bombardment

Posted by Charles Chen


I think I need to drive into New Brunswick.  Right now.

Damn you, MSNBC!


NHibernate Or Bust!

Posted by Charles Chen

So my interest in NHibernate is picking back up again.  The 1.2 beta release that's circulating now (the candidate release has been out since February of this year) addresses various issues with NHibernate in my previous time with it.

Specifically, the biggest issue was native support for generic types.  In addition, it seems like there are various other goodies in the 1.2 release such as stored procedure support.

And to think, I just got the team to standardize on Microsoft Enterprise Library 3.0.  I'm wondering how to break this to the team.

I guess in a sense, they are not completely incompatible.  Roll your own queries and data access routines are still the way to go for more complex queries (does NHibernate handle FOR XML EXPLICIT?) and anywhere high performance is critical.

The beauty of this whole thing is that as NHibernate has gained traction since the first time I used it like 2 years ago, the tool support has evolved tremendously.  Combined with MyGeneration and user templates, I was up and running (although the generated output had some minor errors in the XML mapping file) in minutes.  Not only has the tool support improved, the documentation has improved as well.

There is still some conflict, internally, as I was just ragging on LINQ last week with another group of developers for the simple fact that it creates a tight coupling between code and the raw data.  Whereas with stored procedures, you can have dedicated DBAs write highly performant code and you can modify the underlying data retrieval and layout so long as you maintain the same resultset, with dynamic queries, you lose a lot of that flexibility.  In addition, you lose a bit of testability as well since many times, it's just really helpful to be able to test the SPROC independently of any code (or perhaps breakdown subqueries in the SPROC to test small subsets of data).

In actuality, I think that having the mappings as XML is probably better than using LINQ since the XML mapping files can be loaded at runtime, meaning that the deployed mappings can still be manually updated whereas LINQ would necessitate a recompile of the source (my understanding of it).

So if you haven't checked out NHibernate for a while, now's a good time to get a refresher and re-evaluate the library.  I think it will still stick around even after LINQ is released.

Filed under: .Net, Dev, DevTools No Comments

Most Convoluted Licensing Model. Ever.

Posted by Charles Chen

See if you can figure out how much your company's deployment of MOSS2007 will cost:

Mindblowingly convoluted.

Filed under: Rants, SharePoint No Comments

Combating Namespace Bloat With .Net XML Serialization

Posted by Charles Chen

Anyone who has used the .Net XmlSerializers have surely encountered the dreaded namespace bloat which makes the serialized objects grow to ridiculous sizes.

There's a nice little article over at TopXML on how to deal with this bloat.

If you're using WSCF, on the client stub, I've gotten into the habit of writing custom serialization overrides in partial classes which ensure that if the client needs to serialize objects into XML, I'm doing so in an efficient manner.  It'd be nice to see it added to the server side class constructors as well.  Add your vote for this feature over at the WSCF dicussion boards.

Filed under: .Net, DevTools No Comments


Posted by Charles Chen

So I filed my taxes pretty early this year (this is the first time I've ever owed taxes) using TurboTax.  At the end of the submission, I was given an option to pay with a credit card, direct debit, or check.  Since I don't want to carry around a several thousand dollar balance and since I didn't have the requisite funds in my checking account at the time, I had to settle for a check.

I took care of the state taxes first since it was a much smaller sum and I had enough in my checking account to cover it.  Intuitively, as you logged into the state tax payment site, it would pull up the information regarding the e-filed tax returns, show you how much you owed, and ask if you wanted to pay in full.

Fast forward 20 days.  After I transferred the funds from a savings account, I found out that to pay online (since TurboTax didn't show the payment options interface again), I needed an EFTPS account, which for some reason or another takes 15 days to process the account setup.  So after receiving the account information and activating my account over the phone, I proceeded to log onto the site and attempt to pay the balance owed on my 1040.

Unfortunately, this process came to a screeching halt once I reached the "Tax Type Selection" screen which presented the following 6 options:

  • Estimated 1040ES 
  • Balance due on Installment Agreement 
  • Pmt on an amended return 1040X 
  • Extension 
  • UnderReporter CP2000 
  • Audit Adjustment 

I knew for sure that the last two options were not applicable, but for the life of me, I couldn't figure out which of the other four I should be using.  The help on the page is completely useless, presenting the following information:

The payment due information, such as a Federal Tax Deposit for businesses or an Estimated Tax Payment for individuals. This is the type of tax you are paying. The options shown here are those available for the Tax Form you selected above.

And of course, selecting three of the other four options lead to the same exact form...To make it even more "user friendly", the forms were not populated with data that made sense.  Instead of pre-populating the amount with the amount I owed and the "Tax Period" date with "2006", the date entered is "2007".


Being completely baffled by this system, I proceeded to call the EFTPS customer service line.  Surprisingly, I got through on a Saturday in no more than 1 or two rings.  Unfortunately, the service rep. that I got was definitely clueless and instead, referred me to the IRS offices.  Since the IRS offices are closed on the weekends, I had to postpone the whole ordeal until this morning.  The funny thing is, after speaking with the IRS rep., she admitted that she had never actually seen the system and couldn't help me pick an option (but she was nice).  Instead, she referred me back to EFTPS customer service.


Fortunately, the woman I reached this time seemed to know my problem right off the bat (you know, as if she'd received like, a million calls about it already).  It turns out that the second option, "Balance due on Installment Agreement", is missing some text and should really read something like "Balance due on Installment Agreement or Current Tax Return".

What really baffles me is why my data wasn't just pulled up when I logged in.  It would only make sense that once I was authenticated through this whole ordeal of linking a funding account, obtaining a PIN, and activating my account over the phone, the software would be able to pull up my already submitted e-file with the amount owed with a text box asking me how much of the balance I wanted to pay and a button labled "Pay Now".

I've found that in software/UI development and working with other people, if you make a process (any process, software or human) intuitively easy, even people who would otherwise wince at the suggestion of doing something will accept it.  Imagine if everytime you shopped on Amazon and you wanted to add something to your cart, you had to click the item and it would take you to a screen where you had to enter the SKU from the previous page... 

One would think that the government would want to make it easy for citizens to pay their taxes.

Filed under: Rants 1 Comment