Jack is Here, asp.net findings

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 Tagged ‘object oriented programming’

Programmers Should go for ASP .NET

ASP.NET has become a face to the developer with the traditional ASP question. As the ASP has a wide range of applications, but Microsoft has to ensure the implementation of the ASP script on a computer used without modification. NET Framework (ASP engine, Asp.dll, and there is no custom installation. NET Framework). Thus, IIS on the same machine can accommodate ASP and ASP.NET scripts.

Advantages of ASP.NET

1.Division of Code from HTML:

To make a clean sweep, with ASP.NET you can be totally detached layout and business logic. This makes it very easy for developers and designers to collaborate effectively. There is also a high level of performance achieved through this.

2.Support for compiled languages:

Developers can use VB.NET and interviews strongly typed and object-oriented programming of the important things. The use of assembly language indicates that the performance of ASP.NET pages and so there is no similar code to link to an explanation of the punishment. ASP.NET page is compiled into byte code, and in real-time (JIT) compilation of the legitimate demands of it. From now on, all the requests are directed to a fully compiled code, which is to the source to change the cache.

3.Use services provided by the .NET Framework:

. NET Framework to provide a class library used by applications. Help some of the best input / output, access to operating system services, data access, or debugging.

4. Graphical Development Environment:

Visual Studio. NET development environment offers the potential for Web developers. It is possible to drag

5. State Management:

In answer to the problems which developers faced ASP.NET provides solutions for session and application state management. State information can, can be confined in memory or stored in a database. It is also sharable across Web farms, and state information can be recovered, in case the server fails or the connection breaks down.

6. Update files while the server is running!

You can update your application while the server is online and customers are connected. The framework will use the new files at the same time they are copied to the application. The files are old and need to be removed are still in use are kept in memory by the time customers.

7. XML-Based Configuration Files:

In the ASP.NET configuration settings can be saved in the XML file is readable and can be edited. It is also very easy to them to another server, with your applications, including other documents.

ASP Web Development has thus revamped the entire IT Industry in its own way.

Using the singleton design pattern

What is the Singleton Design Pattern?

A group of authors now affectionately known as the ‘Gang of Four’ (Erich Gamma, Richard Helm, Ralph Johnson, and John Vilssides) wrote a book called ‘Design Patterns: Elements of Reusable Object-Oriented Software’. In this book they defined three categories of design patterns which are:

  • Creational Patterns
  • Structural Patterns
  • Behavioural Patterns

?

The Singleton Design pattern falls into the category of Creational Design Patterns, the Singleton Design Pattern ensures your software has only one instance of the class and provides a global access to it. In other words?the Singleton design pattern is all about making sure that you can instantiate only one object of a particular class. If you don’t?use a pattern like this one, the new operator just?keeps on?creating more?and more objects.??

Could I not just use a Static Class

Technically you can only use a static class it will only have a common instance of a class. However, if you do not, then it may miss some design patterns for single persons, some of the benefits. These benefits are single people, including a static class are:

  • Singletons can implement interfaces and inherit from other classes
  • A singletons can be lazy loaded. Only when it is actually needed. That’s very handy if the initialisation includes expensive resource loading or database connections
  • Singeltons offer an actual object
  • Singletons can be extended into a software factory. The object management behind the scenes is abstract so it’s better maintainable and results in better code
  • Static classes are instantiated at runtime. This could be time consuming. Singletons can be instantiated only when needed

So how do you use the Singleton Design Pattern?

In object-oriented programming and software development, you typically create an instance of an object with a new operator, for example:

C#:??????????? MyObject myNewInstance = new MyObject()
VB.NET:????? Dim myNewInstance As New MyObject()

Each time a new object of the computer has a heap of memory, creating lots of these items will increase the amount of memory used and may result in the performance of your software product.

So how do we do this so that we only ever one instance of our class, but this is a very simple 2 step process:

  1. Create the objects contructor as PRIVATE , that way no code outside of the class can creat an instance of the object.
  2. Create a static/shared method within the class that will return a newly created instance of your class, or if an instance already exists then it will return the current instance.

?Singleton Design Pattern?Example

C#:

public class MyObject
{
?????? //create a private static variale to store our instance
?????? private static MyObject singletonObject;

?????? //create a private constructor
???????private MyObject()
????? {
???????????? //initial
?????? }

?????? //create a publi static method to return the instance
?????? public static MyObject CreateInstance()
?????? {
/ / Check if we have an example, if the returns in, otherwise create a new
????????????? //instance

????????????? if (singletonObject == null)
???????????????????????? singletonObject = new MyObject();

??????????????return?singletonObject;
???????}
}

?

VB.NET :

Public Class MyObject

?????? ‘create a private static variale to store our instance
?????? Private Shared?singletonObject As MyObject

?????? ‘create a private constructor
???????Private Sub New()
??????
???????????? ‘initialise the object
???????End Sub

?????? ‘create a public static method to return the instance
?????? Public Shared Function CreateInstance() As MyObject
???????
????????????? ‘check if we already have an instance, if so?return it, else create a new
????????????? ‘instance

????????????? If singletonObject Is Nothing?Then
???????????????????????? singletonObject = new MyObject()
????????????? End If

??????????????Return?singletonObject
???????End Function
End Class

?

Please note that in a single design model, we declare a private static variable to store instances of a class of our implementation. When we call we have created, and create an instance of our checks to see if there is an instance of the variable, if there is no one is to create and return to function.