Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘Programming’ Category

What Makes a Good Programmer?

Here are some suggestions for the fresh graduates and the college freshmen on how to become a good programmer.

  1. Strong skill of one or more good languages like C++, Java and C#.
  2. Write an implementation plan (or model).
  3. Deep knowledge of OOP.
  4. Know most common algorithms well
  5. Be skilled in debugging in IDEs
  6. Add Comments to your code.
  7. Organize your code
  8. Test (Unit Test)
  9. Practice
  10. Read codes from others

FAQ in BlogEngine.NET

Can BlogEngine.NET be installed within an existing website?

Yes. Install it in its own folder and configure the directory it resides in as an application in IIS.

Some hosting providers may not allow the level of trust used in BlogEngine.NET by default. If you receive an error similar to:

  • “Parser Error Message: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level.”,

You can try one of the following to resolve the issue:

  • Comment out the “trust” line in web.config
  • Ask your hosting provider if they can configure the directory where BlogEngine.NET is installed as a virtual directory.
  • Ask your hosting provider to verify that the directory has been configured as an application in IIS.

How do I update the “About the Author” section of the blog?

In the default Standard theme, edit the content of this section by clicking “edit” in on the side bar of your blog.

An alternative way to display About the Author information is to create a ‘Page’ in the control panel. The Title of the Page can be About the Author. Enter information about the author in the WYSIWYG editor. Once the page has been created, you can add a link to the About page on your blog. This can be achieved by adding a Page List widget, or by adding a TextBox widget with a hyperlink to the About page, or by editing your theme file (site.master) and adding a hyperlink to the About page.

Is BlogEngine.NET open source and completely free?

Yes. BlogEngine.NET is built by passionate developers who have too much spare time, just to make an open source blog engine to give away absolutely free.

Is my mother able to use it?

Yes. We have gone to great lengths to make BlogEngine.NET as easy as possible to use – both from an end user as well as a developer or theme designer’s point of view.

What are the demands for the web server?

The only thing needed to run BlogEngine.NET is a web server that support ASP.NET 2.0 and write permissions on the App_Data folder.

What database is it running on?

None. BlogEngine.NET uses XML to store all posts, pages etc. by default. However, if you prefer to use a database, BlogEngine.NET includes a “DbBlogProvider” that allows you to store data in databases which support standard SQL — MS SQL Server, MySql, SQLite and Vista DB among many others. Configuration changes necessary to store data in a SQL Server database can be found. If there isn’t a data provider already available, you can easily write your own provider. We have enginereed our framework to make this very easy and simple to do.

How can I switch where data is stored (XML to Database or vice versa)?

If you’re just starting off with BlogEngine.NET, all of your data will be stored in XML files in your App_Data folder. Some web hosts such as GoDaddy who have an automatic BlogEngine.NET setup option, might setup your blog so data is stored in a database instead. If your blog is new, you don’t yet have any data, and you want to switch from XML storage to Database storage

VS 2010 Webinar Session Overviews

Visual Studio 2010 is set to be released in April.  Microsoft has made significant investments to improve the “Testing”, “Architecture”, and “Developer” tools within Visual Studio to make it an even more powerful productivity solution.

VS 2010 Webinar Session Overviews:

TITLE DESCRIPTION
Full Testing Experience: Professional QA with Visual Studio 2010 Join us as we demonstrate the testing and quality assurance lifecycle using Visual Studio 2010 and Team Foundation Server. We’ll dive into the testing tools and testing process you can use to dramatically improve the effectiveness of your QA and Test efforts. You’ll see the Microsoft Test and Lab Manager (MTLM) in all its glory as we explore how to manage your test environment, organize test suites, test cases, requirements and bugs, and how to manage both automated and manual test runs. In addition, you’ll see how to easily create an automated test from an existing manual test run. Finally, and most importantly, you’ll discover how insanely easy it is to create bugs that can be simply and reliably reproduced by developers – VS 2010 is that powerful.
Improving Development Practices with  Visual Studio 2010 This is an overview of the new development and database tools in Visual Studio 2010. New capabilities of historical debugging, code analysis, profiling and the new test impact analysis will be demonstrated. Working with Team Foundation Server (TFS) 2010, gated-check-in will be discussed as well as the tester/developer collaboration experience. The new architect tools will be demonstrated to facilitate a better understanding of how modeling is a part of the development experience.
Lab Manager – The Ultimate “No More No Repro” Tool Designing, building and testing code is a hard job. A job made even harder by the fact that most organizations don’t have development and test environments that are clean, easily reset and similar to the production environment. Enter virtualization…and Lab Manager. Lab manager allows you to define, configure and create complete development or test environments as needed. It can coordinate both physical and virtual environments, and comes with an incredibly powerful suite of effective tools that make managing environments simple and cost effective. Attend this webcast event to see Lab Manager in action!
Managing Requirements with Team Foundation Server 2010 Requirements management is a struggle for many organizations. A distinction must be drawn between requirements elicitation, requirements documentation and requirements management. Team Foundation Server provides rich capabilities for managing requirements and can easily be integrated with your preferred tools for documenting requirements. Best practices of requirement elicitation, documentation, management and traceability will be discussed in the context of the requirement lifecycle and how TFS 2010 and third party tools can maximize your overall requirements management process.
Overview of Visual Studio 2010 ALM Tools This overview of Visual Studio 2010 highlights the difference between Team System 2008 and Visual Studio 2010. Emphasis will be put on what migration steps need to be taken to maximize new features including testing tools, version control, work item tracking and build enhancements. As a basis for demonstration, the development processes and practices used to create Notion Tools for Team System will be shown, including branching models, build and deployment automation, custom reporting and workflows.
Streamlining Testing with  Visual Studio 2010 ALM Tools This Visual Studio 2010 overview features Visual Studio Test Elements 2010 testing tools including using the new Microsoft Test and Lab Manager to manage and automate your UI testing. The use of Test Lab will be discussed as a means of automating the creation of virtual environments for testing purposes. Deploying to VM environments during build will be demonstrated and facilitate a robust developer/tester lifecycle. For a taste of real-world use, the test plans and test process used to perform multi-platform testing of Notion Tools for Team System will be shown.
Using Team Foundation Server 2010 for Non-Windows Development This is an overview of best practices for utilizing Team Foundation Server (TFS) 2010 and the Teamprise Client Suite for development activities beyond Microsoft and the Windows platform. This webcast shows development teams using mixed and non-Microsoft platforms how to effectively leverage TFS 2010 to adopt work item tracking, version control, and automated build and test technologies.
Visual Studio 2010 Quality Tools for Developers This webcast event will demonstrate how developers use Visual Studio 2010 and Team Foundation Server to create high quality code, reliably reproduce and efficiently fix reported bugs, and truly work with the testing team. We’ll demonstrate the use of several important tools, such as test impact analysis, IntelliTrace, and other tools that help you understand your code, pinpoint bugs and efficiently fix them. Let’s face it – fixing bugs is both tedious and hard. VS 2010 provides the tools to both you and the tester to make finding, reproducing and fixing bugs dramatically simpler.
What’s New in Visual Studio 2010 Why you should consider Visual Studio and Team Foundation Server 2010. We’re going to discuss the specific business value of the Visual Studio ALM tools now and later. Free webinar event to learn how to get the most out of the Visual Studio investments that your organization has made. You owe it to yourself to learn how this new solution will help you be a more productive in your role!

Keyboard Shortcut Tricks in Visual Studio 2010

  1. visual-studio-2010-asp.net4 Insert a blank line above or below the current line:
    Go to any line in the Editor and press CTRL + Enter to insert a line above or CTRL + SHIFT + Enter to insert a line below the current line.
  2. Pasting a single selection into a box selection
    ALT + Left Mouse
  3. Zoom in or out of text in the Editor using the mouse wheel
    CTRL + Mouse Wheel
  4. Zero-length box selection
    Alt + Left Mouse
    • Assume that you have a a situation with some variables like the ones below and you want to make them all public
    • The answer is a zero-length box selection.  Hold down your ALT key and Left Mouse Button, then drag straight down
    • Release the ALT key and the Left Mouse Button.
    • Done~

Current .NET Version Penetration

The bad news is that only 52.7% of the users has .NET Framework 3.5 installed on their PCs, but as you can see from the table they become more and more very fast:

  Mar-08 Jun-09 Aug-09 Oct-09
Dot Nothing 28.12% 25.60% 25.53% 21.40%
.NET 1.0 2.59% 0.60% 0.40% 0.30%
.NET 1.1 23.22% 13.00% 8.41% 7.70%
.NET 2.0 27.41% 23.20% 23.02% 11.60%
.NET 3.0 17.67% 14.40% 10.01% 6.30%
.NET 3.5 0.99% 21.82% 32.63% 52.70%

List(T).BinarySearch in C#

I think most of us are quite familiar with binary search. Binary search is an algorithm for locating the position of an element in a sorted list by checking the middle, eliminating half of the list from consideration, and then performing the search on the remaining half.If the middle element is equal to the sought value, then the position has been found; otherwise, the upper half or lower half is chosen for search based on whether the element is greater than or less than the middle element. The method reduces the number of elements needed to be checked by a factor of two each time, and finds the target value, if it exists in logarithmic time. A binary search is a dichotomy divide and conquer search algorithm.

In C#, .Net provide a List<T>.BinarySearch Method (T) which can be used easily. here is a demo:

   1: // Init a long type list

   2: var myList = new List<long>();

   3: foreach (var item in "269, 361, 347, 355, 352, 346, 351, 354".Split(','))

   4: {

   5:     myList.Add(long.Parse(item.Trim()));

   6: }

   7:  

   8: // sort

   9: myList.Sort();

  10: var ret = myList.BinarySearch(347);

  11: Console.WriteLine(ret);

Note, I have a ‘myList.Sort();’ before call the BinarySearch, why? It is because BinarySearch will Search the entire sorted System.Collections.Generic.List<T> for an element using the default comparer and returns the zero-based index of the element.

Yes, it is sorted list that binary search will operate on! So remember make your list sorted before call binary search function