Download presentation
Presentation is loading. Please wait.
Published byChester Chambers Modified over 8 years ago
1
IT254 Foundation of Programming Using C# Seminar 1 : Course Introduction Instructor : Vladimir Gubanov, PhD Email : vgubanov@kaplan.eduvgubanov@kaplan.edu AIM : vladimirg77
2
Some Course Administration questions first : 1.Our Seminars : they will be each Wednesday, from 9 PM to 10 PM EST You are here – so you already know that, right ? 2.My Office Hours : Mondays, 7PM to 8PM Saturdays, 9AM to 10 AM
3
On Our Seminar Rules Please stay on topic when responding. Interrupt me anytime by typing in your question or comment – I will be glad to answer them No Side/off-topic Conversations Please - we are here to discuss course issues. Agreed ? Please be nice to each other and respect others. Every opinion is valuable and appreciated. 3
4
Any questions so far ? Do not hesitate to ask, especially if you are new to online classes and/or Online Seminars ! 4
5
Let us talk on our course now. This course introduces the fundamentals of C#, and object-oriented programming language. Topics include producing and editing printed output, I/O processing, loop processing, user-defined functions, arrays, and database access. Upon completion, you will be able to write programs to solve business application problems. 5
6
6 Some Early Ideas on Computers and Computer Programming “It is by no means hopeless to expect to make a machine for really very difficult mathematical problems. But you would have to proceed step-by-step. ” Charles Sanders Peirce (1839-1914) “Computers have no power of anticipating any analytical relations or truths. Their province is to assist us in making available what we are already acquainted with.“ Humans v.s. computers : “fuzzy logic” v.s. “100% definitive logic” What is that ?
7
7 Computers how they are now: consist of : – Hardware : physical computer machine – Software : all kind of programs that are used to give instructions to the computer – Program: a set of instructions for the computer what to do, must be “ understandable” for a computer” Computer: programmable electronic device that can store, retrieve and process data
8
8 Programming Languages : many of them ! Programming Language: – Set of specific instructions and rules recognizable by a computer: – Low-Level Language: recognized by hardware as is – High-Level Language: needs language specific and hardware specific compiler(interpreter) to run; easy for people to write and understand Machine Languages (1 st generation PL) Use binary number system : each character is represented by a series of “Off” (0) or “On (1) switches Typical coding scheme: ASCII (American Standard Code for Information Exchange) Instructions written in 0s and/or 1s : machine language Assembly Languages (2 nd generation PL) Use mnemonics (memory aids, alphabetic abbreviations for instructions ) in place of 0s and 1s Programs require an assembler : a program converting the assembly instructions to machine code
9
9 Machine Languages Are based on the binary number system Use combination of 0s and 1s to communicate directly with the computer How to input those 0s and 1s ? : punch cards Are tedious and error-prone; require highly trained programmers, who know what those combinations of Os and 1s mean
10
10 Machine Languages
11
11 Assembly Languages Allow programmers to use mnemonics in place of 0s and 1s in the program Require an assembler (a special program to convert assembly instructions into machine code – the combinations of 0s and 1s which a computer understands) Easier to write than machine language, but still tedious and require highly trained programmers
12
12 Assembly Languages
13
Simple Program Design, Fourth Edition Chapter 1 13 High-Level Languages Instructions are written in the language “close” to English (FORTRAN, COBOL, SQL, Java, C++, VB.Net C#…) Two types of those languages : procedural and object-oriented Procedural : focus how to solve a problem: Step-by-step instructions from the start to completion top-down design : – what needs to be done; – how to get it done Object- Oriented : focus what parts (objects ) a system consists of The translation of a program from a high-level language to a language that the computer can understand is done by a compiler The input program is called the source code; the translated low-level language program - the object program or object code.
14
Microsoft Visual C#.NET: From Problem Analysis to Program Design 14 Software Development Process Programming is a process of problem solving How do you start? Number of different approaches, or methodologies Successful problem solvers follow a methodical approach
15
Microsoft Visual C#.NET: From Problem Analysis to Program Design 15 Steps in the Program Development Process 1.Analyze the problem 2. Design a solution 3.Code the solution 4.Implement the code 5.Test and debug 6.Use an iterative approach
16
Microsoft Visual C#.NET: From Problem Analysis to Program Design 16 Programming Methodologies Structured Procedural Programming – Emerged in the 1970s – Associated with a technique called top-down design Analogy of building a house Write each of the subprograms as separate functions or methods invoked by a main controlling function or module – Drawbacks During software maintenance, programs are more difficult to maintain. Less opportunity to reuse code
17
Microsoft Visual C#.NET: From Problem Analysis to Program Design 17 Programming Methodologies ( continued ) Object-oriented – Newer approach – Construct complex systems that model real world entities – Facilitates designing components – Assumption is that the world contains a number of entities that can be identified and described – Through abstracting, determine the attributes (data) and the behaviors (processes on the data) of the entities – Encapsulate (combine) attributes and behaviors to form a class
18
Microsoft Visual C#.NET: From Problem Analysis to Program Design 18 The Evolution of C# and.NET 1940s: Programmers toggled switches on the front of computers 1950s: Assembly languages replaced the binary notation Late 1950s: High-level languages came into existence Today: More than 2,000 high-level languages – Noteworthy high-level programming languages are C, C++, Visual Basic, Java, and C#
19
Microsoft Visual C#.NET: From Problem Analysis to Program Design 19 C# One of the newest programming languages Conforms closely to C and C++ Has the rapid graphical user interface (GUI) features of previous versions of Visual Basic Has the added power of C++ Has the object-oriented class libraries similar to Java
20
Microsoft Visual C#.NET: From Problem Analysis to Program Design 20 C# ( continued ) Can be used to develop a number of applications – Software components – Mobile applications – Dynamic web pages – Database access components – Windows desktop applications – Web services – Console based applications
21
Microsoft Visual C#.NET: From Problem Analysis to Program Design 21.NET Not an operating system An environment in which programs run Resides at a layer between operating system and other applications Offers Multi-language Independence – One application can be written in more than one language Includes over 2,500 reusable types (classes) Enables Creation of dynamic Web pages and Web services Scalable component development
22
Microsoft Visual C#.NET: From Problem Analysis to Program Design 22 C# relationship to.NET Many compilers targeting the.NET platform are available C# was used most heavily for development of the.NET Framework class libraries C#, in conjunction with the.NET Framework classes, offers an exciting vehicle to incorporate and use emerging Web standards
23
Microsoft Visual C#.NET: From Problem Analysis to Program Design 23 C# relationship to.NET ( continued ) C# is object-oriented 2001, the European Computer Manufacturers Association (ECMA) General Assembly ratified C# and its common language infrastructure (CLI) specifications into international standards
24
Microsoft’s Visual Studio 2008.NET 3.5 Framework – Environment that allows objects from different languages to operate together, standardizes references to data and objects –.NET languages all compile (translate) to Microsoft Intermediate Language (MSIL) – MSIL runs in the Common Language Runtime (CLR) Programming Languages – Visual C#, Visual C++, Visual Basic C# Versions – Express Edition, Standard Edition, Professional Edition, Team System
25
Writing C# Programs – The Three-Step Process (Planning) Planning – Design the user interface Sketch screens Show forms and all controls – Name forms and objects on form Consult with user – Plan the properties – Plan the C# code Plan classes and methods Write pseudocode
26
Writing C# Programs – The Three-Step Process (Programming) Define user interface – Create forms and controls Set the properties – Name each object and define its attributes Write the code – Define the actions of the program
27
C# Application Files Solution file – A C# application is called a solution and can consist of one or more projects –.sln extension Project file – Describes project and lists files included –.csproj extension Form files –.cs,.Designer.cs,.resx extensions The Visual Studio environment creates several more files
28
The Visual Studio Environment Integrated development environment (IDE) – Includes various tools Form designer Editor for entering and modifying C# code Compiler Debugger Object Browser Help
29
Default Environment Settings Visual Studio 2008 allows selection of default IDE profile – Available with full version of Visual Studio – Choose Visual C# Development Settings Text uses the Visual C# settings Settings can be saved for more than one language To switch between the settings for languages: – Select Tools/Import and Export Settings – Choose Reset all settings
30
The New Project Dialog Select File/New Project – New Project Dialog Box Opens Select the Windows Forms Application template Enter the Project Name Select Visual C# Windows
31
The IDE Main Window Each window can be moved, resized, closed, or customized Solution Explorer Properties window Toolbox Main Document window
32
The Toolbars Toolbar buttons are shortcuts Each button’s command is also a menu selection Select View/Toolbars to display or hide a toolbar Three commonly used toolbars – Standard – Layout – Text Editor
33
Document Window Use tabs to switch between open documents Items in Document window – Form Designer – Code Editor – Project Designer – Database Designer – Object Browser
34
The Form Designer Design forms for user interface Change size of form using sizing handles or selection border A new default form is added when a new C# application is started
35
The Solution Explorer and Properties Windows Solution Explorer window – Holds filenames for project files – Lists classes referenced – Holds name of solution (.sln) file Properties Window – Used to set properties for objects in project
36
Toolbox Holds tools to place controls on form Tools vary depending on edition of C#
37
Design Time, Run Time, Debug Time Design Time – Design user interface (forms) – Write code Run Time – Testing project – Running project Debug Time – Run-time errors – Pause program execution
38
Write Code C# Events – While a project is running the user can perform actions, each of which causes an event to occur – C# will execute a method when code has been written for an event – C# ignores events for which no methods are written
39
C# Event Handlers Write C# code in methods – Each begins with the words private void – Code in method is enclosed in braces { } C# names the event-handling method as the object name, an underscore (_) and the name of the event – displayButton_Click
40
C# Code Statements Comment statements – Sometimes called remarks Ending a statement – Code statements are terminated by a semicolon (;) Assignment statements Executing a Method – Methods always have parentheses – Use this keyword to execute method of the current form
41
The Comment Statement Comments or remarks are for project documentation Explain purpose of the program Provide identifying information Non-executable statements within the code Automatically colored green by the editor Single-line comments begin with two slashes // Display a message to the user. Multiline comments begin with /* and end with */ /* First line... Last line */
42
Ending a Statement Most C# statements end with a semicolon (;) A statement can appear on multiple lines The semicolon determines the end of the statement Comments and a few other C# statements do not end with a semicolon
43
Code Event-Handling Methods - 1 Double-click the Display button The Editor window opens The header line for the method is in place The insertion point appears inside the opening and closing braces private void displayButton_Click(object sender, EventArgs e) { | }
44
Automatically Generated Code Using Statements – Provide references to classes from the language library System.Windows.Forms – Allows program to refer to all Windows controls Namespace Statement –.NET Framework requires every program component to have a namespace Class Statement – A new class can inherit from another class
45
Finding and Fixing Errors Syntax errors – Breaking the rules of the language – Editor finds most, compiler reports remainder Editor identifies syntax errors with a red squiggly line Run-time errors or exceptions – Program halts due to statements that cannot execute For example, impossible arithmetic operations Logic errors – Program runs but produces incorrect results – Carefully proof output to make sure it is correct Computations, text and spacing
46
Project Debugging Program errors are bugs Editor highlights syntax and run-time errors Programmer must locate logic errors C# allows edit-and-continue – Fix error and press F5 or Debug/Continue Clean Compile – No errors during the compile process
47
Naming Rules and Conventions for Objects Follow C# rules for naming objects, methods and variables Good programmers follow naming rules and conventions Most programming shops have standards that must be followed When programmers consistently follow standards, programs are easier to read and to maintain, by both the original programmer and by others
48
The Naming Rules Name must begin with a letter or an underscore Name can contain letters, digits, and underscores Name cannot include a space, punctuation mark or be a reserved word Names are case sensitive – exitbutton, ExitButton and exitButton refer to three different objects
49
The Naming Conventions -1 Follow standard naming conventions Use camel casing – Begin name with lowercase character – Capitalize each additional word in name Use meaningful names, indicate purpose of object Append full name of control’s class – Examples messageLabel, exitButton, discountRateLabel
50
The Naming Conventions - 2 Do not keep C# default names – Exception is labels that never change during execution Use pascal casing to name forms and classes – Capitalize first letter of name and first letter of all other words in name – Examples HelloForm, MainForm, AboutForm
51
Visual Studio Help Installing and Running MSDN – Can be run from a hard drive or online Viewing Help Topics – Help window opens on top of IDE window – Filter by C# and either Express or Professional Edition Context-Sensitive Help – Select a C# object (i.e. form or control) – Place insertion point in a word in the editor Press F1
52
Microsoft Visual C#.NET: From Problem Analysis to Program Design 52 Summary Computing dates back some 5,000 years – Currently in 4 th or 5 th generation of computing Physical components of the computer System Software versus Application Software Steps in Program Development Process – 1. Analyze the problem – 2. Design a solution – 3. Code the solution – 4. Implement the code – 5. Test and debug
53
Microsoft Visual C#.NET: From Problem Analysis to Program Design 53 Summary ( continued ) Programming methodologies – Structured procedural – Object-Oriented C# – One of the.NET managed programming language – Object-oriented – 2001 EMCA standardized – Provides rapid GUI development of Visual Basic – Provides number crunching power of C++ – Provides large library of classes similar to Java
54
Quick Quiz What is the brain of the computer? Answer: CPU True or False: Main memory is volatile. Answer: True True or False: The CPU is divided into peripheral devices and control units. Answer: False What are the two roles of the processing device? Answer: Serve as the control unit and to perform arithmetic and logical comparisons 54
55
Quick Quiz What are the two types of software? Answer: system and application True or False: Excel is an example of system software.r: False Identify two types of functions that are performed by operating system software. Answer: copy and delete files 55
56
Quick Quiz Name two approaches used to design a solution. Answer: Procedural and object-oriented Give three examples of high level programming languages. Answer: C#, Java, Visual Basic True or False:.NET has been around since the mid 1990s. Answer: False 56
57
Quick Quiz True or False: All of the.NET Framework classes were written in C#. Answer: False Identify two reasons to use C# for developing applications. Answer: C# is a simple object-oriented language. You can create graphical user interfaces with the same ease as was available only to Visual Basic programmers. 57
58
The End 58 Any questions? My E-Mail: vgubanov@kaplan.edu
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.