chapter 2 designing applications l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 2: Designing Applications PowerPoint Presentation
Download Presentation
Chapter 2: Designing Applications

Loading in 2 Seconds...

play fullscreen
1 / 49

Chapter 2: Designing Applications - PowerPoint PPT Presentation


  • 143 Views
  • Uploaded on

Chapter 2: Designing Applications. Programming with Microsoft Visual Basic .NET, Second Edition. Planning an Object-Oriented (OO) Application in Visual Basic .NET Lesson A Objectives. Plan an OO application in Visual Basic .NET Complete a TOE (Task, Object, Event) chart

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 2: Designing Applications' - wilbur


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 2 designing applications

Chapter 2: Designing Applications

Programming with Microsoft Visual Basic .NET, Second Edition

planning an object oriented oo application in visual basic net lesson a objectives
Planning an Object-Oriented (OO) Application in Visual Basic .NET Lesson A Objectives
  • Plan an OO application in Visual Basic .NET
  • Complete a TOE (Task, Object, Event) chart
  • Follow the Windows standards regarding the layout and labeling of controls

Programming with Microsoft Visual Basic .NET, Second Edition

solving the problem using a procedure oriented approach
Solving the Problem Using a Procedure-Oriented Approach
  • Emphasis of a program is on how to accomplish a task
  • A flowchart uses standardized symbols to show the steps needed to solve a problem
  • Pseudocode uses English phrases to describe the required steps
  • User has little, if any, control

Programming with Microsoft Visual Basic .NET, Second Edition

solving the problem using an object oriented oo approach
Solving the Problem Using an Object-Oriented (OO) Approach
  • Emphasis of a program is on the objects included in the interface and the events that occur on those objects
  • You will use a TOE (Task, Object, Event) chart to assist you in planning your object-oriented programs
  • User has a lot of control

Programming with Microsoft Visual Basic .NET, Second Edition

solving the problem using an object oriented oo approach continued
Solving the Problem Using an Object-Oriented (OO) Approach (continued)

Sample TOE chart

Programming with Microsoft Visual Basic .NET, Second Edition

creating an oo application
Creating an OO Application

Figure 2-6: Processes used by a builder and a programmer

Programming with Microsoft Visual Basic .NET, Second Edition

planning an oo application
Planning an OO Application
  • Actively involve the user in the planning phase
  • Planning an OO application requires the following steps:
    • Identify the tasks the application needs to perform
    • Identify the objects to which you will assign those tasks
    • Identify the events required to trigger an object into performing its assigned tasks
    • Draw a sketch of the user interface

Programming with Microsoft Visual Basic .NET, Second Edition

identifying the application s tasks
Identifying the Application’s Tasks
  • What information, if any, will the application need to display on the screen and/or print on the printer?
  • What information, if any, will the user need to enter into the user interface to display and/or print the desired information?
  • What information, if any, will the application need to calculate to display and/or print the desired information?

Programming with Microsoft Visual Basic .NET, Second Edition

identifying the application s tasks continued
Identifying the Application’s Tasks (continued)
  • How will the user end the application?
  • Will previous information need to be cleared from the screen before new information is entered?

Programming with Microsoft Visual Basic .NET, Second Edition

identifying the objects
Identifying the Objects
  • After completing the Task column of the TOE chart, you then assign each task to an object in the user interface
  • You use a label control to display information that you do not want the user to change
  • You use a button control to perform an action immediately after it is clicked by the user
  • You use a text box to give the user an area in which to enter data

Programming with Microsoft Visual Basic .NET, Second Edition

identifying the events
Identifying the Events
  • Text boxes and Label controls display their contents automatically - no special event is needed
  • The remaining objects are the three buttons: uiCalcButton, uiClearButton, and uiExitButton
  • Have the buttons perform their assigned tasks when they are clicked by the user

Programming with Microsoft Visual Basic .NET, Second Edition

drawing a sketch of the user interface
Drawing a Sketch of the User Interface
  • In Western countries, organize the user interface so that the information flows either vertically or horizontally
  • In a vertical arrangement
    • The information flows from top to bottom
    • The essential information is located in the first column of the screen
    • Secondary information is placed in subsequent columns

Programming with Microsoft Visual Basic .NET, Second Edition

drawing a sketch of the user interface continued
Drawing a Sketch of the User Interface (continued)
  • In a horizontal arrangement
    • The information flows from left to right
    • The essential information is placed in the first row of the screen
    • Secondary information placed in subsequent rows
  • You can use white space, a GroupBox control, or a Panel control to group related controls together

Programming with Microsoft Visual Basic .NET, Second Edition

drawing a sketch of the user interface continued14
Drawing a Sketch of the User Interface (continued)
  • If buttons appear in the interface, they should be positioned either in a row along the bottom of the screen, or stacked in either the upper-right or lower-right corner
  • Each text box and button control should be labeled so the user knows the control’s purpose
  • The Windows standard is to use sentence capitalization for identifying labels

Programming with Microsoft Visual Basic .NET, Second Edition

building the user interface lesson b objectives
Building the User InterfaceLesson B Objectives
  • Build the user interface using TOE chart and sketch
  • Follow the Windows standards regarding the use of graphics, color, and fonts
  • Set the BorderStyle property
  • Add a text box to a form

Programming with Microsoft Visual Basic .NET, Second Edition

building the user interface lesson b objectives continued
Building the User InterfaceLesson B Objectives (continued)
  • Lock the controls on the form
  • Assign access keys to controls
  • Use the TabIndex property

Programming with Microsoft Visual Basic .NET, Second Edition

preparing to create the user interface
Preparing to Create the User Interface
  • Maintain a consistent margin of two or three dots from the edge of the window
  • Position related controls on succeeding dots
  • Controls that are not part of any logical grouping may be positioned from two to four dots away from other controls
  • Try to create an interface that no one notices

Programming with Microsoft Visual Basic .NET, Second Edition

including graphics in the user interface
Including Graphics in the User Interface
  • The human eye is attracted to pictures before text; include a graphic only if it is necessary
  • If the graphic is for aesthetics only, use a small graphic and place it so as not to distract the user

Programming with Microsoft Visual Basic .NET, Second Edition

including different fonts in the user interface
Including Different Fonts in the User Interface
  • Use 8, 10, or 12 point fonts for the elements in the user interface
  • Use only one or two font sizes
  • Use only one font type for all of the text
  • Avoid italic and underlining
  • Limit the use of bold text to titles, headings, and key items

Programming with Microsoft Visual Basic .NET, Second Edition

including color in the user interface
Including Color in the User Interface
  • Use either white, off-white, light gray, pale blue, or pale yellow for an application’s background, and use black for the text
  • Always use dark text on a light background
  • Never use a dark color for the background or a light color for the text
  • Limit the number of colors (other than white, black, and gray) to three

Programming with Microsoft Visual Basic .NET, Second Edition

the borderstyle property
The BorderStyle Property
  • BorderStyle property determines the style of a control’s border
  • Set the BorderStyle property of text boxes to Fixed3D
  • Set the BorderStyle property of labels that identify other controls to None
  • Set the BorderStyle property of labels that display program output to FixedSingle

Programming with Microsoft Visual Basic .NET, Second Edition

adding a text box control to the form
Adding a Text Box Control to the Form
  • A text box control provides an area in the form where the user can enter data
  • Add the missing text box control to the form and then set its properties

Programming with Microsoft Visual Basic .NET, Second Edition

locking the controls on a form
Locking the Controls on a Form
  • Once you have placed all of the controls in the desired locations, lock them so you do not inadvertently move them
  • Once locked, you cannot move them until you unlock them; you can, however, delete them

Programming with Microsoft Visual Basic .NET, Second Edition

assigning access keys
Assigning Access Keys
  • An access key allows the user to select an object by using the Alt key in combination with a letter or number
  • Each access key must be unique
  • You can assign an access key to any control that has a Caption property

Programming with Microsoft Visual Basic .NET, Second Edition

assigning access keys continued
Assigning Access Keys (continued)
  • Place an & to the left of the desired letter in the Text property
  • To give keyboard access to a text box, assign an access key to its identifying label, then set the label’s TabIndex value to one less than the text box’s TabIndex value

Programming with Microsoft Visual Basic .NET, Second Edition

setting the tabindex property
Setting the TabIndex Property
  • The TabIndex property determines the order in which a control receives the focus when the user presses either the Tab key or an access key while the application is running
  • When a control has the focus, it can accept user input
  • To determine the appropriate TabIndex settings for an application, make a list of the controls that can accept user input

Programming with Microsoft Visual Basic .NET, Second Edition

setting the tabindex property continued
Setting the TabIndex Property (continued)
  • The list should reflect the order in which the user will want to access the controls
  • After listing the controls, assign each control in the list a TabIndex value, beginning with the number 0
  • You can use the Properties list to set the TabIndex property for each control; or, you can use the Tab Order option on the View menu

Programming with Microsoft Visual Basic .NET, Second Edition

coding testing debugging and documenting the application lesson c objectives
Coding, Testing, Debugging, and Documenting the ApplicationLesson C Objectives
  • Use the TOE chart to code the application
  • Use pseudocode to plan an object’s code
  • Write an assignment statement
  • Use the Focus method

Programming with Microsoft Visual Basic .NET, Second Edition

coding testing debugging and documenting the application lesson c objectives continued
Coding, Testing, Debugging, and Documenting the ApplicationLesson C Objectives (continued)
  • Include internal documentation in the code
  • Write arithmetic expressions
  • Use the Val and Format functions

Programming with Microsoft Visual Basic .NET, Second Edition

coding the application
Coding the Application
  • Instructions are called code
  • The process of writing the instructions is called coding
  • Use pseudocode to help you plan the code
  • Internally document the code by placing an apostrophe before the comment in the Code window

Programming with Microsoft Visual Basic .NET, Second Edition

coding the clear screen button
Coding the Clear Screen Button
  • According to the TOE chart, the Clear Screen button is assigned the task of clearing the screen for the next order
  • A zero-length string (empty string), is a pair of quote marks with nothing between them: “”
  • Assigning a zero-length string to the Text property of a control removes its contents

Programming with Microsoft Visual Basic .NET, Second Edition

coding the clear screen button continued
Coding the Clear Screen Button (continued)
  • The pseudocode shown in Figure 2-25 represents the steps the Clear Screen button needs to prepare the screen for the next order
  • The programmer uses the pseudocode as a guide when coding the application
  • You use an assignment statement, which is simply a Visual Basic .NET instruction, to set the value of a property while an application is running

Programming with Microsoft Visual Basic .NET, Second Edition

coding the clear screen button continued33
Coding the Clear Screen Button (continued)

Figure 2-25: Steps for the Clear Screen button

Programming with Microsoft Visual Basic .NET, Second Edition

assigning a value to a property during run time
Assigning a Value to a Property During Run Time
  • Use the syntax [Me.]object.property=expression to set the value of an object’s property while an application is running
  • In an assignment statement, the equal sign (=) is called the assignment operator
  • The value of the expression on the right side of an = is assigned to the object and property that appears on the left side

Programming with Microsoft Visual Basic .NET, Second Edition

using the focus method
Using the Focus Method
  • A method is a predefined procedure
  • The Focus method allows you to move the focus to a specified control
  • The syntax of the Focus method: [Me.]object.Focus()

Programming with Microsoft Visual Basic .NET, Second Edition

internally documenting the program code
Internally Documenting the Program Code
  • Visual Basic .NET provides an easy way to document a program internally
  • Place an apostrophe (‘) before the statement you want treated as a comment
  • Visual Basic .NET ignores everything that appears after the apostrophe on that line

Programming with Microsoft Visual Basic .NET, Second Edition

writing arithmetic expressions
Writing Arithmetic Expressions
  • The precedence numbers indicate the order in which Visual Basic .NET performs the operation in an expression
  • Operations with a lower precedence number are performed before operations with a higher precedence number

Programming with Microsoft Visual Basic .NET, Second Edition

writing arithmetic expressions continued
Writing Arithmetic Expressions (continued)
  • Use parentheses to override the precedence
  • Use the integer division operator (\) to divide two integers and return the result as an integer
  • The modulus operator returns the remainder after integer division

Programming with Microsoft Visual Basic .NET, Second Edition

writing arithmetic expressions continued39
Writing Arithmetic Expressions (continued)

Figure 2-34: Arithmetic operators and their order of precedence

Programming with Microsoft Visual Basic .NET, Second Edition

coding the calculate order button
Coding the Calculate Order Button
  • The Calculate Order button is responsible for:
    • Calculating both the total number of skateboards ordered and the total price of the order
    • Displaying the calculated amounts in the uiTotalBoardsLabel and uiTotalPriceLabel controls
  • The instructions to accomplish the Calculate Order button’s tasks should be placed in the button’s Click event procedure

Programming with Microsoft Visual Basic .NET, Second Edition

coding the calculate order button continued
Coding the Calculate Order Button (continued)

Figure 2-35: Pseudocode for the Calculate Order button

Programming with Microsoft Visual Basic .NET, Second Edition

the val function
The Val Function
  • Like a method, a function is a predefined procedure that performs a specific task
  • The Val function temporarily converts a string to a number, and then returns the number
  • Syntax of the Val function is Val(string), where string is the string you want treated as a number

Programming with Microsoft Visual Basic .NET, Second Edition

using the format function
Using the Format Function
  • Syntax: Format(expression, style)
  • Expression specifies the number, date, time, or string whose appearance you want to format
  • Style is either the name of a predefined Visual Basic .NET format style or a string containing symbols that indicate how you want the expression displayed

Programming with Microsoft Visual Basic .NET, Second Edition

testing and debugging the application
Testing and Debugging the Application
  • Test an application by starting it and entering some sample data
  • Use both valid (expected) and invalid (unexpected) test data

Programming with Microsoft Visual Basic .NET, Second Edition

testing and debugging the application continued
Testing and Debugging the Application (continued)
  • Debugging: locating errors in the program
  • Errors can be either syntax or logic
  • Most syntax errors are simply typing errors
  • Logic errors occur when you enter an instruction that does not give the expected results

Programming with Microsoft Visual Basic .NET, Second Edition

assembling the documentation
Assembling the Documentation
  • Assembling the documentation refers to putting in a safe place your planning tools and a printout of the application’s interface and code
  • Your planning tools include:
    • The TOE chart
    • Sketch of the interface
    • Flowcharts and/or pseudocode

Programming with Microsoft Visual Basic .NET, Second Edition

summary
Summary
  • Steps to create an OO application:
    • Meet with the client
    • Plan the application
    • Build the user interface
    • Code the application
    • Test and debug the application
    • Assemble the documentation

Programming with Microsoft Visual Basic .NET, Second Edition

summary continued
Summary (continued)
  • To control the border around a label control, set the label control’s BorderStyle property
  • To assign an access key to a control, type an ampersand (&) in the Text property of the control’s caption or identifying label
  • To set the tab order, set each control’s TabIndex property to a number that represents the order in which you want the control to receive the focus

Programming with Microsoft Visual Basic .NET, Second Edition

summary continued49
Summary (continued)
  • To assign a value to the property of an object while an application is running, use an assignment statement that follows the syntax:[Me.]object.property = expression
  • To document Visual Basic code with comments, begin the comment with an apostrophe (’)
  • To temporarily convert a string to a number, use the Val function

Programming with Microsoft Visual Basic .NET, Second Edition