Showing posts with label Technical. Show all posts
Showing posts with label Technical. Show all posts

Tuesday, April 20, 2010

Technical: To create customized class file template in Visual Studio.

Hi Friends,

We can create customized templates for Visual Studio. Please find below the steps for customized class file template.

Steps:
1. Create an Empty Project.
2. Add class file.
3. Write the necessary statements in this file which you want every time you create new class file. Save the project.
4. Go to File Menu -> Export Template...
5. It will give us a zip file.
6. Copy this file to the location: Visual Studio 2008/Templates/Project Templates/Visual C# [If you are using C#, o/w corresponding language folder.]
7. Now Open a new project & click on Add Item. You can see this new template in the Add Item dialog Box for that language.

This example gives ‘class' file template. You can customize any item type.
 
Thank You.
 
Happy Coding..!! :-)

Monday, April 19, 2010

Technical: Garbage Collector in .NET

Hi Friends,

I wanna share few terminologies related to Garbage Collector in .NET. Hope this helps u...

Garbage Collection Phases:














Types of Garbage Collection:

Garbage Collector Generations: 















 Survival & Promotions:
     Objects that are not reclaimed in a Garbage Collection are known as Survivors & are promoted to the next generation.

Variable Threshold:
     When Garbage collector detects that the survival rate is high in a generation, it increases the threshold of allocations for that generation, so that next collection gets a substantial size of reclaimed memory.

Unmanaged Resources:
      If your managed object refers unmanaged objects by native file handlers, you have to explicitly free the managed objects, because the collector tracks memory only on the managed heap.
     This can be done by using finalizers. You can make your managed object finalizable.
     When your finalizable object is detected as dead, its finalizer puts in a queue so that the cleanup actions are executed and the objects itself is promoted to next generation.

Q: How GC determines whether object is live?
A: 1. Stack Roots
     2. Garbage Collection Handles
     3. Static Data Tracking

Q: When Garbage Collection occurs?
A: 1. When system has low physical memory.
     2. When the memory that is used on managed heap surpasses acceptable threshold. [This threshold  
          continuously adjusted as the process runs.]
     3. When GC.Collect() method is called.

Thank You..!! :-)

Happy Coding..!! :-)

Sunday, April 11, 2010

Technical: What is Test Scenario?

Test Scenario is high level description of business requirements, which is later decomposed into set of test cases.
Test Scenario may contain list of test cases to test a particular scenario. Test scenarios are executed through test scripts or test procedures.
The test cases may be ordered in a test scenario, which means output of one test case will be an input for the next test case.
We can write scripts to execute a test case. A single script may cover multiple test scenarios.

For Example: 'Test a login page' will be a test scenario.
This scenario may contain multiple test cases like: If user name is blank, If password is blank, If credentials match, If credentials does not match, etc.. etc...

Hope this helps!!

Happy Coding!!!

Monday, March 8, 2010

Technical: Fetching blog feeds in .NET

Hi Friends,

I would like to share how we can fetch the blog posts in .NET 3.5.

.NET Framework 3.5 had given us a dll: System.ServiceModel.Syndication. This dll gives a class SyndicationFeed in which we can extract the blog feeds.
We can read the blogpost in XmlReader.

Please find below a simple code snippet in C# to fetch the blog item & displaying it on console.

// Read the blog from the blog URL.
XmlReader reader = XmlReader.Create("http://aashita28.blogspot.com/feeds/posts/default");

// Create an object of SyndicationFeed class.
SyndicationFeed feed = SyndicationFeed.Load(reader);

// Access the items of feed object & display its properties.
foreach (var item in feed.Items)
{
Console.WriteLine("Title: " + item.Title.Text);
Console.WriteLine("Link :" + item.Links[0].Uri.ToString());
Console.WriteLine("Description :" + item.Summary.Text);
Console.WriteLine("PublishDate :" + item.PublishDate.LocalDateTime.ToLongDateString());
}

Using this class, we can display the blog item links on a webpage.

Thank you..

Happy Coding..!! :-)

Wednesday, March 3, 2010

Technical: To create a class from XML Schema in .NET

Hi Friends,

I came across one requirement in my last project to create class file from the XML schema.
I would like to share the points for doing this task in .NET.

1. Create XML Schema(.xsd) file.
2. Goto Visual Studio Command Prompt.
3. From the command prompt, run the xsd.exe
Syntax: xsd Schema.xsd /classes /language:[CS/VB]

Example: xsd c:/abc.xsd /classes /language:CS

You will get newly created class file.

Thanks.

Happy Coding..!!

Tuesday, March 2, 2010

Technical: About Collections [HashTable]..

Hi Friends,

I got to know new thing today, which you may be already knowing...

Few months back, I faced one issue in .NET related to HashTable, that we can not sort hashtable by keys. :-(

Fortunately, today I got its solution. We can use 'OrderedDictionary' to have same performance as HashTable & also, to have sorting feature on it. This class seems to be a mixture of HashTable & ArrayList.

Thought to share with you all...!!!

Thank you.

Happy Coding..!!

Thursday, February 25, 2010

Technical: Visualizations using ASP.NET Charting controls.

Hi Friends,

I have a good news for you. Now showing a chart in our ASP.NET page or in our Windows Application is as easy as showing a datagrid or a table.

Microsoft had given us a visualization toolkit which gives us a facility to just drag & drop a chart control on our page & show our data in a chart format.

.NET Visualization toolkit gives us a dlls: System.Web.DataVisualization.dll and System.Web.DataVisualization.Design.dll. Add reference to these dlls in your application.

Write an import statement in your code behind:
using System.Web.UI.DataVisualization.Charting;

Now, drag & drop chart control to your page.
Please find below some basic settings of chart:

Title -
You can set the title of chart
chart.Titles.Add(title);

ChartType -
You can set ChartType as-
chart.Series[0].ChartType = SeriesChartType.Column;

Data -
You can set data of the chart using method-
chart.Series[0].Points.Add(DataPoint);

Legend -
You can set legend as-
chart.Series[0].LegendText= LegendText;

Thankas for reading my post.

Happy Coding..!!

Technical: ASP.NET MVC Architecture

Hi Friends,
I want to share with you my knowledge of ASP.NET MVC.
This is the new technology Microsoft had launched, which uses HTML Controls instead of ASP Server controls.

Switching back from ASP.NET to ASP.NET MVC was little tough for me, since we have to use HTML controls & JQuery for the client-server communication.

MVC stands for Model - View - Controller.
Models consists of classes which wroks in backend.
View mainly consists of UI pages i.e. ASPX & ASCX pages.
Controller is similar to code-behind pages in ASP.NET. It will consists of code behind logic.

For implementing ASP.NET MVC, we must know:
- JavaScript,
- JQuery,
- HTML Controls
- C#/VB.NET

One more interesting feature of ASP.NET MVC is URL Routing. Global.asax file consists of MapRoutes. Whenever a URL is fired, the map routes are checked & accordingly the action will be taken.

When you create an ASP>NET MVC Application, the Visual Studio already gives you folder structure, mainly consists of Models, Views & Controllers. Also it will give 'Global.asax' file.

Views
Views folder will have sub folders. For example: Home. The subfolders will consists of ASPX or ASCX pages. These pages consists of HTML controls.
For Example: Html.ActionLink, Button, etc.

Controllers
Controller name will be consists of subfolder name of Views, and consists of methods to handle events of the UI pages in that perticular subfolder.
For Example: HomeController will contain methods like: getPersonClicked(), btnHomeClicked(), etc.

Models
Models will consists of .cs files mainly consists of classes.
For example: Person class with its properties PersonId, Name, Age, etc.

Repository
Repository filder will consists of operations on classes in Models folder.
For example: PersonRepository class will contain methods like AddPerson(), GetPerson(), etc.

One important point to be noted is: "We can not access controller(its methods) directly from view and also we can not access controls in views directly from controller.!!!".
For this purpose we will have to use JQuery & ViewModel.

For accessing controller method from View, we will use JQuery. [$.ajax calls] and for passing the values from Controller to Model, we will use ViewModel.

Feeling very happy to share my knowledge with others.

Thanks.
Happy Coding..!!