Archive for March 2017
3 layer architecture
Create website- ASP Project
Create class library - BAL
Create class library - DAL
Add references as below:
BAL in ASP Project
DAL in BAL
Adding class:
Right click on dal project
add class with name as DUser.cs
Make class as public bcoz it is used in other project.
To use some namespaces you have to add reference in DAL project
Right click on DAL Project
Add references
In assemblies/.NET add System.Configuration to use ConfigurationManager class in DAL layer.
Create DUser class - Write method with parameters and ADO.NET Code.
Right click on BAL Project
Add BUser class - Write method with parameters and C# logic
Sending inputs:
PL - input parameter (txt.text) - > BAL - input parameter (variables) -> DAL
Returning values:
DAL - return value -> BAL - return value -> PL
Calling methods:
Call methods of BAL from Presentation layer.
Call methods of DAL from BAL.
Developer Unit Testing
Unit testing is done by the developer to check your code is working as expected or not.
It is called unit testing as the developed functionality is tested individuals as small units.
Visual Studio Test Explorer is used to find the list of unit test methods available in the project and provides options to run/debug your unit tests.
It improves the quality of the code as it is easy to test every unit of program using automated unit testing as soon as new code is added into the project.
With Test driven development by proper unit testing bugs in the code can be reduced.
You can also install add ons of other 3rd party unit testing tools in Visual Studio to use them for unit testing.
Code Example:
In the below example Unit Test project is created.
In test class(UnitTest1) two test methods are created 1. TestAuthSignInSuccess and 2. TestAuthSignInFail methods.
Original method(DUserAuth) used for user registration which has to be tested is also written in the same class.
--------------
It is called unit testing as the developed functionality is tested individuals as small units.
Visual Studio Test Explorer is used to find the list of unit test methods available in the project and provides options to run/debug your unit tests.
It improves the quality of the code as it is easy to test every unit of program using automated unit testing as soon as new code is added into the project.
With Test driven development by proper unit testing bugs in the code can be reduced.
You can also install add ons of other 3rd party unit testing tools in Visual Studio to use them for unit testing.
Code Example:
In the below example Unit Test project is created.
In test class(UnitTest1) two test methods are created 1. TestAuthSignInSuccess and 2. TestAuthSignInFail methods.
Original method(DUserAuth) used for user registration which has to be tested is also written in the same class.
--------------
using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Data.SqlClient; using System.Data; namespace UTDigitalWorkSpace { [TestClass] public class UnitTest1 { [TestMethod] public void TestAuthSignInSuccess() { //inputs string username = "ravi"; string password = "ravi123"; //outputs UnitTest1 ut = new UnitTest1(); int result = ut.DUserAuth(username, password); //expected outputs int expectedResult = 1; //check Assert.AreEqual(result, expectedResult); } [TestMethod] public void TestAuthSignInFail() { //inputs string username = "ravi"; string password = "ravi12344"; //outputs UnitTest1 ut = new UnitTest1(); int result = ut.DUserAuth(username, password); //expected outputs int expectedResult = 0; //check Assert.AreEqual(result, expectedResult); } public int DUserAuth(string UserName, string Password) { SqlConnection con1 = new SqlConnection(@"Data Source=.;Initial Catalog=DigitalWorkSpace;Integrated Security=True"); SqlCommand cmd = new SqlCommand("select * from Tbl_SignUp where UserName='" + UserName + "'and password='" + Password + "'and Status='A'", con1); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); return ds.Tables[0].Rows.Count; } } }
Interview Questions
Fresher:
Add your strengths at the top of the resume. Try you add your extra curricular activities and awards information along with academic achievements.
If your academic records are not good then add your technical skills above your academic information.
Your interests and hobbies related to technology on the resume grabs more attraction.
Experienced:
1. Difference between the versions of tools you used in your projects?
If you mention about the usage of more than one version of the same tool in your projects then you have to be ready with the knowledge of
- differences between the versions
- updates in the new version
- how the new updates are used in your project
2. What is the module you worked in your project?
You should have knowledge on the entire project and how it works but you have the scope to work on limited modules. So, you have to explain in detail about how that module works and how it is implemented.
3. What are the challenges you faced in implementing that module and how you resolved it?
While implementing a project as a team you will run into some difficulties when you go through some tricky scenarios. You have to explain about your contribution to your team to resolve them.
Example: Task: To print data of a registered user in pdf format. Answer: Printing a pdf file is easy but converting data available in database table to pdf format to print is difficult. External tools to do this required license which is costly. In that time i converted the data into html page and then used it to print which resolved this issue.
4. What are your responsibilities in your project?
My responsibilities in my project is to understand the requirements, analyzing the requirements to find the technical solutions to it and implement it with good quality.
5. Explain about your project architecture?
I used ASP.NET 3 tier architecture in my 1 st project and used MVC architecture in the 2 nd project.
Explain about 3 tier and MVC with uses.
6. What is the duration of your 2 nd project?
7. What are the functionalities you are providing to the customer in 2 nd project?
8. What are the .NET features used in current project?
OOPs concepts, interfaces, exception handling...
9. Explain about SDLC?
Agile methodology and scrum framework
10. How many members are there in your team and what is the process you followed?
Add your strengths at the top of the resume. Try you add your extra curricular activities and awards information along with academic achievements.
If your academic records are not good then add your technical skills above your academic information.
Your interests and hobbies related to technology on the resume grabs more attraction.
Experienced:
1. Difference between the versions of tools you used in your projects?
If you mention about the usage of more than one version of the same tool in your projects then you have to be ready with the knowledge of
- differences between the versions
- updates in the new version
- how the new updates are used in your project
2. What is the module you worked in your project?
You should have knowledge on the entire project and how it works but you have the scope to work on limited modules. So, you have to explain in detail about how that module works and how it is implemented.
3. What are the challenges you faced in implementing that module and how you resolved it?
While implementing a project as a team you will run into some difficulties when you go through some tricky scenarios. You have to explain about your contribution to your team to resolve them.
Example: Task: To print data of a registered user in pdf format. Answer: Printing a pdf file is easy but converting data available in database table to pdf format to print is difficult. External tools to do this required license which is costly. In that time i converted the data into html page and then used it to print which resolved this issue.
4. What are your responsibilities in your project?
My responsibilities in my project is to understand the requirements, analyzing the requirements to find the technical solutions to it and implement it with good quality.
5. Explain about your project architecture?
I used ASP.NET 3 tier architecture in my 1 st project and used MVC architecture in the 2 nd project.
Explain about 3 tier and MVC with uses.
6. What is the duration of your 2 nd project?
7. What are the functionalities you are providing to the customer in 2 nd project?
8. What are the .NET features used in current project?
OOPs concepts, interfaces, exception handling...
9. Explain about SDLC?
Agile methodology and scrum framework
10. How many members are there in your team and what is the process you followed?
About AngularJS
AngularJs is a JavaScript framework used to build web applications. It is a free source developed by Google.
Advantages:
Dependency injection
Two way data binding
Supports clean MVC architecture
Controlling DOM.
http://angularjs.org/ - Link to download AngularJs library.
Example:
In html page with ref of angularjs file with below code it will display 30 on browser.
<!DOCTYPE html>
<html>
<head>
<script src="Script/angular.min.js"></script>
</head>
<body ng-app>
{{10+20}}
</body>
</html>
Advantages:
Dependency injection
Two way data binding
Supports clean MVC architecture
Controlling DOM.
http://angularjs.org/ - Link to download AngularJs library.
Example:
In html page with ref of angularjs file with below code it will display 30 on browser.
<!DOCTYPE html>
<html>
<head>
<script src="Script/angular.min.js"></script>
</head>
<body ng-app>
{{10+20}}
</body>
</html>
Module
A module is a container of different parts of the application.
A module is a container of different parts of the application.
ASP.NET Displaying Online Users Count and Page Views - Application state in Global.asax
ASP Source code:
<p>
Online User:
<asp:Label ID="lblOnline" runat="server" Text="0"></asp:Label>
</p>
<p>
Page Views:
<asp:Label ID="lblPageViews" runat="server" Text="0"></asp:Label>
</p>
ASP C#.NET Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace StarBus
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//increment on page load and display
Application["PageViews"] = Convert.ToInt32(Application["PageViews"]) + 1;
lblPageViews.Text = Application["PageViews"].ToString();
//display online users
lblOnline.Text = Application["OnlineUsers"].ToString();
}
}
}
Global.asax file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace StarBus
{
public class Global : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Application_Start(object sender, EventArgs e)
{
Application["OnlineUsers"] = 0;
Application["PageViews"] = 0;
}
protected void Session_Start(object sender, EventArgs e)
{
Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) + 1;
}
protected void Session_End(object sender, EventArgs e)
{
Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) - 1;
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}
<p>
Online User:
<asp:Label ID="lblOnline" runat="server" Text="0"></asp:Label>
</p>
<p>
Page Views:
<asp:Label ID="lblPageViews" runat="server" Text="0"></asp:Label>
</p>
ASP C#.NET Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace StarBus
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//increment on page load and display
Application["PageViews"] = Convert.ToInt32(Application["PageViews"]) + 1;
lblPageViews.Text = Application["PageViews"].ToString();
//display online users
lblOnline.Text = Application["OnlineUsers"].ToString();
}
}
}
Global.asax file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace StarBus
{
public class Global : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Application_Start(object sender, EventArgs e)
{
Application["OnlineUsers"] = 0;
Application["PageViews"] = 0;
}
protected void Session_Start(object sender, EventArgs e)
{
Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) + 1;
}
protected void Session_End(object sender, EventArgs e)
{
Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) - 1;
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}