53
BIS305: Advanced Business Programming Introduction Toru Sakaguchi, Ph.D.

BIS305: Advanced Business Programming Introduction

  • Upload
    guri

  • View
    21

  • Download
    1

Embed Size (px)

DESCRIPTION

BIS305: Advanced Business Programming Introduction. Toru Sakaguchi, Ph.D. Chapter 1: Introduction. Introduction to Programming the .NET Framework. Introduction to Software Development. The software development life cycle consists of a sequence of well-defined steps Problem identification - PowerPoint PPT Presentation

Citation preview

Page 1: BIS305: Advanced Business Programming Introduction

BIS305: Advanced Business Programming

Introduction

Toru Sakaguchi, Ph.D.

Page 2: BIS305: Advanced Business Programming Introduction

Chapter 1: Introduction

• Introduction to Programming

• the .NET Framework

Page 3: BIS305: Advanced Business Programming Introduction

Introduction to Software Development

• The software development life cycle consists of a sequence of well-defined steps– Problem identification– System design– System implementation– System documentation– System testing– System deployment– Postimplementation audit

Page 4: BIS305: Advanced Business Programming Introduction

System Analysis Methodologies

• Pseudocode uses English-like statements to depict an application’s actions

• Top-down design (HIPO chart) is used to subdivide general tasks into more specific tasks

• Flowcharting uses graphical symbols to depict an application’s actions

• The Unified Modeling Language (UML) supplies several graphical templates to model a system

Page 5: BIS305: Advanced Business Programming Introduction

The Evolution of Programming Languages

• Programming languages can be categorized into four generations– Machine languages (1st generation)– Assembly languages (2nd generation)– Machine independent languages (3rd generation)– Natural languages (4th generation)

Page 6: BIS305: Advanced Business Programming Introduction

Figure 1-14: Relationship Between Assembly Language and Machine Language

Page 7: BIS305: Advanced Business Programming Introduction

Figure 1-15: Compiling Third-generation Programs

Page 8: BIS305: Advanced Business Programming Introduction

Compiling a .NET Program

• Visual Studio compiles a program into machine independent assembly language called intermediate language (IL)

• IL gets translated into executable code using the just-in-time compiler (JIT)– The process is automatic

Page 9: BIS305: Advanced Business Programming Introduction

Introduction to Object-oriented Programming

• Hardware costs are falling but software development costs are rising

• Software systems are becoming increasingly complex

• Object-oriented programming attempts to reduce software costs through code reuse

Page 10: BIS305: Advanced Business Programming Introduction

Characteristics of Object-oriented Programming

• Objects are created from classes– A class is a template or blueprint for an object– A class describes the data stored in the class

and the actions performed by the class

• Multiple objects can be created from the same class

Page 11: BIS305: Advanced Business Programming Introduction

Figure 1-17: Relationship Between a Class and Objects Created From the Class

Page 12: BIS305: Advanced Business Programming Introduction

Characteristics of Object-oriented Programming Languages

• Encapsulation: Data and processes are coupled together

• Inheritance: A new class can be created from an existing class

• Information hiding: Some information is hidden in a class while other information is exposed to the developers using the class

• Polymorphism: members have multiple forms

Page 13: BIS305: Advanced Business Programming Introduction

The Visual Studio Implementation of Object-oriented Programming

• The interface of a class is the formal specification of the data stored in the class and the actions supported by the class

• Objects are created from a class by calling a constructor

• Data items stored in a class are called properties• Actions performed by a class are called methods• A class can have events

– Statements in an event handler execute in response to an event

Page 14: BIS305: Advanced Business Programming Introduction

Procedural and Event-driven Programming Languages

• In a procedural language, the sequence of activities can be predicted by the application

• In an event-driven language, the execution path of the application is based on the various events that fire– Users and the system itself can cause events to fire

– It's impossible to predict exactly when an event will fire

Page 15: BIS305: Advanced Business Programming Introduction

Figure 1-18: Event

Processing Loop

Page 16: BIS305: Advanced Business Programming Introduction

Figure 1-19: Operation of a Procedural Application

Page 17: BIS305: Advanced Business Programming Introduction

The Syntax of Programming Languages

• The rules of a programming language are called syntax

• Each programming language has its own syntax– C# and Visual Basic have a different syntax, for

example

• Syntax rules are absolute• Statements with incorrect syntax are

considered syntax errors

Page 18: BIS305: Advanced Business Programming Introduction

Types of Programming Statements

• A statement expresses a complete thought or action

• Statements can be categorized into two types– Declaration statements are used to create

variables and define the structure of an application

– Executable statements perform an action while a program is running

Page 19: BIS305: Advanced Business Programming Introduction

Types of Programming Statements (Example)

Module Hello

Sub Main()

System.Console.WriteLine("Hello World")

End Sub

End Module

Executable statement

Page 20: BIS305: Advanced Business Programming Introduction

Reserved Words and Operators

• Language keywords are called reserved words– Every programming language has a set of reserved

words

– Reserved words differ from programming language to programming language

– Module and Sub are Visual Basic reserved words, for example

– + and – are the Visual Basic operators for addition and subtraction

Page 21: BIS305: Advanced Business Programming Introduction

Identifiers and Their Names

• The term identifier describes the name of a programming element

• Identifier names must– Begin with a letter– Only contain alphabetic characters, digits, or

the underscore character– Have a maximum length of 1023 characters

Page 22: BIS305: Advanced Business Programming Introduction

The Structure of a Visual Basic Application

• Every program has a well-defined structure

• Visual Basic is a block structured language– The outermost block is the Namespace block– Namespace blocks contain Module blocks– Module blocks contain Sub procedure blocks– Procedure blocks contain declaration and

executable statements

Page 23: BIS305: Advanced Business Programming Introduction

Namespace Blocks

• Conceptually, Namespace blocks are similar to file folders– An application can contain one or many Namespace blocks

– Every namespace has an identifier (name)– A Namespace block is marked by the Namespace and End Namespace keywords

Page 24: BIS305: Advanced Business Programming Introduction

Namespace Block (Example)

• Declare a namespace named Chapter01:

Namespace Chapter01

End Namespace

Page 25: BIS305: Advanced Business Programming Introduction

The Contents of a Namespace

• A Namespace block can contain– Class blocks– Structure blocks– Module blocks– Interface blocks

Page 26: BIS305: Advanced Business Programming Introduction

Introduction to Module Bocks

• A Namespace block can contain one or more Module blocks

• A Module block begins with the Module statement

• A Module block ends with the End Module keywords

• Module blocks cannot be nested

Page 27: BIS305: Advanced Business Programming Introduction

Module Block (Example)

• The Namespace block named Chapter01 contains a Module block named Hello

Namespace Chapter01

Module Hello

End Module

End Namespace

Page 28: BIS305: Advanced Business Programming Introduction

Introduction to Procedure Blocks

• A Module block can contain one or many Procedure blocks

• Procedure blocks cannot be nested

• Procedure blocks contain declaration and executable statements

• The Sub and End Sub statements mark the beginning and end of a procedure

Page 29: BIS305: Advanced Business Programming Introduction

Procedure Block (Example)

• The Namespace named Chapter01 contains a Module block named Hello with a Sub procedure block named Main()

Namespace Chapter01

Module Hello

Sub Main()

End Sub

End Module

End Namespace

Page 30: BIS305: Advanced Business Programming Introduction

Figure 1-20: Organization of a Namespace, Module, and Procedure

Page 31: BIS305: Advanced Business Programming Introduction

Writing Executable Statements

• Executable statements can be used to call (execute) a procedure

• Executable statements can be used to make decisions and execute loops

• Assignment statements are executable statements

Page 32: BIS305: Advanced Business Programming Introduction

Calling a .NET Framework Class Library Method

• The .NET Framework supplies general services used by all applications– The Console class has methods used to read

input and to write output– The SystemInformation class gets

information about the local computer

Page 33: BIS305: Advanced Business Programming Introduction

Organization of the .NET Framework Class Library

• The .NET Framework class library is made up of several disk files called libraries– Physical library files are called assemblies

• Physical assemblies contain one or more logical namespaces– Namespaces are organized hierarchically– Namespaces contain classes and other types

Page 34: BIS305: Advanced Business Programming Introduction

Common Namespaces

• System defines the primary data types• System.Data contains classes used to

work with databases• System.Drawing supplies graphics

functionality• System.Windows.Forms contains

classes to create visual forms• System.XML contains classes to work with

the XML language

Page 35: BIS305: Advanced Business Programming Introduction

Figure 1-21: Categorization of Types That Make Up the .NET Framework Class Library

Page 36: BIS305: Advanced Business Programming Introduction

Referencing Namespaces and Classes

• A period separates a namespace name and a class name

• Reference the Console class of the System namespaceSystem.Console

• Call the WriteLine method of the System.Console classSystem.Console.WriteLine()

Page 37: BIS305: Advanced Business Programming Introduction

Method Arguments

• Methods accept 0, one, or many arguments– Arguments are used to send data to a method

• Arguments appear as a comma separated list– The list appears in parenthesis

• Example to display the text "Hello World”:

System.Console.WriteLine("Hello World")

Page 38: BIS305: Advanced Business Programming Introduction

Continuation Lines

• Complicated statements might not fit on one line• Use the continuation character to split a statement

across multiple lines– The continuation character is the underscore (_)

– The continuation character must appear at the end of a line

– A space must precede the continuation character

– The continuation character cannot break up words

Page 39: BIS305: Advanced Business Programming Introduction

Continuation Lines (Example)

• The following statement appears on two lines:

System.Console.WriteLine( _ "Hello World")

Page 40: BIS305: Advanced Business Programming Introduction

Methods of the System.Console Class

• The Read method reads one character from the console

• The ReadLine method reads a line from the console

• The Write method writes a character or characters to the console

• The WriteLine method writes a character or characters, followed by a carriage return, to the console

Page 41: BIS305: Advanced Business Programming Introduction

The SystemInformation Class

• The SystemInformation class gets information about the system

• The ComputerName property gets the name of the computer

• The MouseButtons property gets information about the mouse

• The MouseWheelPresent property indicates whether the mouse has a mouse wheel

• The Network property indicates whether the computer is connected to a network

• The UserName property returns the name of the current user

Page 42: BIS305: Advanced Business Programming Introduction

Using a Command Prompt Window

• The Command Prompt window is used to execute commands and compile programs– Type a command and press Enter to execute the

command

• The Command Prompt window can be used to navigate through the Windows file system

Page 43: BIS305: Advanced Business Programming Introduction

Figure 1-22:Command Prompt window

Page 44: BIS305: Advanced Business Programming Introduction

The Windows File System

• A path defines the hierarchical location of a directory within the Windows file system

• Path references are of two types– Absolute paths begin with a drive designator and a leading

backslashC:\CourseTechnology\Chapter01

– Relative paths begin with a period (.) to denote the current directory and two periods (..) to denote the parent directory of the current directory..\Data.Chapter01.\Chapter01

Page 45: BIS305: Advanced Business Programming Introduction

Windows Navigation Commands

• DIR lists the files and directories in the current directory

• CD changes directories• RENAME changes the name of a file or directory• DEL deletes a file

• There are many other commands and command options

Page 46: BIS305: Advanced Business Programming Introduction

Windows Navigation Commands (Examples)

• Display the contents of the current directoryDIR

• Change the current directory to the root directory on the current driveCD \

• Rename FileOld to FileNewRENAME FileOld FileNew

• Delete FileNewDEL FileNew

Page 47: BIS305: Advanced Business Programming Introduction

Compiling and Executing a Visual Basic Application

• Visual Basic programs are compiled into intermediate language (IL)

• IL code is translated into an executable form using the JIT compiler– The JIT compiler is called automatically when

an application is run

• The Visual Basic compiler is named vbc.exe

Page 48: BIS305: Advanced Business Programming Introduction

Figure 1-23: Translation of .NET Source Code to Executable Code

Page 49: BIS305: Advanced Business Programming Introduction

Calling the Visual Basic Compiler

• The compiler is called with directives that define how the application is compiled– /main specifies the module containing the

entry point– /out specifies the name of the executable file– /verbose causes the compiler to display

informational messages

Page 50: BIS305: Advanced Business Programming Introduction

Calling the Visual BasicCompiler (Example)

• Compile the Visual Basic file named Hello.vb to produce an executable file named Hello.exe

• The Main procedure appears in the Namespace and Module named Chapter01.Hello

vbc /main:Chapter01.Hello /out:Hello.exe Hello.vb

Page 51: BIS305: Advanced Business Programming Introduction

Figure 1-24: Using the Command Prompt Window to Compile a Visual Basic Application

Page 52: BIS305: Advanced Business Programming Introduction

Syntax Errors

• A program with syntax errors cannot be compiled

• Statements with syntax errors are identified by the Visual Basic compiler

Page 53: BIS305: Advanced Business Programming Introduction

Figure 1-25:Syntax Errors