Chapter 61
Writing a Problem Domain Class Definition
Introduction to E-Business Technologies
ChapterHAPTER OVERVIEW
vOverview
In this chapter you will see how to design and write a class definition for Customer. This definition will include attributes and methods to store and retrieve the attribute values. To test the Customer class definition, you will write a second class, named TesterOne, to create instances of Customer and test the methods that access the attribute values. You will then write a third class, named TesterTwo, that duplicates the tasks in TesterOne but uses a GUI form instead of a module.
Lecture Topics / Page # / Teaching Suggestions in this ManualThe Early Development of the Internet / 2 / See Lecture Notes “Early Development of the Internet”
Advanced Research Projects (ARPA) / 2 / See Lecture Notes “Advanced Research Projects Agency”
ARPANET / 4 / See Lecture Notes “ARPANET”
Tech Case: The Packet-Switching Coincidence / 7 / See Lecture Notes “Packet-Switching Coincidence”
NFSNET / 9 / See Lecture Notes “NFSNET”
The Origins and Evolution of the World Wide Web / 10 / See Lecture Notes “Origins and Evolution of the World Wide Web”
Tech Case: From Memex to Xanadu / 12 / See Lecture Notes “From Memex to Xanadu”
Commercialization of the Internet and the World Wide Web / 13 / See Lecture Notes “Commercialization of the Internet and the World Wide Web”
The Origins of E-Business / 14 / See Lecture Notes “Origins of E-Business”
E-Business Models / 14 / See Lecture Notes “E-Business Models”
Tech Case: Checking the Sticker Price / 18 / See Lecture Notes “Checking the Sticker Price”
Business-to-Consumer (B2C) / 15 / See Lecture Notes “Business-to-Consumer”
Business-to-Business (B2B) / 19 / See Lecture Notes “Business-to-Business”
Business-to-Government (B2G) / 20 / See Lecture Notes “Business-to-Government”
Tech Case: These Boots are Made for Working / 22 / See Lecture Notes “These Boots are Made for Working”
Consumer-to-Consumer (C2C) / 23 / See Lecture Notes “Consumer-to-Consumer”
Consumer-to-Business (C2B) / 23 / See Lecture Notes “Consumer-to-Business”
E-Business Advantages and Disadvantages / 24 / See Lecture Notes “E-Business Advantages and Disadvantages”
CHAPTER OBJECTIVESObjectives
· Learn VB .NET naming conventions
· Develop a problem domain (PD) class definition
· Define attributes for a PD class
· Write methods and properties for a PD class
· Test a PD class
· Create an instance of a PD class
· Write a constructor method for a PD class
· Write a TellAboutSelf method for a PD class
· Write a Tester class as a Form
Describe the early technological development of the Internet
· Discuss the origins and evolution of the World Wide Web
· Identify the primary events that led to the commercialization of the Internet and the World Wide Web
· Define e-business models based on the commercial application of Internet technologies
KEY TERMSKey Terms
ARPA– Advanced research project Agency. Sponsored research at universities and corporations in areas deemed strategically important, including communications systems and compu
Ø accessibility
Ø accessor method
Ø argument
Ø assembly
Ø class definition
Ø class header
Ø client object
Ø constructor
Ø custom method
Ø default constructor
Ø event
Ø event handler
Ø event procedure
Ø Function procedure
Ø getter or get function
Ø parameterized constructor
Ø parameter
Ø procedure header
Ø procedure
Ø property
Ø scope
Ø server object
Ø setter or set method
Ø standard method
Ø Sub procedure
Explanation of Symbols
è Write a definition, concept or key point following the arrow.
______Fill in blank lines with a word or phrase to complete a definition, concept or key point.
choice1/choice2 Circle one of the choices.
E The pointing finger comes into play when you review your notes. It is a prompt to think of and write your own example(s) of a concept.
Early Development of the Internet
In the early days of the Internet, only scientists and researchers with UNIX programming skills could readily access Internet resources such as files and programs. In 1992, a team of young programmers at the University of Illinois Champaign-Urbana ’s National Center for Supercomputing Applications (NCSA) were determined to give users a tool to navigate the Internet and to encourage developers to create Internet content for nonscientific users. To do this, the team developed a software application for the Internet called Mosaic. The Mosaic application, which used pictures as well as text to help users find Internet resources, quickly became very popular in the university-based UNIX environment. In 1993, its first year of availability, the number of Mosaic users went from 12 to more than one million. Still, in the early 1990s most people familiar with the Internet thought it was impossible to make money using it.
Today, millions of people use the Internet to shop for goods and services, listen to music, view artwork, conduct research, get stock quotes, keep up to date with current events, and communicate with others. At the same time, more and more businesses are using the Internet to conduct their business activities.
VB .NET Naming Conventions
The conventions for writing identifiers, which are the names assigned to classes, class definitions, attributes, and methods, are as follows:
· Class names start with a ______. Examples of class names are Customer and Boat.
· Attribute names begin with a ______, but subsequent words comprising the name are ______. Examples of attribute names are address and phoneNo.
· Method names begin with an ______, and subsequent words are ______. Method names usually contain an ______— ______phrase describing what the method does. Examples of method names are GetPhoneNo, SetAddress, and ComputeLease.
Developing a PD Class Definition
The Bradshaw Marina system has several PD classes, such as Customer, Boat, Slip, and Dock, and that there are interactions and relationships among many of these.
To begin developing the marina’s system, a ______would need to be written for each of the PD classes. This will define the ______and ______that make the objects behave as required by the system.
The structure of a class definition consists of a ______followed by ______definitions and then ______code. The class header is a line of code that identifies the class and some of its characteristics. The end of the class is indicated by an ______statement.
The class header for the Customer definition is è
The keyword ______indicates that this class has public accessibility, meaning anyone can use it. The keyword ______indicates that this line of code is a class header, and ______establishes the class name.
Defining Attributes
An attribute definition is written in the same way as a variable is declared, except the keyword ______is used instead of Dim.
The code to define the name Customer attribute is è
When defining attributes, the accessibility of a variable is defined as
· Public which allows ______
· Private, which ______
· ______, which allows subclasses to have direct access to the variable
______, which permits classes within the same assembly direct access. An assembly is a collection of one or more projects deployed as an application.
A class generally provides ______methods which can be invoked by other classes to access the Private attribute values..
Writing Methods and Properties
Problem domain classes do not function alone. Instead, their methods provide services to other objects in a system. In OO systems the interaction of objects is simulated when one object sends a message to another object to invoke a method. The object sending the message becomes the client object, while the object receiving the message is the server object. The client sends a message invoking a server method, perhaps sending along values in the form of arguments. The server method performs the requested task, and may return a value to the client.
Methods are written using procedures. VB .NET has two types of procedures: Sub procedures and Function procedures. The difference between a Sub procedure and a Function procedure is that a Sub procedure does/does not return a value and a Function procedure does/does not.
A Sub procedure definition begins with a procedure header followed by one or more statements.
accessibility Sub procedurename(parameter list)
method statements
End Sub
Similar to a Sub procedure, a Function procedure definition begins with a procedure header followed by one or more statements.
accessibility Function procedurename(parameter list) As datatype
method statements
End Function
Accessor methods are often called ______methods and are typically shown/not shown on class diagrams. In contrast, methods the programmer writes to perform other functions are called ______methods and are shown/not shown on class diagrams.
There are two types of accessor methods: those that ______attribute values and those that ______attribute values. Accessors that retrieve values are called ______accessor methods, and are named with the prefix “______” followed by the attribute name. Similarly, accessor methods that change attribute values are called ______accessor methods, and are named with the prefix “______” followed by the attribute name.
A ______can also be written to set and get attribute values, which is similar to a method, but appears as an ______to a client.
Testing a PD Class
To simulate the way a client might send messages, a small tester class can be written. For example, a tester class named TesterOne can be written to invoke methods in the Customer class definition. In this example, TesterOne is a client and Customer is the server. TesterOne is the startup object for the project and its Main method begins execution when it is loaded.
Creating an Instance
To create an instance of the Customer class, a ______reference variable must be defined as è
To create the instances of the Customer class, the following code is used è
An instance of the Customer class, called firstCustomer, can be created using a single statement as è
After the class is instantiated, the variable firstCustomer points to the newly created Customer instance. FirstCustomer is an example of a ______variable. The attributes of the Customer instance initially have no values. The instance attributes can be populated either by invoking setter methods or properties. For example, the CustomerName property can be used to populate the name attribute as follows è
The SetPhoneNo Setter methods can be used to populate the customer’s phone number with è
To verify that the setter methods worked correctly, code can be written to retrieve the name and phone number attribute values from the customer instance and display them, using the WriteLine method as è
Writing a Constructor Method
A constructor is a special method that è
The constructor is unique in that it is named ______and is written as a Sub procedure because ______. Even if the programmer does not write a constructor, VB .NET creates a default constructor that does not do anything. The default constructor consists of only a header and an End Sub statement.
A constructor created by the programmer is called a ______constructor because ______that are used to populate the instance attributes. The constructor should then invoke the setter methods to populate the attributes.
Writing a TellAboutSelf Method
Good design suggests that changes in one class should be insulated from outside classes to reduce maintenance requirements. To accomplish this, a single PD method can be written which can be invoked to retrieve all of the attribute values for an instance. An appropriate name for this method is TellAboutSelf. It will retrieve all of the attribute values, place them in a ______, and then return it to the invoking client. This method should have public accessibility, and because this method will return a value, it should be written as a Function procedure.
Quick Quiz
Traditional business conducted in physical buildings is referred to as ______marketspaces.
Answer: Truebrick-and-mortar
True or False: E-Commerce transactions include buying and selling products and services, delivery of information, providing customer service, collaborating with business partners, and enhancing productivity within organizations.
Answer: Truebrick-and-mortar
Priceline.com is an example of what type of E-Business model?
Answer: Consumer-to-Business, C2B
What are retailers that combine both brick-and-mortar and E-Commerce marketspaces called?
Answer: brick-and-click companies
True or False: Extranets allow participating Business-to-Business companies to view each other’s data and to complete business transactions on-line.
Answer: True
What are B2B Web sites that bring multiple buyers and sellers together in a virtual centralized marketspace called?
Answer: B2B exchanges
True or False: The Business-to-Government model is similar to the B2B exchange model.
Answer: True
In the ______marketspace, consumers sell directly to other consumers via online classified ads and auctions.
Answer: Consumer-to-Consumer, C2C
What is the “reverse auction” or “demand collection model” where buyers to name their own price for a specific good or service called?
Answer: Consumer-to-Business, C2B
1
1-