Monday, March 31, 2008

Not an MVP anymore, but going to the summit and to TechEd Israel


Well, unless I get an email in the next couple of days, I am no longer an MVP. Exactly one year ago Microsoft granted me the MVP award for my contribution to the sharepoint community. I am hoping that this will be the same this year as well - but so far I hadn't heard from them. Then again - it is too early in the United states, and it could be that they are taking my advice from last year that sending the "you are an MVP" email on April's fools day is not a good idea...

I think I contributed quite a bit this year. True, I didn't blog as much, and I didn't start any new open source projects - but I am still leading the Canberra SharePoint User Group (and spent some time on developing the site and the user base. The last meeting we had 32 people come in - and that is in Canberra!). I have also answered quite a bit of questions on the SharePoint developers' forums in MSDN. Look at today's log of top answerers from the last 30 days:



If the award gets renewed, I'd be sure to let you know. but for now, I will remove the MVP logo from this site and from my email signature. If not, then I will try harder next year!



So next week I will be in Israel for the Israeli TechEd. I will be presenting a most difficult presentation on how to create a community site solution, integrating office 2007 open XML and sharepoint, with web services, VSTO and even windows presentation foundation thrown in for good measure.

The week after that I will be in Seattle for the MVP Summit where I will meet the SharePoint team, listen to lectures and mingle with other MVPs. If you are an MVP - look me up - I am the guy with the horribly big hair style and the stubbly facial hair:






Product Review of the week - Tzunami Deployer

As promised - another product review. This week - Tzunami Deployer.



This application is used to copy data into SharePoint. The source of the data doesn't have to be sharepoint, but it has modules that support all versions of SharePoint as sources - so if you want to migrate data from your old sharepoint 2001 or 2003, this is the tool you are looking for. Other modules they have for sale are "file system" (I can hear some ears perking up...), "lotus notes" (a lot more ears?) "exchange", "livelink" and "eRoom"...interesting?



The Tzunami product allows you to model the data migration path manually - by loading the source and the target in two panes, and then dragging and dropping items (either documents, list items, document libraries and lists or event whole sites with sub sites) and then allows you to manually map metadata fields.



The application main screen. Source is on top.





Mapping metadata fields from source to target.


There are important options like adding missing metadata fields to the target if they don't exist (or skip them) as well as security mapping (very important when moving between domains for example).

However, the big advantage of this tool compared to others I have tried is the "rule wizard". This feature allows you to predefine some rules on what will happen when you drag and drop. For example, you can specify that certain lists type will not be migrated, or that document libraries with specific names (or other properties) will be migrated using a specific predefined metadata mapping - and more and more. This richness of the rules wizard clearly makes Tzunami Deployer a very good tool - as it saves a lot of manual time.



Finally, after you have modeled your deployment, you can "commit" the changes - at which point the application actually creates the sites\lists\libraries and copies the list items\documents. The application supports migrating versions as well as security settings, and retains the built-in fields like created, modified, created by and modified by.


Did I mention that the modeling application does not need to run on a sharepoint server? You just need to install the "remote deployer" on the servers you are deploying to\from, and you can run the application from any desktop. However, since it is the application that commits - it is recommended to run the commit on the receiving server - to reduce network load if nothing else.




That said, the developers in Tzunami still need to work on a few things. The user interface is at times frustrating - dialog boxes that cannot be resized (and you are stuck with annoyingly small treeviews with scroll bars) and dialogs that pop up without an option to set a default answer - something like "remember my answer, and apply to all" - specifically on metadata mapping. The metadata mapping dialog box will popup for each list and document library that you have dragged and dropped. This makes dragging and dropping a hierarchy of sites with a lot of lists and libraries a very annoying process - and can cause the application to crash if we are talking about thousands of lists (have you have tried to click "next" three thousand times?). The boys there assure me they are working on it.



But the biggest problem that I see with the software is that it is impossible to model a migration path and then run it on different servers. Basically the application stores the setting of the source and the target in its "project", and will not let you say "do that again, but this time on that server". This makes going through a series of tests (as in, development-test-production) impossible - since you will still have to do the dragging and dropping all over again. But if you are careful - and you make sure you dragged and dropped correctly, and you make maximum usage of the rule wizard (which is defined by XML files - which you can even generate yourself by code, a thing I find very useful), you can work around this limitation.



Bottom Line



The flexibility of the rule wizard, coupled with the awesome support level I have been getting from the Tzunami support team (which is fantastic considering that I am in Australia and it is very hard to support us since we are usualy at a huge time difference with anyone else in the world) would have given this product a much higher score, if the annoying UI and some stability issues were gone. However, if you know what to beware of, and have enough patience for trial and error on the rules and how they work - you will find Tzunami to be your best friend. I give Tzunami 3.5 SharePoint Tips stars.







Back from Leave

If you had been wondering about my absense, I was in Tasmania for the last week. Want to see some pictures? click here

Monday, March 17, 2008

When to use "using" (To dispose or not to dispose - that is the question)

Hey! SharePoint developers! a must read, must print article for us. make sure you read, understand and comply or you will leak!
Seriously - this is one of the most important articles you can read if you are developing for SharePoint.
Roger Lamb's SharePoint Developer Blog - SharePoint 2007 and WSS 3.0 Dispose Patterns by Example

SharePoint Product recommendation of the week - WSS 3.0 Connected Fields.


The first post in a series of (hopefully) many to come, I want to tell you about a product that really impressed me. I am going to give "stars" to show how impressed I was.

For now, these stars are lousy images that I created my self using visio and paint.net, but if there is a volunteer amongst my readers who can whip up a nice "sharepoint tips star" design, please contact me through this "email ishai" link (you understand why I will not expose my email address?). Please upload the image to a web site (picasa, flicker and so on) so I can see it. I will publicly thank anyone who will submit an entry into this "make Ishai a star" contest.


The product of this week is "WSS 3.0 Connected Fields" by a company called InfoWise. For proper disclosure I have to say that the owner and the lead developer there are both friends of mine - but that doesn't change the fact that this product is awesomely cool - 4.5 stars.




Also known as "Master-Detail" or "Cascading Dropdowns", WSS 3.0 Connected Fields adds another field type to the types of fields you can add to lists in SharePoint. this field type operates like the built-in lookup field, but also allows you to specify a "parent" lookup.

This way you can create a master-detail connection between two fields. For example, choose a "category" and have the "product" list filter to products in that category! how great!

What is even more impressive is that they support infinite connections. so "Continent" will filter "Country" which will filter "State" which will filter "City" and so on and on.



But every friendship has its limits - and so does this solution. The only thing that bugs me about this is that the field type cannot be used in site columns and therefor in content types.
As a developer I understand the difficulty - but still I reckon that this solution can only get 4.5 stars and not 5 just because of that.


Here are some images from the infowise web site (ignore the hebrew bit in the second one - it is the "none" value for the lookup - a Microsoft localization stuff-up?):










Monday, March 10, 2008

Aha! User profile choice list commit - I told you so

This just in: KB948724 - "Changes are not committed when the Commit() method is called in SharePoint Server 2007 or in SharePoint Portal Server 2003" that was published yesterday (thank you KBAlertz for letting me know) affirms what I have written about a year and a half ago.
The Microsoft article describes a workaround (that me and the guys have already found, but I never got a chance to blog about.

Short story - if you try to do this:
property.ChoiceList.Add("test");
property.Commit();
It won't work.
Workaround - "To work around this problem, modify another property that is not a ChoiceList property. Then, call the Commit() method. The changes to the ChoiceList property will be committed."

Thursday, March 06, 2008

Code review thoughts

Yesterday we had a very good session of code review on a project we are working on (developing a solution that updates Active Directory when the user updates his user profile) so I figured it wouldn't hurt to share how we did it.
Code review, if done right, is a great process to raise the quality of the code and therefore the end result of what you are developing.
So, how did we do the code review? We sat in a room, all developers, and opened VS on the projector. After a short explanation of what the code is trying to achieve, we just walked through the code. We let the most junior developer read the code to us and explain what it does (don't just read out the lines - make sure he translates the code into pseudo code - for example: "we loop over the user profile's properties and put them in a string array"). During this, everyone of us was in charge of looking for way to improve the code:

  1. Naming conventions
  2. Coding standards
  3. Optimising performance
  4. Error handling
This way you have several people thinking and double checking, and you end up with 6 developers knowing the insides of the code instead of 2 (for example).
Some rules:
  1. Keep the atmosphere light and not overly criticising - we are here to get better.
  2. Make people who didn't write the code read out and explain the code.
  3. Involve everyone in decisions on how to optimize the code.
  4. Go through the code in a logical order - start from the things that the user sees, and walk through the code to the backend code.
These are my thoughts. How do you do code review?

Tools of the trade


Some people ask me what I am developing on, so I guess I will post my hardware\software list every now and then.


Hardware



I am currently using a Dell XPS M1330 with T7700 (they now have a penryn processor option...I missed out!) with 4GB RAM and a 160GB 7200RPM hard drive.





I use a Western Digital Passport external drive for my virtual machines (see software).



Software




  1. Vista 64bit SP1 enterprise edition

  2. Office 2007 ultimate

  3. VPC 2007 (for the virtual machines I use at work)

  4. VMWare workstation 6 (for personal development and presentations I find it faster, and it supports 64Bit guests! excellent!)

  5. Free Download Manager

  6. Roboform (to manage all my passwords)

  7. 7-Zip for all my archiving needs (although every now and then I need winrar

  8. Total Commander which is the most comfortable file manager I have used since Norton Commander

  9. Snag It and Camtasia for easily capturing my screen for presentations or web casts

  10. Skype to make overseas phonecalls (I use skypeout)

  11. Acronis true image for backup

  12. Winamp for my MP3 (I used to use musikcube, but it crashed too often for me to enjoy it)

  13. Google toolbar (and google.com.au as my home page)





In the future I will write about what I have in my virtual machines -which is more interesting - what I feel is a must on a development sharepoint machine.






Wednesday, March 05, 2008

Thoughts and best practices around the "Smart Part"

In the last few years i have been meeting with a lot of developers who had just been introduced to sharepoint web part development, and immediately switched to developing using SmartPart. I think it is time for me to write something about it here in the blog to help people decide when and how they should be using that solution.
I want to make one thing clear. I know that Jan Tielens put a huge effort into the smart part solution, and I think the results is fantastic. It is a great example of how one can embed an ascx control in a web part and display it in sharepoint. The addition of ajax connections between two smart parts is awesome, and I applaud it.
But while I appreciate it, and will recommend it as an example of how such things can be done, I don't think starting developers should forgo learning how web parts work and settle down to use smart part out of the box as their development platform.
I will explain.
Another small note - I gave Jan the option to comment on this article, and I am including his remarks, in green.

What is "SmartPart"?


To quote from the official (and quite out of date - Jan: I forgot about the smartpart.info site, thanks for reminding me, I’ll update it immediately.) smart part web site:
"The SmartPart is a SharePoint Webpart that can host any ASP.NET user control. Create your webparts by using the VS.NET designer instead of coding everything by hand!"
Yes- you read it right - it allows you, the frustrated sharepoint developer to create web parts by just dragging and dropping controls on a canvas, just like ASP.NET developers do it! how great is that (note - I am not being sarcastic - it is great).
Why am I saying the site is outdated? because it shows a huge link to gotdotnet, which doesnt exist anymore. The real link should be to the smartpart codeplex project, which does exist and works.
The codeplex project's home page explains that smartpart is "The SharePoint web part which can host any ASP.NET web user control. Create your web parts without writing code!" (Well, one would argue that if you want web parts without code, use SharePoint Designer - but that is opening a completely different discussion)

Smartpart is basically a simple but genius idea - it is a web part, that can host ascx controls inside it. That way, all you have to do as a sharepoint developer is to write the ascx control, and you can do it with the Visual Studio canvas - just drag and drop, and then when you want the web part on a sharepoint page, you load the generic smartpart, and tell it to load the ascx that you want. it supports ajax, and ajax web part connections - which is cool. overall - a cool solution. I totaly respect Jan Tielens, I love his blog, and his U2U CAML Query Builder is the first tool I install on every sharepoint development server I work on (or is it Patrick's?).Jan: U2U CAML Query Builder is created by Karine

Pro

The Pro is obvious -

  1. you gain so much in development time - you just drag and drop on a canvas
  2. you can easily use all the complex web controls and not worry about web part life cycle and binding times and events.
  3. Fantastic if you are a asp.net developer who needs to learn sharepoint development but doesnt really want to.

Con

  1. The biggest con I can see is that people who use smartpart from the start do not learn about web parts and how web parts work.The solutions they create will be run in a wrapper solution and not natively on sharepoint itself. This leads to people developing user controls that require full trust from the web.config and they totaly disregard sharepoint security, resulting in solutions that require you to change the security settings in sharepoint to full trust. (Jan: If people have questions about CAS I usually point them to an old blog post (http://weblogs.asp.net/jan/archive/2005/06/23/414699.aspx), which still works for SharePoint 2007. Bottom line, deploying the SmartPart doesn’t require Full Trust on the server. WSS_Minimal should be fine! Of course it is possible that the user controls you are building will require a higher trust level.)
  2. Another issue is with the fact that at the end of the day, the smartpart is a generic wrapper around a ascx that lies somewhere on the server. Since it is generic, and since deployment of ascx controls do not require administrative priviliges on the server, it can be used to override sharepoint security. In other words - sharepoint trusts smartpart (because it was installed by an administrator) and smartpart gives that trust to any ascx that is on the server. Combine this with the fact that learning developers do not hesitate to give full trust on the web.config without realizing what it does, and you end up with a potential security risk. Not smartpart fault - it is the fault of the developer, but my fear is that the ease of use of smart part will lead to a lot of unsecure solution like this.
    A friend of mine has shown how a person with permissions to create\edit files on the sharepoint machine can use smart part to run unsecure sharepoint code. This can be corrected in the smartpart, if administrators will be able to specify in a configuration file what locations should be considered trusted by smartpart - but that would basically be repeating what .NET framework already does out of the box.
  3. Performance hit.
    SmartPart is a wrapper. It loads another control - meaning it is another layer of code between the user and the end result. Additionaly, To expose the properties of the control it is hosting to the user it is using reflection - performance hit.
  4. Deployment - hard to deploy, hard to debug. I can't tell you how many people who tried to use the smartpart asked me for help on deployment and debugging. Remember, the debugging of problems in your web part now needs to also debug the smartpart code, because the problem may be in the smartpart and not your code.
    Jan: I have to agree with you: debugging a user control (ASCX) with a code behind file (CS) is not as easy as debugging web parts. What I recommend people is to make use of the Web Application project template (available in VS2005 SP1 and VS2008). This will give you a DLL containing the code behind instead of a CS. You can debug that DLL just like you would debug a web part DLL. If you really want to do this in VS2005 (without SP1 or without a Web Application project) you can use precompilation.
  5. Does not support cross page connections, and marginally supports other forms of webpart connections. If you want to support all kind of webpart connections you still need to write your own web part.
    Jan: I’m not sure about the cross page connections (never tried it), but cross page connections won’t work with ASP.NET 2.0 web parts either I think (please correct me if I’m wrong). Of course flexibility comes with a price; there is only one interface implemented which will allow you to send objects between web parts. The result is that the SharePoint UI won’t prevent you from making connections between web parts that can’t work. It will be the responsibility of your code to check if the data that is received is of the correct type etc.

For more info I suggest you read Eli Robillard's blog about What to know about SmartPart, and LoadControl().

So what instead

Ok, so Ishai is a "bloody annoying purist who wants everyone to develop bloody hard web controls and do it all by code". That wont win me any popularity contests!
Well, my first to the question what is my genius recommendation is, "yes! develop a web control like I do". Who needs canvas? by writing the code behind we have total control of what is happening in the webpart, and we dont rely on the canvas to do what we want.

But I understand that this approach doesnt appeal to a lot of developers - and to them I suggest, just develop your own smartpart (you can start from the smartpart code! that is why its there for on codeplex, or read Eli's blog post about the Eli Robillard's blog about LoadControl), but dont make it generic - write it so that it is strongly bound to the ASCX control, and users cant use it to load other controls, or make it so that only a specific folder on the sharepoint machine is trusted by the generic webpart, and make sure that folder gives "write" permissions only for the right people. Performance will still take a hit and deployment and debugging will still be hard but at least you will be (a very small bit) more secure, and in control of what is happening.

PS: I have a friend who claims that Microsoft has a tool that generates web controls out of ASCX controls - he claims that MS used it to create most of the webcontrols that come builtin in sharepoint. I don't know if it's true or not, but if it is I hope that MS will consider publishing that tool - that would be a big step forward towards the developer experience that so many developers want.

Before I end this article, I want to add that I may update this article with more info, since I am sure I will be getting a lot of comments (online or offline) on this article. I hope everyone understands that this is not a flame against Jan and his solution - quite the opposite. I think the smartpart is a magnificent piece of code, that is very useful as an example, but I don't think it should be used without learning how it works and what it means when you use it.
What do you think? comment on this article!
If you want me to respond to you only, you will have to leave contact details, so you'd better do it through the "Email Ishai" link. I hate it when people comment on my article and say "I had a problem doing it - what am I doing wrong" and don't leave personal details how to help them.

Sunday, March 02, 2008

MSDN forums for sharepoint developers

Microsoft have been putting alot of effort to clean up the forums, going through threads and marking them as helpful if they are, deleting threads that are dead (6 months old and no response) and even collecting problems that people have noted there (like a thread where a lot of people say "I have the same problem") so that MSDN can maybe publish articles about those FAQs.
I think this is great, and improves a very important tool that we have to get sharepoint development help. Check out the forum!