Archive

Archive for the ‘SharePoint’ Category

#SharePoint Daily WTF: Complexity

November 11, 2011 Leave a comment

So yesterday I came accross a particular piece of code that I couldn’t accept. Not only that, I can’t really see how da hell someone has the ‘awesome’ idea of putting it together.
What amazes me the most is that it was clearly done by someone who had no idea what he/she was doing.
some people say I criticize too much but for god sake, I do that to myself and it is to keep on improving.

anyway, Have a look at the code:

<code>

private SPListItem GetPageDataByBrand()

{

if (string.IsNullOrEmpty(Brand))

{

Brand = new PolicyDao().FindByPolicyNumber(PolicyNo).Quote.Brand.Name;
bool catchADE;

foreach (SPWebApplication wa in SPWebService.ContentService.WebApplications)
{

foreach (SPSite sc in wa.Sites)
{

catchADE = sc.CatchAccessDeniedException;
sc.CatchAccessDeniedException = false;
try
{

SPFeature sf = sc.Features[new Guid("32b12f24-a926-4b66-92d6-43eb3011febd")];

}
catch (IndexOutOfRangeException) { continue; }
//Ignore the web apps which we do not have access to.
catch (SqlException) { continue; }

try
{

foreach (SPWeb sw in sc.AllWebs)
{

using (sw)

{

PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(sw);
foreach (PublishingPage pp in pWeb.GetPublishingPages())
{

if (pp.Layout.Name.Contains(“QuickQuote”))
{

if (pp.ListItem["Brand"] as String == Brand)
{

return pp.ListItem;

}

}

}

}

}

}
catch (Exception e)
{

//TODO SP Logging

}
finally
{

sc.CatchAccessDeniedException = catchADE;
sc.Dispose();

}

}

}

}

}

}

</code>

As you can easily see it:
1) nests 4 loops which by itself is a big no! In this scenario it means that this code can potentially go through every single sharepoint page to find a particular one. My questions
- isn’t search meant to do that?
- what are you trying to acchieve? sadly enough I can’t ask the person who did it because this company is long gone from this environment.
- SharePoint environments can get quite big, that means this code could potentially iterate a million times.
2) What if a particular site isn’t a publishing web, is it going to work?
- why do you need a publishing web if you are just returning a list item anyway? Ok, I understood he/she wanted to see if layout was quickquote. So what?
3) Thanks for saying there must be logging….
4) What are you doing with that SPSiteCollection.Features????

5) Thanks for wrapping the SPSiteCollection with a ‘using’ statement

Sorry but I just can’t accept devs who do this kind of thing. Please, I reckon you should give up and become something else.

Two possible ways to solve that:
1) Replace that by search. Include your ‘Brand’ and ‘ContentType’ field as managed properties and that will do the trick just fine.
2) create a reference links list. That could allow some extra flexibility as you can add some other parameters to it and use it as a resources list. Given the nature of this solution I decided to go for that.

Categories: Daily WTF, SharePoint

SharePoint 2010

July 31, 2009 1 comment

I have finally managed to get hold of a VM with SharePoint 2010.

 

This VM was built by Chandima and will be used during the Test phase. I haven’t managed to play with it yet, but I’ll start documenting all my findings. Most of them won’t be published till the public beta release. Whenever possible I’ll post comments.

Categories: SharePoint

It’s knocking our door

July 15, 2009 Leave a comment

Yesterday we received the confirmation that we’ll be part of the SharePoint 2010 beta program. Obviously I was already expecting it to happen however I wasn’t really anxious to see what MS have pulled off for this new version.

The fact is that I am very anxious to see this damn new version since the Steve Smith’s course I attended last week.

I’ll end up signing a NDA soon which means that right now I can speculate and dream about what is going to happen but I won’t be able to speculate and/or share my hopes here once I get to see SP2010.

On top of this email we’ve found the sneak peeks Microsoft also released  yesterday.

It’s getting here, it’s is getting to us!

Categories: SharePoint

Let’s face it: SharePoint is a Business Enabler

July 13, 2009 Leave a comment

I’ve read a while ago a news article saying that Larry Ellison used to say that software will become a commodity in few years.

Well, the fact is that it happened few years ago and even when I read that I could see heaps of sense on what he was saying. Software has got to a point where each subject is perfectly dealt by a number of tools that can address any requirement set.

The problem I’ve got so far is that for each business/company/industry there are specifics that have to be dealt as a brand new problem. I built back in 2003 a CMS application called NetCommunity (sorry, link in Portuguese), a very powerful tool which I could define components that would feed information from anywhere and would also be displayed according to any requirement through a nice XSLT definition framework.

Problems on that: It wasn’t a unified way of getting things together from a market perspective. It wasn’t an easy way either. People had to tell us how it would work so we would pack it as a .Net component which would be smart enough to display the interface retrieved and the expected interface. In my sw developer dreams of that time that would solve the planet’s problem.

Well, the fact is that it didn’t and the wheel kept on spinning and the world has made popular few technologies. JSon is available and so is AJAX, which I believe was around that time but no one was really master on it. I’ve got to also mention SOA which in certain ways is still struggling to get people who are really interested on implementing it properly just because sometimes people can’t see advantages and/or reasons on implementing it properly(I’m not going to discuss about that, I do think SOA should be properly implemented).

Right now I’m facing the possibility of running a brand new version of SharePoint, on its version 2010. I’ve got the lucky to know Chandima, who is a well known SharePoint MVP who is tempting me to have a play with the Beta version.

I have to say that I’ve got a mix of feelings while talking about beta versions. On one hand I remember failed attempts to implement a robust software using beta versions while on the other hand I’ve got a huge hope that I’ll find on SP 2010 things that will be allowing changes within IT industry. Sounds pretty optimistic,right?

I’ll need a little while to establish all the reasons to be so hopeful, so I’ll start talking features found on MOSS 2007 and how I expect enhancements to allow Developers/IT Pros to really leverage business applications thorough features like BDC, InfoPath, Excel Services, OBA, and WebParts and CONNECTIVITY BETWEEN THEM.

Microsoft essentially did with MOSS 2007:

1)  a great job on providing InfoPath as it is now.  It does provide a flexible way of building user forms and leverage web services

2)  a interesting job on building BDC Applications. It provides a nice way of connecting web pages to services web services.

3) a fantastic job integrating Office 2007 and SharePoint. I understand it still not very used but it could be a way more used. Perhaps the users are still not ready or there is something missing.

4) enabled a great community to enhance it and build plug-ins that have became used in most successful SharePoint implementations.

5) created a good content management system(Ok, Microsoft CMS was integrated with) that also provides tools to leverage enterprise applications.

Why do I highlight those items? This would be one of the most flexible toolsets/frameworks possible to connect ANY kind of system/solution if there was a proper connectivity between any kind of web part.

Yes, I need to explain which kind of connectivity I’m expecting on SharePoint 2010… I’ll do that soon.

Categories: SharePoint
Follow

Get every new post delivered to your Inbox.