Category Archives: OOPS

  • 4

MVC Architecture

MVC architecture  is basically designed to separate the business logic and application data from the presentation data to manage easily.
MVC stands for L Model – View – Controller

1).  Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.

2). View : The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view’s to maintain the consistency in its presentation when the model changes.

3). Controller:  Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. The views and the controllers work very closely together.

Advantages of using the MVC Architecture.

1. Code developed using MVC is resuable
2. When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary.
3. By using the MVC design pattern our application becomes more expressive.
4. Expaning of an application is very easy as business logic is seperated from UI.
5. Tomorrow if you need to switch the database from, say, SQL to Oracle you dont need to change the whole application, only the Model layer will be changed.


Bookmark and Share


  • 28

Tips for Creating a better E-Commerce Application

E-Commerce, A name started few years back and now ruling the world. Most of the companies started their E-Commerce portals to sell products online to increase their sales and some are even only online portals they don’t have off line stores and they sell some one else’s products.

Now a days people want the products at their door steps. If your services are on time then no one can beat you in E-Commerce, Following are few of recommendations to develop an E-Commerce Application:

1. A neat and clean website design

Your website UI design must be very clear and soothing that users visit again and again, atleast to review the design.

2. Avoid Ads:

if you want to show some Ads go for internal Ads, Like Ad of one of your product which is going to appear on other page

3. Easy to find Products:

Put a Search box, so that users can easily find the products on website, People don’t remember SKUs so make the search keyword enabled, better to go for Full Text Search.

4.  Better Searched Results Page:

The search results page should be interactive enough to display the maximum products and at the same time the page should not be cluttered enough that irritates the customer to find the required product.

5. Put Drill Down on Searched Results:

The successful websites like Amazon, E-Bay, CNET etc have the Drill Downs impemented on the searched results. Suppose user entered the keyword “Laptop” in the search box, Now it will display the list of all the laptops in the searched results but the true E-Commerce leader will display the searched results as the Groups of Laptops. Grouping by Brand, Grouping By common paratmeters like screen size, RAM, Processor, Next Generation Processors, Price Slabs (500$ – 800$, 1000$ to 1200$) etc so that user’s can easily idetify the product that they required.

6. Product Details Page:

Your  product details page is very important for the user, as its going to behave like a Sales Man, Display the product with Multiple pictures, one picture on the screen of medium size and show some icons of the images below the main image and let the user to view the bigger images. Give all the four views of a product to user for his satisfaction.

Dont write very long descriptions, describe important points and give a summary too.

7. Product Variants:

Display variants of products on Product Detail Pages. When you enter a shop and check a laptop the sales person will also show you the different models of that laptop or different skins available for that so that you can have options to buy. similarily this page is your sales man.

8. Shopping Cart:

Make an interactive shopping cart, easy to operate where the quantity of the prodcuts can be altered.

9. Easy Checkout:

There should be an easy checkout system, Users should be able to enter multiple Shipping addresses while let them have only one billing address and store those shipping and billing addreses for future usage.

10. Payment Gateway Integration:

Always go for Secured and known payment Gateways like paypal, google that people can trust over.

11. Use SSL certificate to make the pages secured:

Its very necessary for you to implement the SSL certificate to prevent fraud and theft of your important information.  Users will not trust your site untill it has the SSL installed – i mean https://

12. Display Secured Logos:

Display the logo of that SSL provider on your website that let the users know that the site is secured. there are various organizations who keep on testing your websites and make sure that your website is hackers safe and fraudulent free. Like Hackerssafe. keep these logos on your website that will assure users that your site is protected and safe which will eventually increase your site traffic.

13. Let the people sell your Products on their sites:

Pubish the XML / CSV feeds. Let people subscribe to that. In this way, your product selling will increase and your brand will be promoted.

14. Google Page Rank:

Google page rank play an important role in E-Commerce Applications, Now a days users are more smart than the programmers. They know the importance of Google Page Rank and they know if a site has high Page rank (atleast PR-4) that means that site has importance in Google eyes and will be Good. Click here to find steps to increase Google Page Rank

15 Alexa Page Rank:

Alexa page rank defines the usage of the site. It shows the rank of a page as per the visits of  the users. so user can some to know how popular is your site is.

These were few steps to make your e-commerce application as the best E-Commerce application.

We at Zonix develop these E-Commerce Application, if you would like to go for that – contact at www.zonixsoft.com or email at sales@zonixsoft.com. Few more things are more which we will be publishing in near future. Keep visiting.

Bigbuyindia is an E-Commerce Portal where you can buy India Jewellery products.


Bookmark and Share



  • 0

SingleTon Object

Introduction

Sometime we need a class that has to be instantiated only once. That means we cannot have more than one instance for a class. Here singleton comes into picture. Singleton object is not a new thing come from oops concept. Let us read how easy it is.

Implementation

Typically every class is instantiated using constructor. Suppose if you make the access modifier of constructor to private, what happens u cannot access the constructor outside the class. That means u cannot instantiate your class. Then now you may have a doubt that how can we access the methods in that class without an instance. So for that you are creating one static method inside the class, I think now you got an idea. Yes, how can we access static method in a class? Directly using (classname.Methodname).
In the same way we are using our static method in our class. That static method is of class type it belongs. That means we are returning class object from static method. In this way we are restricting our class to single instanced class.

Example

This gives some clarification.public class MySingletonClass
{
//////// declarations

private string _name;
private string _company;
private static MySingletonClass singletonobject = new MySingletonClass();

//////// here some properties
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}

public string Company
{
get
{
return _company;
}
set
{
_company = value;
}
}

///// here private constructor

private MySingleTonClass()
{
_name = “Phani”;
_company = “KST”;
}

public static MySingletonClass GetSingletonObject()
{
return singletonobject;

}

}

that’s all now u create singleton object in your application like this

MySingletonObject singleton = MySingletonObject.GetSingletonObject();
singleton.Name = “Phanindra”;
singleton.Company = “KST”;

 

 

 

 

Summary

This article describes what singleton object is and how can we make it ? and these
Singleton objects are mainly used as session objects. Just directly assign this reference
To System.Web.HttpContext.Current.Session[“SingletonSession”] = singleton;

Que : Which of the following is a Singleton object

             DataReader,SqlConnetion,SqlDataAdapter,DataSet

Ans :  DataReader

An instance of the DataReader cannot be created like DataReader dr=new DataReader() but only like DataReader dr=cmd.ExecuteReader() which returns an open datareader , this is to restrict only one instance of the dr per execution as the datareader has the behavior of exclusively locking up db connections until it reads all the records

 Courtesy: The Seo Guru, A Software Development Company, Best OOPS Blog Site, Link Submission, Thanks to Shopping  Site for Link Exchanging


Bookmark and Share


  • 10

OOPS Concepts and .NET Part 2 Inheritance, Abstraction, Polymorphism

Summary

The following article is the second of a three-part article series that presents definitions and samples for different Object-Oriented Programming (OOP) concepts and its implementation in .NET. The first part examined the concepts of classes, objects, and structures. This part examines the concepts of inheritance, abstraction, and polymorphism. The third and last part will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Introduction

In Part 1 of Object-Oriented Programming Concepts and .NET, I defined the concepts of class, object, and structure. In addition to defining the concepts, I explained real world samples and presented sample code in C# and VB.NET to create classes and structs. The first article also explains objects as independent building blocks.

In Part 2 of Object-Oriented Programming Concepts and .NET, I will explain the concepts of inheritance, abstraction, and polymorphism. I will also present a Unified Model Language (UML) class diagram to represent an object model that will help as a visual aid to explain some concepts. The purpose of this article is to explain a series of relationships between objects.

Inheritance

In the real world there are many objects that can be specialized. In OOP, a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP and is represented by a is-a relationship.

The following OO terms are commonly used names given to parent and child classes in OOP:

·       Superclass: Parent class.

·       Subclass: Child class.

·       Base class: Parent class.

·       Derived class: Child class

The most common real world sample to explain inheritance is the geometric shapes object model. Squares, circles, triangles, rectangles, pentagons, hexagons, and octagons are geometric shapes. The following figure shows a sample set of geometric figures:

Figure 1. Geometric shapes.

The concept of generalization in OOP means that an object encapsulates common state an behavior for a category of objects. The general object in this sample is the geometric shape. Most geometric shapes have area, perimeter, and color. The concept of specialization in OOP means that an object can inherit the common state and behavior of a generic object; however, each object needs to define its own special and particular state an behavior. In Figure 1, each shape has its own color. Each shape has also particular formulas to calculate its area and perimeter.

Inheritance makes code elegant and less repetitive. If we know that all shapes have color, should we program a color attribute for each shape? The answer is no! Would it be a better idea to create a shape class that has a color attribute and to make all the specialized shapes to inherit the color attribute? The answer is yes!

An object model for this sample could have a shape parent class and a derived class for each specific shape. The following UML class diagram shows the set of classes needed to model the geometric shapes sample. Observe the field, properties, and methods for each class:

 

Figure 2. The Shape class is the parent class. Square, Rectangle, and Circle are derived classes that inherit from Shape. The triangle-connector in the diagram represents an is-a relationship.

The .NET framework has many base classes. Everything is derived from System.Object. You can create almost anything you imagine using the built-in functionality provided in the .NET Framework Class Library.

To create a derived class in C#, the class declaration should be done as:

class child: parent 

To create a derived class in VB.NET, the class declaration should be done as:

Class child
Inherits
parent
End
Class

Multiple inheritance

Multiple inheritance is the possibility that a child class can have multiple parents. Human beings have always two parents, so a child will have characteristics from both parents.

In OOP, multiple inheritance might become difficult to handle because it allows ambiguity for the compiler. There are programming languages such as C++ that allow multiple inheritance; however, other programming languages such as Java and the .NET Framework languages do not allow multiple inheritance. Multiple inheritance can be emulated in .NET using Multiple Interface Inheritance, which I will explain in Part 3 of this series.

Sealed class

A sealed class is a class that does not allow inheritance. Some object model designs need to allow the creation of new instances but not inheritance, if this is the case, the class should be declared as sealed.

To create a sealed class in C#, the class declaration should be done as:

sealed class Shape

To create a sealed class in VB.NET, the class declaration should be done as:

NonInheritable Class Shape

Abstraction

Abstraction is “the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use” (Richard Gabriel).

An abstract class is a parent class that allows inheritance but can never be instantiated. Abstract classes contain one or more abstract methods that do not have implementation. Abstract classes allow specialization of inherited classes.

Figure 2 shows a Shape class, which is an abstract class. In the real world, you never calculate the area or perimeter of a generic shape, you must know what kind of geometric shape you have because each shape (eg. square, circle, rectangle, etc.) has its own area and perimeter formulas. The parent class shape forces all derived classes to define the behavior for CalculateArea() and CalculatePerimeter(). Another great example is a bank account. People own savings accounts, checking accounts, credit accounts, investment accounts, but not generic bank accounts. In this case, a bank account can be an abstract class and all the other specialized bank accounts inherit from bank account.

To create an abstract class in C#, the class declaration should be done as:

abstract class Shape

To create an abstract class in VB.NET, the class declaration should be done as:

MustInherit Class Shape

To following code shows a sample implementation of an abstract class:

/// C#
using System;
namespace
DotNetTreats.OOSE.OOPSamples
{
public
abstract class Shape
{
private
float _area;
private
System.Drawing.Color _color;
private
float _perimeter;
public
float Area
{
get
{
return
_area;
}
set
{
_area = value;
}
}
public
System.Drawing.Color Color
{
get
{
return
_color;
}
set
{
_color = value;
}
}
public
float Perimeter
{
get
{
return
_perimeter;
}
set
{
_perimeter = value;
}
}
public
abstract void CalculateArea();
public
abstract void

CalculatePerimeter();
}
}
Listing 1. The Shape abstract class in C#.
 

 

Polymorphism

Polymorphism allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. Polymorphism is a concept linked to inheritance and assures that derived classes have the same functions even though each derived class performs different operations.

Figure 2 shows a Rectangle, a Circle, and Square. All of them are shapes and as shapes their area and perimeter can be calculated; however, each shape calculates its area in a specialized way. Declaring a member as abstract allows polymorphism. The Shape class defines the CalculateArea() and CalculatePerimeter() methods as abstract, this allows each derived class to override the implementation of the parent’s methods.

To following sample code shows an implementation of a derived class (rectangle). The specific CalculateArea() and CalculatePerimeter() methods for the rectangle class illustrate polymorphism:

/// C#
using System;
namespace
DotNetTreats.OOSE.OOPSamples
{
class
Rectangle : Shape
{
private
float _height;
private
float _width;
public
rectangle(float height, float width)
{
_height = height;
_width = width;
}
public
float Height
{
get
{
return
_height;
}
set
{
_height = value;
}
}
public
float Width
{
get
{
return
_width;
}
set
{
_width = value;
}
}
public
override void CalculateArea()
{
this.Area = _height * _width;
}
public
override void

CalculatePerimeter()
{
this.Perimeter = (_height * 2) + (_width * 2);
}
}
}
Listing 2. Polymorphism represented in the Rectangle’s methods.
 

 

Virtual keyword

The virtual keyword allows polymorphism too. A virtual property or method has an implementation in the base class, and can be overriden in the derived classes.

To create a virtual member in C#, use the virtual keyword:

public virtual void Draw()

To create a virtual member in VB.NET, use the Overridable keyword:
Public Overridable Function Draw()
 

 

Override keyword

Overriding is the action of modifying or replacing the implementation of the parent class with a new one. Parent classes with virtual or abstract members allow derived classes to override them.

To override a member in C#, use the override keyword:

public override void CalculateArea()

To override a member in VB.NET, use the Overrides keyword:

Public Overrides Function CalculateArea()

Conclusion

Inheritance allows developers to manage a generalization and specialization relationship between objects. OOP concepts such as abstraction and polymorphism help to define better object models where object hierarchies are designed with reusability in mind. In this article, I examined the concept of inheritance, abstraction, and polymorphism. The third and last part of this series will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Courtesy: The Seo Guru, A Software Development Company, Best OOPS Blog Site, Link Submission, Thanks to Shopping  Site for Link Exchanging


Bookmark and Share