I’m a big fan of Joel Spolsky’s writings and last weekend I checked his article archive for some useful to read. One interesting article I found there, which is about how we can steer our development process to achieve better coding. Even though he has written this in year of 2000, it's almost valid yet.
He was discussing about 12 steps we can follow up for better coding and he named it as Joels Test
The Joel Test
Do you use source control?
Can you make a build in one step?
Do you make daily builds?
Do you have a bug database?
Do you fix bugs before writing new code?
Do you have an up-to-date schedule?
Do you have a spec?
Do programmers have quiet working conditions?
Do you use the best tools money can buy?
Do you have testers?
Do new candidates write code during their interview?
Do you do hallway usability testing?
Questions are about two options you take as answer; Yes or No.
Usability is a big thing to be bothered about in the current industry. Even though we have delivered all the functionalities well worked, how we are going to assure that customer is reaching all the functionalities and features we developed over nights to make them happy.
Found nice definitions for usability from the few articles I read…
Put User at the center of the Process The term usability in the context of creating software represents an approach that puts the user , rather than the system, at the center of the process.
Usability And Likability Usability is a measure of how easy it is to use a product to perform prescribed tasks. This is distinct from the related concepts of utility and Likability.
Few months back, we were migrating our SVN server into new machine and after the migration we all needed to Re-Locate our sources.
In that case, what we were assisted to replace old server URL with new Server URL.
As Expected Re-Locating went successfully and after that we were trying to get update the Projects Sources with the new server. But it was started throwing following error message.
Path 'https://svnservername.CompanyName.local:8443/svn/projectname' is not canonicalized; there is a problem with the client.
Error itself doesn’t tell much on issue details and was surfing internet to find the solution.
Finally found someone mentioning make all the characters in the URL into simple and try. So made the URL like this
As I can remember, when I was starting learn to programming, writing a simple Hello World program was a big challenge, even though we had enough capable IDEs to do the programming. It’s very interesting to even imagine generate programs dynamically at run time by another program.
With Microsoft .NET CodeDom, it’s possible to generate programs, compile and run them at run time. With this framework code library, it’s possible to have virtual DLLs, Namespaces, classes, Variables, Methods and etc.
Just Imagine this is the class you need to generate dynamically,
The Class name you have to pass into the method and it will return a reference of object type CodeTypeDeclaration class, which is representing a particular .NET Class with given name.
Create a Property
publicstatic CodeMemberProperty CreateProperty(string Name, Type propertyType)
{
CodeMemberProperty returnValue = new CodeMemberProperty();
returnValue.Attributes = MemberAttributes.Public;
returnValue.Name = Name;
returnValue.Type = new CodeTypeReference(propertyType);
As Same as Class declaration, we have to pass Property Name and the type of the property here and method will return an object reference of type CodeMemberProperty Class, which is representing the .NET Class Property virtually.
Generate a Class
Let’s generate the class we need with all together,
new CodeMemberField(typeof(string), "_property2"));
return returnvalue;
}
publicvoid GenerateCode()
{
CodeNamespace cns = GenerateSkeleton();
return cns.ToString();
}
Now we have generated the class we need and to make sure everything is ok, you just write the text coming from GenerateCode() method to a file. And it will exactly match with the class we mentioned at the start of this article.
Compile the Generated Class
Now it’s time to working on compiling the class generated at runtime. As same as class generation, compilation is also going to be done at runtime.
publicAssembly CompileCode()
{
CodeNamespace ns = GenerateSkeleton();
string lcCode = GenerateCode("C#", ns);
ICodeCompiler loCompiler = new CSharpCodeProvider().CreateCompiler();
At the end of the compilation, you can have compiled assembly and this is not an assembly physically exists.
How to use a virtual assembly
After generating the Assembly for the virtual class implementation, it’s time to use it at runtime. This class won’t be alive to use later or after a particular session of the application, because all these things are happening here, is virtual. Anything you need to keep for the later use, you will have to save them purposely in the code.
Monday I heard from one of our customer that their SharePoint site is not working and give an error like
"Server error: http://go.microsoft.com/fwlink?LinkID=96177". That's all it says....
So I was googling to find some thing useful to overcome this and there were lots suggestions online too.
Most of the suggessions were asking to Run SharePoint Product And Technologies Upgreade and then after that things should be ok.....
But SharePoint Product And Technologies Wizard was stucking at step 9 and It was running more than a whole day, but I didn't stop it and let it to run. But finally found it is not going to stop and I stoped it.
Then fortunately found blog post asking to run following command...
In SharePoint Task, we are having three views, New Task View (Where you initiate a new task) , Edit Task View(Where you update an exsisting task) and Task Display View (Just View a Task Details). In each view, you will need, particular fileds to be viewed, but some fields no to be in there.
I was also having same senario to be implemented in our intranet, Some fileds won't need t0 be view New Task entering view, but those fileds need to be in task editing view and so on so on.
In case i found a usefull article which describes how to achieve that what I was looking for....
This is some thing i was really working hard on to find out. And it is a common thing we might need most of the time. Suppose we need to find the Start Date and End date of this week. Only thing I can reach programatically is Current Date. In C# it's
DateTime currentDate = DateTime.NOW;
Here is the code snippet to find the Start Date and Last Date of this week.
DateTime currentDate = DateTime.Now; int week = myCal.GetWeekOfYear(currentDate , System.Globalization.DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DayOfWeek.Monday); DateTime BeginingOfYear = new DateTime(DateTime.Now.Year, 1, 1); System.Globalization.Calendar D = System.Globalization.CultureInfo.CurrentCulture.Calendar; DateTime Weeks = D.AddWeeks(BeginingOfYear, Convert.ToInt32(week));
I found this code snippet from a SharePoint Forum thread, It is about How to upload Files into SharePoint Document Library Using SharePoint API. Credit Should to original developer. using (SPSite siteCollection = new SPSite(url))
I found simple article on this, and it says essential you need to know as new comer for SharePoint development. Here I copied that and paste here, just to read when I need.
The core SharePoint Services platform is comprised of more than 3000 API's. The most fundamental of these are found in the Microsoft.SharePoint namespace. The classes in this namespace will be used in virtually every Web Part and application development effort, so this is a good place to start.
The four key classes you'll need to become familiar with first are SPContext, SPSite, SPWeb, and SPUser. The SPContext class represents the context of an HTTP request in SharePoint Services. The SPSite class represents a collection of sites, including the top-level site and all children sub-sites. The SPWeb class is used to represent a single site in SharePoint. And, the SPUser class is used to represent a single user. Using these classes together lets you access virtually all information about sites and users, both in and out of the current site context.
In most situations, you'll need to know in what site context your code is currently running. To obtain this information, use the following code:
SPWeb web = SPContext.Current.Web;
If you are interested in retrieving the current site collection, use this code:
SPSite siteCollection = SPContext.Current.Site;
And if you need to access a site collection for a different context, you can use the following approaches:
Many times you'll want to obtain the current user for the current site context. Give this a try:
SPWeb web = SPContext.Current.Web; SPUser currentUser = web.CurrentUser;
If you want to use some of what we learned above in a custom Web Part development effort, your code may look something like the following:
protected override RenderContents( HtmlTextWriter writer ) { // Obtain context of current site and user. SPWeb web = SPContext.Current.Web; SPUser user = web.CurrentUser;
// Display the current users name. writer.WriteLine( "Greetings: " + user.Name ); }
Obviously, this is a very basic example, but I hope it gives you a clear idea of how to use the current site context to obtain information about the site and user for which your code is executing.
http://www.sharepointkings.com/2008/08/create-custom-listviewwebpart.html - Customer List View
http://www.sharepointkings.com/
Web Service Examples http://blogs.msdn.com/arpans/archive/2007/07/24/sharepoint-web-service-example-grabbing-wiki-content.aspx http://blogs.msdn.com/ericwhite/archive/2009/01/06/getting-started-with-sharepoint-wss-web-services-using-linq-to-xml.aspx http://www.csharphelp.com/archives4/archive602.html http://www.developer.com/tech/article.php/3104621 http://www.sharepointdevwiki.com/display/public/SharePoint+Web+Services http://www.infoq.com/articles/swanson-moss-web-services
Normally with ASP.NET Tab Container we manage to keep few Data Forms in several Tab Panels. For example, One Tab Panel has User adding Form and other one has Customer Adding Form.
In Add User View We have Few Required Filed validate controls to validate few fields and in same way Add Customer Form Also having few Required Field Validate Controls to validate some user input fields.
Add User Form and Add Customer View...
The Problem I faced is like, when we submit the Add User form with user information, the Required Field Validate Controls in Add Customer Form are also fired. Then as the result, nothing is happened. Finally I found the solution for this after browsing the internet few minutes.
We need to have value for ValidationGroup Property in the Required Filed Validate Controls and for the same form every Validate Controls should have same value for Validation Group Property. And also make sure to set ValidationGroup property for the button in the form as the same value as the form's Validate Controls.
Then what happens I like, when the button press, it only validates Controls which are in the Same Group as it's ValidationGroup Property.