Your Project Is A Very Simple Example of The Classic Three-Tier Architecture

The Three-Tier Architecture breaks an application's design into
three distinct layers. The top layer is the Presentation Layer. This
is the layer that the user sees. It is also known as a Graphic User
Interface (GUI).
The Presentation Layer
The first step in creating the Presentation Layer is to lay our
your components using Visual Basic's Designer. I have several images
showing the layout of components for the Presentation Layer. Lay out your
components to resemble those in the images. Name them as I have.
Click on the thumbnails
below to enlarge each image.
Each imagine shows you the layout of controls for the Presentation Layer
of your final project. The names of the controls are included as
text. |
View of the entire form. |
The "File" drop down menu and its menu items. |
The "Help" drop down menu and its menu items. |
The Business Logic Layer
The primary tasks of your application is to permit the user to
open a file, edit the file, encrypt the file and save the file. Since the
application is intended to be a kind of document editor, it makes sense to view
the Business Logic Layer of your application in terms of the manipulation of
documents.
The first step in the Business Logic Layer, therefore, is to
design a document class. The document class will act as a template for
creating and managing documents for your application.
In addition to being simple documents, our documents may also be
encrypted. We could make our application more elaborate by creating cypher
object's tasked with encrypting and decrypting data. If you wish to
develop your project, for your own use, beyond the final project, then you may
wish to consider following that path. However, with the goal of
simplifying the final project, we will consider encryption and decryption to be
behaviors of our document rather than behaviors of a different object applied to
our document.
When designing our document class, we should ask ourselves the
following questions:
-
What is a document?
-
What kind of information does a document hold?
-
What kinds of operations can a document perform?
I suggest the following answers to the above questions:
-
A document is an object that stores information intended for
presentation to the user.
-
Our document will hold text. It will need to know the
name and location of the file where it is stored. It will need to know
where to present its text to the user.
-
Our document can retrieve itself from a file, save itself to
a file, allow itself to be edited, encrypt itself and decrypt itself.
Given the above question and answers, I propose the following:
Details of the Document Class
|
Member Variables
|
Properties
|
Methods
|
| mtxtDisplayBox
The Text Box within the Presentation Layer where the
document is displayed. |
|
Open
Opens the file corresponding to the document loading
the file's text into the document object. |
| mstrFileName
The name of the file that stores the document. |
FileName
Returns the name of the file (mstrFileName) |
Save
Writes the contents (mstrFileText) of the document to
the file. |
| mstrCurrentDirectory
The directory where the file that stores the document
resides. |
CurrentDirectory
Returns the current directory (mstrCurrentDirectory). |
Update
Given a string, updates the contents (mstrFileText) of
the document to be the same as the given string. |
| |
FullFilePath
Returns the full file path:
mstrCurrentDirectory & "\" & mstrFileName |
Display
Displays the contents of the document (mstrFileText)
on the text box (mtxtDisplayBox). |
| |
FileAssigned
Returns True if both the file name and current
directory have been assigned. Otherwise it returns False. |
Encrypt
Given a key (or passcode) encrypts the document. |
| mstrFileText
A string containing all of the text in the document. |
FileText
Returns the text of the document (mstrFileText). |
Decrypt
Given a key (or passcode) decrypts the document. |
| mblnModified
A boolean indicating whether or not the document has
been modified since the last time it was opened or saved. |
Modified
Returns True if the file has been modified since it
was saved or opened. |
IsEncrypted
Returns True if the document is encrypted and False if
the document is not encyrpted. |
The Data Layer