Best of SharePoint 2007



  • My team is developing one of the most elaborate SharePoint/MOSS customizations to date. We've had continuous consultations from the top tiers at Microsoft. Here's a few takeaways:

    • We've located more than a dozen instances of code like this in the SharePoint API:


      bool condition = true;
      while(condition)
      {
          //snip
          condition = false;
      }

    • There is a property on the SPListItemEvent called CanMaybeEdit.

      It's a bool.

    • Microsoft sells WSS as a "development platform", but almost every control and class is sealed and most properties and methods internal.

    Fantastic.



  • I can't feel my legs!



  • I have legs?

     

     

    Helpdesk girl forever, she even has tattoos! 



  •  @Eddie Izzard said:

    OH SUE

    I've got legs!

    Do ya like... bread?

    I've got a French loaf!

     



  • @rexmorgan said:

    • bool condition = true;
      while(condition)
      {
          //snip
          condition = false;
      }

     

     This type of thing is used fairly often when people need to do the equivalent of:

    foo();

    if(failed())

        goto bar;

    foo2();

    bar:

    cleanup(); 

     

    but they've heard that goto is evil so they use a while loop and a break to "hide" the goto.

    To be fair, most people would do:

    do

    {

    } while(false);

    if they wanted to do what I've described. 



  • @Heron said:

    @rexmorgan said:

    • bool condition = true;
      while(condition)
      {
          //snip
          condition = false;
      }

     

     This type of thing is used fairly often when people need to do the equivalent of:

    foo();

    if(failed())

        goto bar;

    foo2();

    bar:

    cleanup(); 

     

    but they've heard that goto is evil so they use a while loop and a break to "hide" the goto.

    To be fair, most people would do:

    do

    {

    } while(false);

    if they wanted to do what I've described. 

     

    Unless you had a seperate thread you wanted to run until the parent thread shut it down... 

    At that point this may not seem so bad:

    Running = true;

    do

    {

        Read();

        Write();

        Sleep();

    }while(Running);

     

    If Running is made public, you have an easy way to tell the thread to shutdown. I am not saying this is the only/best way but it is simple and effective.

    Not sure what SharePoint is doing this for, but I would not be a good judge of their software considering I know nothing of their codebase.



  • @rexmorgan said:

    We've located more than a dozen instances of code like this in the SharePoint API:


    bool condition = true;
    while(condition)
    {
        //snip
        condition = false;
    }

    So it always sets condition = false at the end of the first pass, and then exits the loop? Awesome.

    Sharepoint's multitude of completely useless error messages ("Unknown error") are the reason I regularly refer to it as Swearpoint.



  • @db2 said:

    Sharepoint's multitude of completely useless error messages ("Unknown error") are the reason I regularly refer to it as Swearpoint.

    Best advice I can give is set CallStack=True and CustomErrors=Off in the portal's web.config, that should give you the real error.



  • Emphasis on the should. A good third of the time, we just get "Index fell outside the expected range" with a call stack that is nothing but SharePoint internal calls all the way up. Troubleshooting means "something I did between the last time I tried this page and now is what broke it".



  • @rexmorgan said:

    Emphasis on the should. A good third of the time, we just get "Index fell outside the expected range" with a call stack that is nothing but SharePoint internal calls all the way up. Troubleshooting means "something I did between the last time I tried this page and now is what broke it".

     

    Welcome to programming.



  • Just went on a two-day MOSS course. Following the course guide led to constant crashes and errors in the VM.

     Then I get hauled up by my bosses suggesting I might not have "got as much out of it as I could have"..... I think I did: "Avoid MOSS where possible"



  • @rexmorgan said:

    My team is developing one of the most elaborate SharePoint/MOSS customizations to date..

    Correct me if I'm wrong, but is it not so that Sharepoint is founded on the idea that information/docs/whatever can be classified hierarchically?

    If so, that's TRWTF.

    30 years of relational databases and M$ still believes that hierarchical structures work. Sigh.

    I've been working in projects under a corporate demand that we must use Livelink (the foul undead ancestor of Sharepoint, is it not?). You can guarantee (a) any doc stored will not be visible to those who need it (b) most creators of docs will stop storing stuff cos no-one is getting their jobs done.



  • @thenextman said:

    Best advice I can give is set CallStack=True and CustomErrors=Off in the portal's web.config, that should give you the real error.
     

    Best advice I can give is burn the lot now before the real problems start.



  •  Stop rethrowing exceptions and crushing the call stack.

     If you have code like

    catch (Exception ex)

    {

    doSomething();

    throw ex; 

    change it to:

    catch (Exception ex)

    {

    doSomething();

    throw; 

    }

     

    And you'll get a real stack trace. 



  • @GreyWolf said:

    30 years of relational databases and M$ still believes that hierarchical structures work. Sigh.

    Hierarchical databases are actually better than relational for stuff like LDAP, where the protocol itself specifies a hierarchical structure.

    Also, a lot of the WTFery with SharePoint is that people tend to fall prey to "just because it's there it means I have to use it", feature creep, the fact that sub-sites can be difficult to manage, lack of corporate sponsorship/ownership of information, easily exceeding the storage limits of a List (although I believe that 2007 is a vast improvement here), and what I call the "SharePoint Wall" (i.e. it's great within it's limits, but once you try to push beyond them you hit the wall very quick), and all of these can come back to bite you in the ass.



  • @mfah said:

    @GreyWolf said:

    30 years of relational databases and M$ still believes that hierarchical structures work. Sigh.

    Hierarchical databases are actually better than relational for stuff like LDAP, where the protocol itself specifies a hierarchical structure.

     

    Seconded.  LDAP and filesystems are both hierarchical databases.  Most web sites are organized hierarchically, as are the structures of the organization itself.  People tend to think hierarchically, and a lot of business processes are organized that way, as is the software that supports those processes.  It so happens that relational databases have some features which make them better for dealing with large volumes of aggregate data, but that doesn't mean they're perfect for anything.  In fact, one of the most irrititating problems to solve in a relational database is an efficient representation of an arbitrarily deep hierarchy.



  • OK I take the point made by mfah and morbiuswilters that there are things for which a hierarchical database is right. Let me describe where I'm coming from.

    I'm a designer in IT for a big corporate. I have received a requirements doc from Division A's Product Management for a future system which will allow them to sell and install Division B's product. The intention is to build a forerunner of a corporate solution which will allow most divisions to sell each other's products. When I file this in Livelink or Sharepoint, do I put it in the hierarchy for IT, Div A, Div B, or Corporate? Bear in mind (a) I want all stakeholders to be able to find it without being given a specific link (b) there's multiple reasons why the Divs and Corporate mustn't be allowed to read each other's docs (business confidentiality, regulatory compliance, etc) (c) Livelink Search has performance like a hibernating tortoise.

    One week later, Product Management release an update because they've changed their minds about every detail. However, they have been ordered to use that document repository thingy. Because they are convinced they understand the business far better than IT dept do, they've put it in some randomly chosen location of the hierarchy which none of the rest of us can see or find with search. We tell them to email it out.

    The project is now rolling, so we're producing project plans, meeting minutes, proposals, solution designs, and collecting links to existing relevant docs from all over. The plans go in the Plans branch of IT, the Minutes go in the Minutes branch  of Div A because the oversight person comes from there, the Product is described in Div B's Product branch etc. All of these branches have legs for Draft/Proposed/Approved/Implemented. Each player has their own rules for where the Right Place is. When you try to navigate up and down the hierarchy, the response times are crap, so it becomes impossible to use the hierarchical document repository find all the docs in their latest versions reliably. Result: all the stakeholders demand that everything is emailed out, they keep their own copies of everything, massive duplication and bloat (espec those who keep the docs as attachments in Outlook), no-one can rely on having the latest.

    We bring the coding team on board. They say "WTF are the documents?" [w=where]. We all stare glumly at each other.

    I would want the repository to be a huge bucket with a relational index, so I can say

    SELECT * FROM REPOSITORY WHERE PROJECT_ID="GREYWOLF203" AND VERSION>="0.1"

    ORDER BY VERSION

    and get back a complete list of links.

    I believe that for the typical messy reality, a hierarchical info repository is fundamentally unusable.

     



  • Virtual links would make it easier. Instead of locking the physical entry to a specific hierarchy, it should allow for one instance to be linked to multiple locations. That would allow for a single copy to be maintained, yet also provide visibility where needed.



  • @GreyWolf said:

    ...a whole bunch of text...
     

     I'm not saying Sharepoint isn't a pain in the ass.  I've never used it so I wouldn't know, but it sounds like you are running up against some design limitations.  I was mostly responding to your "30 years of relational" comment.  Sometimes you need a hierarchy like LDAP and sometimes relational works best.  Links are a sort of hack in LDAP to allow for the same data to appear at multiple points in the hierarchy.   Still, some things are very hard to map into a relational model.  It reminds me of the relational database guys camp criticizing Google for using Map-Reduce a few months ago.  Relational databases are pure awesome, I love them, but they aren't the solution to every data organization problem.



  • @GreyWolf said:

    We bring the coding team on board. They say "WTF are the documents?" [w=where]. We all stare glumly at each other.

    I would want the repository to be a huge bucket with a relational index, so I can say

    SELECT * FROM REPOSITORY WHERE PROJECT_ID="GREYWOLF203" AND VERSION>="0.1"

    ORDER BY VERSION

    and get back a complete list of links.

    I believe that for the typical messy reality, a hierarchical info repository is fundamentally unusable.

     

    The WTF here is the way your people are trying to use SharePoint. It appears as though they have transposed what was a rigid folder structure on a file server to a SharePoint Document Library model, and while SP certainly can do that, it doesn't really work too great. It's best when viewed as an amorphous lump that you just stuff data into. Pull the hierarchy back to site level, so that rather than having "PROJECT_ID" as a document attribute you actually have a site (or at worst a separate Document Library) for each project. Make use of the self-service features so that PMs can create their own sites or Doc Libs on the fly. Then sit back and watch the weeping and grinding of teeth when someone asks for an overall report on something.

Log in to reply