Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Newsletter
Enter your email address to receive full length articles at Stardeveloper:


Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (11)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)
Log In
UserName Or Email:

Password:

Auto-Login:

Miscellaneous Links
  Submit Article
Stardeveloper RSS Feed
Hosted by Securewebs.com
 
Home : .NET : ASP : Beginning E-Commerce : Object Oriented Programming
 
RSS - Read full length articles at Stardeveloper using Stardeveloper RSS Feed RSS

Beginning E-Commerce : Object Oriented Programming

by Wrox Press.

Most modern software can be controlled programmatically through its exposed object models. In fact, most of the applications you use everyday on your Windows PC have an object model, including Microsoft Word, Excel, and Internet Explorer.

The careful design of these object models is the key to building good software. We're now going to embark on the design, and start the construction, of the business tier for Jo's Coffee. This business tier will consist of a number of objects whose interrelationships are defined by their position in the object model. Implementing the object model will define what we can do within the application. During the course of the chapter we'll be discussing the object-oriented approach to programming as well as ActiveX and COM technology; all topics that directly influence the way we construct the application.

It is great to put up e-commerce sites to help your business grow.

There are going to be three basic parts to this chapter – we're going to start off with the theory (concepts behind object-oriented programming, COM and ActiveX) then we'll move onto see how that theory influences our design of the object model for Jo's Coffee. Finally we'll begin to implement the design in the WroxCommerce VB project.

More specifically our path through the chapter will involve:

  • q Looking at object-oriented programming q Understanding a little about components
  • q Designing an object model for Jo's Coffee
  • q Creating a project in Visual Basic q Building the Visit object
  • q Building the Database object
  • Building the Catalog object

Let's start by looking at object-oriented programming.

Object-Oriented Programming
Object-oriented programming (OOP) is based on the idea that real-world entities or relationships can be represented in code as objects. These code objects have associated with them data and behave in certain ways when asked to. Objects can be linked together to form programs and applications.

Objects may be regarded as black-boxes – the user of an object may know what information needs to be input to the object to get a certain result out, but does not need to know what process goes on inside the object.

OK, let's step back from that rather terse summary and use the metaphor of a television set to explain this concept. We're all pretty conversant with televisions in so much as we know if we input a signal (from aerial, cable, video or wherever) and we use the control set properly we'll get sound and vision. Pushing the buttons allows us to vary the channel we watch, raise or lower the volume, alter the picture brightness, and so on. Most of us don't know the precise workings of the electronics that control the TV, and neither do we care, because we know enough to be able to control it.

Object Behavior
In the first paragraph we said that objects contain data and have behavior; in programming data is represented as variables while behavior is represented by terms familiar to all VB programmers; properties, methods and events. So to continue our TV analogy we could have a property called channel which you could query to discover what channel was being displayed, or alternatively you could set that property to actually change the channel. Note, a property is different to the underlying data – in the case of the channel property the underlying variable may be the actual frequency of the input signal that gives the picture corresponding to that channel number. Methods describe something the object can do, so our television may have IncrementVolumeOneStep or SwitchToVideo methods that are invoked in response to input from the control set. Events occur when an action or state occurs, so the event of pushing the Increase Volume button would fire the IncrementVolumeOneStep method.

Incidentally, the process of objects hiding their internal design and data from the outside world is termed encapsulation. It means an object can hide data and not allow it to be accessed. So on a TV there maybe a TVMustNotBeOnForLongerThan property that controls the maximum length of time a TV can be on before it automatically turns off to ensure it doesn't overheat.

An Object Example
An Object Example

The properties, methods, and events an object has form the interface through which that object can be manipulated.

All this is very familiar in VB where a control like a CommandButton is an object and has, for example, a Caption property and a Click event to which you can attach a method. It acts as a black-box, as you the programmer do not have to worry how the button responds to the click input or how it looks – that has been sorted out for you.

Classes
A class is basically a template from which we stamp out objects (like a biscuit punch) with each created object being termed an instance of the class and the process of creating the object being termed instantiation. In Visual Basic, classes are defined using class modules (in C++, they are simply known as a class).

An Object Example
An Object Example

OOP in Action
The vast majority of object-oriented programming work is concerned with building objects that have no user interface. These objects provide some function to an application. Imagine you are working on a development project in a team and you need access to a billing system that your company owns. One of your colleagues has built a set of objects for talking to this billing system, but it is used on another application. In an object-oriented world, if your colleague has done their job properly, they can give you a copy of the objects, you can plug them into your application and now your application code has access to a billing system through those objects. You haven't had to learn anything about how the billing system works; you've just plugged the objects in.

Let's say our colleague gives us their class module called BillingSystem, (and provides us with information about its properties, methods, and events) in VB we can create instances of it like this:

Dim MyBillingSystem
Set MyBillingSystem = New BillingSystem

Once we've created a billing system object, we can use it:

MyBillingSystem.BillCustomer "Neil", 
"Mcevoy", "$500", "1/27/2000"

 ( 12 Remaining ) Next

Buy This Book From Amazon
Title: Beginning E-Commerce with Visual Basic, ASP, SQL Server 7.0 and MTS
Publisher: Wrox Press Inc
Price: $39.99
Pages: 600
DatePublished: March 2000



Comments/Questions ( Threads: 2, Comments: 5 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. modifying my asp script
  2. How to execute asp file from stored procedure ( 3 Replies ) This thread contains 2 replies by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed.

 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.