An Introduction to Programming and VB.NET Chapter 1 An Introduction to Programming and VB.NET
Learning Objectives Understand importance of information systems in organizations List and discuss the six computer operations Discuss the role of computer programs and programming languages Understand concepts of object-oriented programming in Windows and in VB .NET List and discuss the steps in developping an application in VB .NET
Information System The combination of technology (computers) and people that enables an organization to collect data, store them, and transform them in useful information
Software List of instructions: Programs Creation of those instructions: Programming Programming is part of :System Development
Development Identify the problem Analyze the system Design the system Implementation (construction)
Computer Operations Input data Store data in internal memory Perform arithmetic on data Compare two values and select an action accordingly Repeat a group of actions a number of times Output the results of precessing
The Six Computer Operations
Input Data From a keyboard From a mouse From barcode reader From data files From sensors
Store Data in Memory Memory location are called Variables Having data in memory allows rapid access Data in memory is not static, it is allowed to be changed by the program
Perform Arithmetic on Data Includes Addition Subtraction Division Multiplication Most manipulation on data in memory can be seen as arithmetic manipulation
Compare and Select Action Compare two numerical values If A>B then do something … Compare textual values If Name1 = Name2 then …
Repeat Actions a Number of Times Keep checking if the next name in a list is the same as that of the user Keep adding item prices in a grocery list to return the total The computer is king of repetitions!
Output Results To be useful, the result must be made accessible On a monitor Printed on paper Saved in a file on disk
Programs and Programming Solution must be a list of steps, this is the algorithm The algorithm is not bound to a programming language, see it as the “English” version of the program The algorithm is more important than the language
Control Structures Sequence : ordered list of operations Decision : control the flow of operation Repetition : repeat operations until a certain exit condition is met
Programming in Windows Windows is based on events A key being pressed is an event The mouse moving is an event Clicking the mouse is an event Double clicking is an event
VB .NET Language It allows event-driven programming It is object-oriented Everything revolves around objects Each object has properties and methods Properties are characteristics Methods are actions the object can take Some objects can raise events, i.e. notify other objects that something happened
Characteristics of OOP Encapsulation black box view of an object what is accessible is key, not how it is made accessible Inheritance allows for specialization of classes Polymorphism Different classes (objects) being allowed to be accessed the same way Dog.Run() Cat.Run()
Programming in VB .NET Define problem Create interface Develop logic for action objects Write and test code for action objects Test overall project Document project in writing
Case Study: Vintage DVDs Want to calculate the taxes and total amount due on a DVD rental
Step 1: Definition of Problem Identify input Price of DVD Identify output Taxes Amount due Identify actions to take Calculate Quit the program
Step 2: Creation of Interface Make a sketch by hand Decide on the objects required TextBoxes, Buttons, Labels, etc Drag and drop the objects on the form The layout should be logical Group related objects together The layout should be eye pleasing Avoid to many fonts and loud colors
Step 3: Logic for Action Objects IPO (Input/Processing/Output) Table For each object, it shows the input, the output, and what processing needs to be done to get from one to the other Pseudo code Step by step instructions in the English language rather than in a given programming language. Pseudo code is more natural to the human and is easy to translate to programming language
Step 4: Write and Test Code Translate pseudocode or IPO tables into the syntax of the programming language Test the code by “running” it in the MSDE Test often, every few lines of code written Make use of test data Test ideal conditions Test problematic conditions
Step 5: Test Overall Project Test communication between objects Make sure the program meets requirements
Step 6: Document Project Documentation The written description of the software that aid users and other programmers Internal documentation Comments in program to explain the purpose and logic of the code Comments are as important as the code Comments allow for maintenance of the code Comments start with an apostrophe ( ‘ )
Final Remarks The development process should be seen as iterative, you will not get the final solution on the first try You should Design a little Code a little Test a little Document a little And then repeat the process again and again
Copyright 2004 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the information herein