Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright ©2004  Department of Computer & Information Science Introducing Computer Science & Algorithms.

Similar presentations


Presentation on theme: "Copyright ©2004  Department of Computer & Information Science Introducing Computer Science & Algorithms."— Presentation transcript:

1 Copyright ©2004  Department of Computer & Information Science Introducing Computer Science & Algorithms

2 Copyright ©2004  Department of Computer & Information Science Goals By the end of this lecture you should … … understand Computer Science as the study of algorithms… understand Computer Science as the study of algorithms … understand the difference between procedural-type languages and object- oriented languages… understand the difference between procedural-type languages and object- oriented languages … understand the program development cycle… understand the program development cycle

3 Copyright ©2004  Department of Computer & Information Science Types of Computers Personal Computer - a computer operated by one person at a time. AKA “Client” computers.Personal Computer - a computer operated by one person at a time. AKA “Client” computers. Server – a computer whose resources and processors are shared by multiple usersServer – a computer whose resources and processors are shared by multiple users VB.Net concerns itself mainly with programming for the client computerVB.Net concerns itself mainly with programming for the client computer

4 Copyright ©2004  Department of Computer & Information Science Computer use is Pervasive BankingBanking Air TrafficAir Traffic Space TravelSpace Travel CommerceCommerce MedicineMedicine Public SafetyPublic Safety EducationEducation

5 Copyright ©2004  Department of Computer & Information Science Computer Components HardwareHardware –Physical components of a computer –Examples: Mouse, keyboard, RAM, hard drives, processor, monitor SoftwareSoftware –Instructions that get the computer to do something –Operating Systems & Applications –Examples: Windows 2000, Microsoft Excel, WordPerfect, Netscape, Internet Explorer

6 Copyright ©2004  Department of Computer & Information Science What is Computer Science? NOT about coding or hardware or software!NOT about coding or hardware or software! Computer Science is about PROBLEM SOLVINGComputer Science is about PROBLEM SOLVING Computer Science is about DEVELOPING ALGORITHMS to solve complex problemsComputer Science is about DEVELOPING ALGORITHMS to solve complex problems Computers are merely tools for solving problems!Computers are merely tools for solving problems!

7 Copyright ©2004  Department of Computer & Information Science Algorithms Well-developed, organized approaches to solving complex problemsWell-developed, organized approaches to solving complex problems Test of a good algorithm:Test of a good algorithm: –Does the algorithm solve the stated problem? –Is the algorithm well-defined? –Does the algorithm produce an output? –Does the algorithm end in a reasonable length of time?

8 Copyright ©2004  Department of Computer & Information Science Developing an Algorithm 1.Identify the Inputs –What data do I need? –How will I get the data? –In what format will the data be? 2.Identify the Processes: –How can I manipulate data to produce meaningful results? 3.Identify Outputs: –What outputs do I need to return to the user? –What format should the outputs take?

9 Copyright ©2004  Department of Computer & Information Science Developing an Algorithm 4.Develop a HIPO chart PROBLEM INPUT MODULE PROCESSES MODULE OUTPUT MODULE

10 Copyright ©2004  Department of Computer & Information Science Developing an Algorithm 5.Identify relevant modules –How can I break larger problems into smaller, more manageable pieces? –What inputs do the modules need? –What processes need to happen in the modules? –What outputs are produced by the modules?

11 Copyright ©2004  Department of Computer & Information Science Programs Sets of instructions that get the computer to do somethingSets of instructions that get the computer to do something Instructions are translated, eventually, to machine language using an interpreter or a compilerInstructions are translated, eventually, to machine language using an interpreter or a compiler Programs may be a few lines or millions of lines of codePrograms may be a few lines or millions of lines of code

12 Copyright ©2004  Department of Computer & Information Science Programming Tasks All computer programs are written so they can take data, manipulate and then produce a result.All computer programs are written so they can take data, manipulate and then produce a result. This process uses three distinct tasks:This process uses three distinct tasks: –INPUT – getting data from an external source (the user, a database, a file, etc.) –PROCESSING – actual manipulation of the data –OUTPUT – reporting the results of data manipulation back (using the monitor, writing information to a database, etc.)

13 Copyright ©2004  Department of Computer & Information Science Relationships in Programming Programmer – The person who solves a problem by providing a solution through writing instructions (the program) for the computer. (AKA – The developer)Programmer – The person who solves a problem by providing a solution through writing instructions (the program) for the computer. (AKA – The developer) User – Any person who uses a program written by a programmerUser – Any person who uses a program written by a programmer

14 Copyright ©2004  Department of Computer & Information Science Categories of Languages Machine LanguageMachine Language –Binary digits (bits – 1s and 0s) which are translated to electrical impulses that get the computer to do something –“Native” language of computers Assembly LanguagesAssembly Languages –Group of basic commands which are more like English –Tied to specific processors –Still need to be translated to machine language

15 Copyright ©2004  Department of Computer & Information Science Categories of Languages High Level LanguagesHigh Level Languages –In terms of syntax, very close to human language (mostly English) –Lower error rate than writing machine language or assembly language programs –Need to be translated to machine language before execution CompilersCompilers InterpretersInterpreters

16 Copyright ©2004  Department of Computer & Information Science More on High-Level Languages Operations common to all HL languages:Operations common to all HL languages: –Sequential Operations – Operations in which lines of code execute in order, one right after another –Conditional Operations – Operations in which execution depends on the outcome of a previous condition (usually evaluated to be TRUE or FALSE) –Looping Operations – Operations designed to repeat until a given condition is satisfied.

17 Copyright ©2004  Department of Computer & Information Science More on High-Level Languages Procedural LanguagesProcedural Languages –Early high level languages –Focus on structures –Examples include QuickBasic, Fortran, Pascal, Visual Basic (early versions) Object-Oriented languages (OOP)Object-Oriented languages (OOP) –More recent development –Focus on data, not structures (Primacy of Data) –Examples include Java, C#, C++, Visual Basic.Net

18 Copyright ©2004  Department of Computer & Information Science Object Oriented Programming Object – Unique programming entity that has methods, has attributes and can react to events.Object – Unique programming entity that has methods, has attributes and can react to events. Method – Things which an object can do; the “verbs” of objects. In code, usually can be identified by an “action” word -- Hide, ShowMethod – Things which an object can do; the “verbs” of objects. In code, usually can be identified by an “action” word -- Hide, Show

19 Copyright ©2004  Department of Computer & Information Science Object Oriented Programming Attribute – Things which describe an object; the “adjectives” of objects. In code, usually can be identified by a “descriptive” word – Enabled, BackColorAttribute – Things which describe an object; the “adjectives” of objects. In code, usually can be identified by a “descriptive” word – Enabled, BackColor Events – Forces external to an object to which that object can react. In code, usually attached to an event procedureEvents – Forces external to an object to which that object can react. In code, usually attached to an event procedure

20 Copyright ©2004  Department of Computer & Information Science Object Oriented Programming Class – Provides a way to create new objects based on a “meta-definition” of an object (Example: The automobile class)Class – Provides a way to create new objects based on a “meta-definition” of an object (Example: The automobile class) Constructors – Special methods used to create new instances of a class (Example: A Honda Civic is an instance of the automobile class.)Constructors – Special methods used to create new instances of a class (Example: A Honda Civic is an instance of the automobile class.)

21 Copyright ©2004  Department of Computer & Information Science OOP - Encapsulation Incorporation into a class of data & operations in one packageIncorporation into a class of data & operations in one package Data can only be accessed through that packageData can only be accessed through that package “Information Hiding”“Information Hiding”

22 Copyright ©2004  Department of Computer & Information Science OOP - Inheritance Allows programmers to create new classes based on an existing classAllows programmers to create new classes based on an existing class Methods and attributes from the parent class are inherited by the newly-created classMethods and attributes from the parent class are inherited by the newly-created class New methods and attributes can be created in the new class, but don’t affect the parent class’s definitionNew methods and attributes can be created in the new class, but don’t affect the parent class’s definition

23 Copyright ©2004  Department of Computer & Information Science OOP - Polymorphism Creating methods which describe the way to do some general function (Example: The “drive” method in the automobile class)Creating methods which describe the way to do some general function (Example: The “drive” method in the automobile class) Polymorphic methods can adapt to specific types of objects.Polymorphic methods can adapt to specific types of objects.

24 Copyright ©2004  Department of Computer & Information Science The Programming Development Cycle Done after identifying inputs, processing & outputsDone after identifying inputs, processing & outputs StepsSteps 1.Analyze the problem 2.Plan a solution to the problem (algorithm) 3.Design the user interface

25 Copyright ©2004  Department of Computer & Information Science The VB.NET Programming Development Cycle Steps (continued)Steps (continued) 4.Code the solution 5.Test and debug the solution 6.Complete program documentation 7.Begin to plan for next release (start Cycle again)

26 Copyright ©2004  Department of Computer & Information Science 1. Analyze the Problem Questions to ask:Questions to ask: –Who is my intended audience? –What SPECIFIC outcomes does my audience expect? –What business rules is my audience expecting to have incorporated into the solution? –What is the SCOPE of the problem?

27 Copyright ©2004  Department of Computer & Information Science 2. Plan a Solution (Algorithm) What types of programming structures are needed?What types of programming structures are needed? –Sequential structures –Conditional structures –Looping structures What data structures are needed?What data structures are needed? –Variables –Lists –Arrays

28 Copyright ©2004  Department of Computer & Information Science 3. Design the User Interface AKA – The “UI”AKA – The “UI” Is the UI “learnable”?Is the UI “learnable”? Is it simple? (Limit user choices)Is it simple? (Limit user choices) Does the UI promote error-proof use?Does the UI promote error-proof use? Is the layout of the UI arranged in a fashion conducive to the user’s culture and expectations?Is the layout of the UI arranged in a fashion conducive to the user’s culture and expectations?

29 Copyright ©2004  Department of Computer & Information Science 4. Code the Solution Develop an actual program from an algorithmDevelop an actual program from an algorithm Should be the “easiest” part of the process – all the work should already be done!Should be the “easiest” part of the process – all the work should already be done!

30 Copyright ©2004  Department of Computer & Information Science 5. Test & Debug the Solution Alpha Testing – Internal testing done with expected client data (NOT LIVE DATA)Alpha Testing – Internal testing done with expected client data (NOT LIVE DATA) Beta Testing – Testing done at the client site with their data (USUALLY LIVE DATA)Beta Testing – Testing done at the client site with their data (USUALLY LIVE DATA) Try to predict common user errorsTry to predict common user errors Test subjects should be Power Users, Normal Users and NeophytesTest subjects should be Power Users, Normal Users and Neophytes

31 Copyright ©2004  Department of Computer & Information Science 6. Complete Documentation User Documentation:User Documentation: –User Manual –Technical Documentation (for System Administrators) Internal Documentation:Internal Documentation: –Documentation comments –Code comments –Procedural comments –Should be done while coding!

32 Copyright ©2004  Department of Computer & Information Science 7. Plan Next Release What bugs need to be fixed?What bugs need to be fixed? –Are bugs “critical”? (Need to be fixed in a minor release) –If bugs are not critical, they can be fixed in next major release What product enhancements do the users want for the next release?What product enhancements do the users want for the next release?

33 Copyright ©2004  Department of Computer & Information Science Internal Commenting Comments are non-executable lines (the computer ignores them) which are used to communicate valuable information about code to othersComments are non-executable lines (the computer ignores them) which are used to communicate valuable information about code to others Types of Internal Commenting:Types of Internal Commenting: –Documentation Comments –Code Comments –Procedural Comments Comment Syntax:Comment Syntax: –C-like Syntax (C, C++, Java, JavaScript): /* This is a comment */ –Visual Basic Syntax: ‘This is a comment

34 Copyright ©2004  Department of Computer & Information Science Documentation Comments Used to given specific information about a programUsed to given specific information about a program Usually found at the beginning of a code windowUsually found at the beginning of a code window Include information about the author, creation date, purpose, modification date & modification historyInclude information about the author, creation date, purpose, modification date & modification history

35 Copyright ©2004  Department of Computer & Information Science Documentation Comment 'TITLE: Hello World, v2.0 'AUTHOR: Bob Molnar 'PURPOSE: To demonstrate changing of textbox 'properties using event procedures. 'CREATED ON: 09.10.2002 'LAST MODIFIED ON: 09.18.2002 'LAST MODIFIED BY: RSM 'MODIFICATION HISTORY: ' 09.12.2002 - Renamed form to frmMain to ' conform with accepted naming standards (MJK) ' 09.18.2002 - Created a Clear Button enabling ' users to clear output (RSM) NOTE: Example uses Visual Basic Syntax

36 Copyright ©2004  Department of Computer & Information Science Code Comments “Tell the story” of the code, in English“Tell the story” of the code, in English For this class, you should use code comments to indicate what lines of code doFor this class, you should use code comments to indicate what lines of code do

37 Copyright ©2004  Department of Computer & Information Science Code Comments /* Initialize loop counter to 1 */ counter = 1; /* Set loop to repeat 10 times */ while(counter <= 10) { /* Prompt for input */ printf("Enter grade: "); /* Get user's input, store in the variable grade */ scanf("%d", &grade); /* Get user's input, store in the variable grade */ scanf("%d", &grade); } /* end while */ NOTE: Example uses C Syntax

38 Copyright ©2004  Department of Computer & Information Science Procedural Comments Identify purpose, arguments & return values for proceduresIdentify purpose, arguments & return values for procedures Can be used in:Can be used in: –Event Procedures –Sub-Procedures –Function Procedures

39 Copyright ©2004  Department of Computer & Information Science Procedural Comments ' PROCEDURE: btnClear_Click ' TYPE: Event Procedure ' ARGUMENTS: VB-Generated ' PROCEDURE: btnClear_Click ' RETURNS: Nothing ' PURPOSE: Re-sets the value of the textbox ' txtDspMsg to null when the button btnClear ' clicked Private Sub btnClear_Click(...) Handles _ btnClear.Click txtDspMsg.Text = "" End Sub btnClear.Click txtDspMsg.Text = "" End Sub NOTE: Example uses Visual Basic Syntax

40 Copyright ©2004  Department of Computer & Information Science Questions?

41 Resources Bob Molnar, N201 Lecture NotesBob Molnar, N201 Lecture Notes Visual Basic.NET Primer Plus by Jack Purdum (Sams Publishing, 2003)Visual Basic.NET Primer Plus by Jack Purdum (Sams Publishing, 2003) An Introduction to Programming Using Visual Basic.NET Fifth Edition by David I. Schneider (Prentice Hall, 2003)An Introduction to Programming Using Visual Basic.NET Fifth Edition by David I. Schneider (Prentice Hall, 2003) C: How to Program by Deitel & Deitel (Prentice Hall, 2004)C: How to Program by Deitel & Deitel (Prentice Hall, 2004)


Download ppt "Copyright ©2004  Department of Computer & Information Science Introducing Computer Science & Algorithms."

Similar presentations


Ads by Google