1 / 22

CSE 20232 Lecture 1 - Preliminaries

CSE 20232 Lecture 1 - Preliminaries. Introduction & Syllabus Computer Hardware/Software Hierarchy C / C++ Problem Solving / OOAD Development Environment / Tools Simple C++ program structure Linux, g++ & dropboxes. Introduction. John H Stewman, PhD Education BA (History), Duke

mikel
Download Presentation

CSE 20232 Lecture 1 - Preliminaries

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 20232Lecture 1 - Preliminaries • Introduction & Syllabus • Computer Hardware/Software Hierarchy • C / C++ • Problem Solving / OOAD • Development Environment / Tools • Simple C++ program structure • Linux, g++ & dropboxes

  2. Introduction • John H Stewman, PhD • Education • BA (History), Duke • BS (Computer Engineering), USF • MS (Computer Science), USF • PhD (Comp. Sci. & Engr.), USF • Research • Computer Vision – DARWIN project (Eckerd College) • Employment • US Navy • Eckerd College • Notre Dame

  3. Syllabus • Grad TA • S. Niaz Arifin (sarifin@nd.edu) • Undergrad TA’s • Joey Schmitt • Joe Thompson • Location • 215 Debartolo, MWF, 9:35 – 10:25 • Assignments (50%) • Weekly programming • Tests (50%) • 2 Midterms & Final exam

  4. What is a “Computer?” • Hardware • Input devices (mouse, keyboard, scanner,…) • Primary Memory (RAM) • Secondary Memory (Hard drive, CD, floppy,…) • Output devices (monitor, speakers, …) • CPU (central processing unit) • Control unit -- fetch-execute cycle • ALU (arithmetic logic unit) • Software • Operating System (Linux, Windows, UNIX, …) • Interpret commands and manage access to resources • Application (Word, FreeCell, Doom, …) • Provide productivity tools, entertainment • Create a “virtual” machine

  5. Programming Language Preliminaries • Language hierarchy • Machine language • numeric codes for basic hardware operations • Assembly language • mnemonic codes for basic hardware operations • load, add, store, … • High-level language (Pascal, C/C++, Java, Ada …) • English-like instructions and constructs for combinations of basic hardware operations • x = 3; • if (x < y) x = y;

  6. Programming Language Preliminaries • Interpreter • Reads, translates and executes program instructions on the fly • Compiler • Translates high-level source code into relocatable object code (assembly or machine)

  7. C / C++ History • BCPL (Martin Richards 1967) • For writing compilers and operating systems • B (Ken Thompson 1970) • Based on BCPL & used to create early version of UNIX at Bell Labs • C (Dennis Ritchie) • Evolved from B & BCPL • Became the development language for UNIX • C programs can be portable (platform independent) • Standard is ANSI/ISO 9899; 1990

  8. C / C++ History • C++ (Bjarne Stroustrup – early 1980’s) • Extension of C • Supports Object-oriented programming • User definable object classes • Facilitates development of reusable software components • C++ Standard Library • LARGE Collection of existing classes & algorithms • string, vector, list, set, map, … • sorts, comparitors, …

  9. Problem Solving Steps • State the problem • Analyze the requirements • Inputs & outputs, precision, timeliness, environment … • Develop a design for the solution • OOAD - Identify key objects • Object attributes become data members • Object behavior become member functions • Identify how objects interact to solve problem • Develop algorithms for functions • Write pseudocode for algorithms • Refine program structure and repeat process • Top-down vs. bottom-up

  10. Program Development Tools • Editor • Create the C++ source code • Save source to disk • Preprocessor • Scan source for preprocessor directives (#include, …) • Compiler • Scan source and translate into object code • Save object code to disk • Linker • Link various object code modules into final executable • Resolve addressing issues between modules • Save executable to disk • Loader • Place executable in main memory and start execution

  11. Abstraction • Description of what something does not how • Data Abstraction • string, stack, queue, complex number • Functional abstraction • sqrt(), sort(), • Encapsulation • Binding of values and operations within a single program entity • Ex: C++ class or data type (int, string, …) • Information hiding • Separating implementation details from interface details • Ex: .h and .cpp files, public vs. private

  12. Simple C++ Program Structure • Comment block • Filename, author, date, purpose, description, … • Preprocessor directives #include … • Using statements using namespace std; • Main function int main () { Declarations Statements return 0; }

  13. C++ Basics • Comments are for humans and are ignored by the compiler • // rest of line after double slash is ignored • /* everything between markers is ignored */ • Include directives load predefined code interfaces so compiler “knows” about functions, classes, and other predefined entities • #include <iostream> • loads C++ header from “normal” location • Headers define entities within namespaces • #include <stdlib.h> • loads C-style header from “normal” location • No namespaces • #include “myStuff.h” • Loads user-defined header from current directory • May or may not contain namespaces

  14. Simple C++ Program (helloWorld.cpp) // file: helloWorld.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE 20232 – Notre Dame – demo // description: // this shows the world we care #include <iostream> using namespace std; int main( ) { cout << “Hello World!” << endl; return 0; }

  15. Simple C++ Program (helloWorld2.cpp) // file: helloWorld2.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE 20232 – Notre Dame – demo // description: // shows the world we care // (with scope resolution operator ::) #include <iostream> int main( ) { std::cout << “Hello World!” << std::endl; return 0; }

  16. Simple C++ Program (addTwo.cpp) // file: addTwo.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE 20232 – Notre Dame – demo // description: ages you by two years #include <iostream> using namespace std; int main( ) { int age; cout << “Hello, what is your age? ”; cin >> age; cout << “In two years you will be ” << age + 2 << endl; return 0; }

  17. UNIX/Linux Basics • Basic commands • ls list current director contents • cd change to another directory • mkdir, rmdir make or remove a directory (folder) • pwd displays current path • rm remove a file • mv move or rename a file • cp copy a file • less page through a text file • man display manual page on command

  18. UNIX/Linux Basics • Basic commands • !! “bang bang” execute last command • !x execute last command x* • | pipe output of one command into another • history show list of previous commands • ln - s create symbolic link • < take input from file • > send output to file • >> append output to file

  19. UNIX/Linux Basics • Creating a symbolic link • ln –s /afs/nd.edu/coursefa.08/cse/cse20232.01/dropbox/jstewman mydrop • Compiling • Compile source to object file • g++ -g -c helloWorld.cpp • Link object file and create executable • g++ -o helloWorld helloWorld.o • Do it all in one step • g++ -g -o helloWorld helloWorld.cpp

  20. Run / Test / Submit • Run your program from a Terminal or xterm by typing … • ./helloWorld • If it does not work correctly, it has a “bug,” so … • Make changes to source, recompile, link, and test again • This is called “testing and debugging” • To submit your program to your dropbox … • if you created a symbolic link (mydropbox) • cp hw1_1.cpp mydropbox/hw1 • otherwise ... • cp hw1_1.cpp /afs/nd.edu/coursefa.08/cse/cse20232.01/dropbox/your_afsid/hw1

  21. Reading and Homework • For this week read in Deitel • Chapter 1 • Sections 1.2-1.6, 1.8-1.10, 1.14-1.17 • Chapter 2 • Sections 2.1-2.4 • Appendices • E.1-E.2

  22. Demo • Go to Linux box and show use of … • Commands • Creation of symbolic link • Editor • GNU g++ Compiler/Linker • Testing & debugging • NOTE: sample programs will be placed on the class web site

More Related