CS1102 Introduction to Computer Studies Lecture 01 PDF
Document Details
Uploaded by LighterPlatinum
City University of Hong Kong
2025
Howard Leung
Tags
Related
- Introduction to Requirements Engineering PDF
- Chapter 1 - Introduction PDF
- Module 1: Introduction to OOAD PDF
- DCF-Module 2 PDF - Boolean Algebra, Logic Gates, and Combinational Circuits
- CS1102 Introduction to Computer Studies Lecture 2: Binary Number System PDF
- IMC Computer Science and Law Fall/Winter Term 2024-2025 PDF
Summary
This document is a lecture on Introduction to Computer Studies, CS1102, at the City University of Hong Kong for Semester A, 2024-2025. The lecture agenda includes an introduction and logistics section, an overview of the course, the evolution of computer age, problem solving, and programming and languages.
Full Transcript
CS1102 Introduction to Computer Studies Not to be redistributed to Course Hero or any other public websites Lecture 01 Introduction Semester A, 2024-2025...
CS1102 Introduction to Computer Studies Not to be redistributed to Course Hero or any other public websites Lecture 01 Introduction Semester A, 2024-2025 Department of Computer Science City University of Hong Kong 1 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 2 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 3 Teaching Patterns Lectures (3 hours per week) – Explain the terminologies, concepts, methodologies Labs (1 hour per week) – Hands-on programming activities and discovery exercises We DO NOT provide zoom recording of lectures or labs Howard Leung / CS1102 Lec 01 4 Teaching Team 2 Lecture Sessions at LT-17: – Prof. LUO, Yuhan (C02/CB2/CC2), Monday 15:00 – 17:50 PM – Prof. LEUNG, Howard (C01/CA1/CB1/CC1) Thursday 15:00 – 17:50 PM 10 Lab Sessions: – YEUNG B7510 (make sure you know where it is before attending the first lab) – Check the schedule of your lab session – Additional help from our graduate students and undergraduate student helpers Howard Leung / CS1102 Lec 01 5 Course Intended Learning Outcomes (CILO) 1. Describe the basic principles of computer systems, networks, Internet and information security; 2. Inquire and evaluate the social, ethical, and safety issues of emerging technologies and innovations; 3. Demonstrate the use of software tools and the ability to write simple programs using a scripting language (e.g., JavaScript); 4. Apply basic programming concepts and trace the execution of simple computer programs. Howard Leung / CS1102 Lec 01 6 Course Materials All materials related to this course will be posted on the Canvas course page https://canvas.cityu.edu.hk/courses/60287 It is your own responsibility to check for updated information and announcements on Canvas The instructors may send emails to students for issues related to this course, so check your email regularly and reply promptly in case we ask you to do something Howard Leung / CS1102 Lec 01 7 Canvas Page Howard Leung / CS1102 Lec 01 8 Textbook Computing Essentials 2023, by Timothy J. O'Leary, Daniel A. and Linda I. O'Leary, McGraw Hill Education, ISBN: 978-1-264-13678-0 (bound edition), ISBN: 978-1-266- 53478-2 Howard Leung / CS1102 Lec 01 9 Assessment Patterns Course work (40%) – Post-lab questions (10%) – Midterm (20%) – Project (10%) Examination (60%) Passing Criteria 1. at least 30% of the maximum mark for the examination must be obtained; and 2. at least 35% of the maximum mark for the overall course grade must be obtained Howard Leung / CS1102 Lec 01 10 Lecture Schedule Lectures + course review in the final week Midterm scheduled on Saturday 26 October 2024 (Week 8) at 7:30pm-8:30pm on campus Howard Leung / CS1102 Lec 01 11 Midterm The Midterm Test will take place on Saturday 26 October 2024 (Week 8) at 7:30pm-8:30pm tentatively on campus. Students are expected to take the midterm test in person on campus. Absence without valid reason will have zero mark. Makeup midterm will not be available unless you have acceptable justification with supporting document, and have followed the official channel in submitting your mitigation request well in advance of the midterm https://www.cityu.edu.hk/arro/asmt/mitg_main.htm If you have any conflicts on the Midterm date, please post a message on this discussion thread and justify why you cannot make it Any time conflicts with the CS1102 midterm test date and time should be reported here on or before 15 September 2024 in order for us to consider making alternative arrangements. More details about midterm will be announced later Howard Leung / CS1102 Lec 01 12 Project Students are expected to form groups with other students in the same lab session (with a normal group size of 4 students) to work on the project The group should study a particular CS-related topic (chosen from a list to be given later) and do their own exploration Some example project topics from last years: Our Experience in 3D Character Animation Our Experience in Creating the Digital Twin of Our Lecture Theatre Customizing a ChatBot with ChatGPT … Timeline – Finalize group members and project topic in the mid semester – Submit required deliverables (a webpage & video) at the end of the semester More details about the project will be announced later Howard Leung / CS1102 Lec 01 13 Lab Schedule and Topics 12 labs in total throughout the semester Focuses on Scratch programming, HTML, CSS, and JavaScript Students should complete the post-lab questions after each lab before the posted deadline in order to receive marks Note that the schedule of Lab 03 and Lab 04 for Mon, Tue, and Wed sessions are different! Howard Leung / CS1102 Lec 01 14 Lab Information (1) Hands-on programming activities and discovery exercises will be given in the weekly 1-hour lab session in person Complete a particular lab in class in that week Do the work yourself, and follow the lab instructions step by step, especially if this is your first programming course Try to come up with the code yourself as much as possible – Do not be afraid of making mistakes, since debugging (finding out where your code goes wrong and fixing it) is part of the learning process Howard Leung / CS1102 Lec 01 15 Lab Information (2) We do not give out model programs to the exercises – There can be multiple ways to write the code that solves the same problem – You should build up the program logic yourself instead of copying code that you do not understand – Feel free to ask the instructor, tutor, or teaching assistant and we will be very happy to help you The lab tasks are designed to be relatively simple – Think about the related underlying concepts – Discover things on your own which may not be specified in the tasks – Explore and maximize your learning experience – Do not rush into things Howard Leung / CS1102 Lec 01 16 Lab Information (3) Around 200 students from various colleges and departments have enrolled in this course so students have diverse background (e.g., have already taken ICT, no prior experience in computer technologies, etc.). If you feel that A) The tasks are NOT trivial – Take your time to read the instructions and work on the tasks – Feel free to ask the teaching assistants for any questions – No need to compete with other students who may require less time to finish the tasks B) The tasks are trivial – Explore around to discover things that we have not covered – If you feel that the lab activities are too simple for you, notify the course leader Prof. Howard Leung by email [email protected] and we will design more challenging tasks for you Howard Leung / CS1102 Lec 01 17 Misconception 1 Misconception The lab content should cover the same topic as the lecture delivered in the same/previous week Fact The lab is focused on programming while the lecture is focused on terminologies, concepts, etc. While some labs have close relations with the corresponding lectures such as binary number, Boolean, conditionals, loops, etc. Other labs may contain hands-on exercises for training students’ programming skills and may not have direct relation with the lecture in the same/previous week Howard Leung / CS1102 Lec 01 18 Misconception 2 Misconception No need to read the details of the lab instructions in order to complete the lab tasks Fact It may be true that some students who are very smart Some students however ignore the details of the lab instructions even if they are not very strong in programming (e.g., just reading the figures and/or simply copy the sample code the corresponding descriptions), which is NOT good as they may not be able to put the pieces together, or they may do the tasks incorrectly Howard Leung / CS1102 Lec 01 19 Misconception 3 Misconception Being able to finish all tasks and getting high marks in the post-lab questions indicates a good mark in midterm/exam Fact Students should take the time to think about the related underlying concepts in completing the lab tasks Students should complete all tasks in class or after class and re-do them if necessary until they have a complete understanding If a student just rushes into completing the lab tasks and leaves as soon as possible, then they may not have deep understanding of the related concepts, and may not be able to do well in midterm/exam Howard Leung / CS1102 Lec 01 20 Misconception 4 Misconception You can master programming skills by merely looking at the sample code Fact Looking at sample code is the first step in learning programming, but not sufficient to master programming skill Mastering programming skill is all about trials and errors Students should work on the lab tasks by themselves if they want to be a programming master, and this course is just a starting point Howard Leung / CS1102 Lec 01 21 Misconception 5 Misconception Anyone can easily pass this course without putting in any effort Fact Some students may have already learnt some CS knowledge, however, there are always materials that you have not learnt before. The amount of new materials varies with each student depending their previous background It will be very risky for a student to take the exam without any preparation and they may fail Howard Leung / CS1102 Lec 01 22 Misconception 6 Misconception One can pass this course as long as the exam mark is over 30 (out of 100) Fact Getting over 30% in the exam is only one of the conditions in passing this course. There is another condition that the overall course grade should be at least 35% If a student obtains 50 (out of 100) in the exam, they may still fail the course if they have 0 in the coursework grade Howard Leung / CS1102 Lec 01 23 Misconception 7 Misconception Students can drop this course any time before the teaching period Fact The last day for course add/drop is 9 September 2024 (Monday) Afterwards, students may request for late drop, but it will only be approved under exceptional circumstances, an X grade will be assigned for the course and printed on the student’s transcript Normally late drop request after Week 6 would not be considered Howard Leung / CS1102 Lec 01 24 How Can You Become More Effective Learner? Take initiative in your learning Be prepared to the class (read the materials before hand) Attend and participate in both lecture & lab Submit assignments on time Do the work on your own Do not be afraid of making mistakes Don't be afraid of asking questions Refrain from academic dishonest behavior Howard Leung / CS1102 Lec 01 25 When you have questions During the lecture and lab, you can raise your hand to ask questions You can check out the Discussion on Canvas to see if other students have asked the same question. If not, then you can post your question. In case your question is more personal, then you can send email via Canvas to the Course Leader or your lab tutor Howard Leung / CS1102 Lec 01 26 Tips on writing email Put down a meaningful subject (do not leave it blank) Send the email via Canvas In the message, first address the person whom you are writing to Be concise about your message Be courteous At the end of the message, put down your name Proofread your message to make sure that there is no error and that your message is clear before sending out Howard Leung / CS1102 Lec 01 27 Ask questions on Canvas We have hired an undergraduate student helper who has taken CS1102 before to help answering current students’ questions posted on the Canvas Discussion: https://canvas.cityu.edu.hk/courses/60287/discussion_topics so feel free to post your questions there Howard Leung / CS1102 Lec 01 28 What if you would like additional help? Programming Clinic – Consultation sessions from the programming clinic will be arranged every week, from week 4 to week 13 – Dedicated student helper will stand-by in the CS laboratory and help those walk-in students to solve problems regarding general programming (Java/C++/C...), web programming (JavaScript/HTML...), data structures as well as fundamentals of computing (digital circuit, binary number...) – Time-table will be available at http://courses.cs.cityu.edu.hk/clinic/ Howard Leung / CS1102 Lec 01 29 How Much Time You Should Spend on This Course? According to University Guide, 1 credit unit = 40 to 50 hours (including lecture, tutorial/lab, self study) This course has 3 credit units, which translates to 120 to 150 hours per semester or 10 hours per week As you spend 4 hours on lecture and lab, you should spend about 6 hours self-study and practice Howard Leung / CS1102 Lec 01 30 Academic Honesty https://www.cityu.edu.hk/pvdp/ah/ah-rules.htm Academic honesty is central to the conduct of academic work Students are expected to present their own work, give proper acknowledgement of other’s work, and honestly report findings obtained Academic dishonesty is regarded as a serious academic offence in the University. Any related offence may lead to disciplinary action with a penalty including without limitation, expulsion from the University, debarment from re-admission, deprivation of an academic award already conferred or revocation of a certification granted Howard Leung / CS1102 Lec 01 31 Academic Dishonesty https://www.cityu.edu.hk/pvdp/ah/ah-rules.htm Academic dishonesty includes but is not restricted to the following behaviors: – Plagiarism, e.g., the failure to properly acknowledge the use of another person’s work, submission for assessment material that is not the Student's own work, or submission of substantially the same material (even a portion) for credit in more than one assessment task without proper acknowledgement; – Misrepresentation of a piece of group work as the Student's own individual work; – Collusion, i.e., allowing another person to gain advantage by copying one's work or working with another student during an individual assessment; – Unauthorized access to an examination/test paper; – Possession/use of unauthorized material in assessment; – Unauthorized communication during assessment; – Use of fabricated data claimed to be obtained by experimental work, or data copied or obtained by unfair means; – Impersonating another Student at a test or an examination or allowing oneself to be impersonated; – Contract cheating, e.g., employing or using services provided by a third party in grade coursework or at a test or an examination; – Use of fraudulent documents and/or information to gain advantage for any academic work, e.g. submission of a fraudulent medical certificate to request for a make-up examination Howard Leung / CS1102 Lec 01 32 Academic Honesty Case Studies (1) https://www.cityu.edu.hk/ah/Tutorial/casestudy Case 1 Chi Wai did some research on the Internet and found some useful sources for his assignment. He used the ideas from these sources but forgot to cite the sources in the text of his assignment and provide a reference list. Case 2 Mia searched the Internet and found a useful diagram. She modified the diagram and included it in her assignment, but did not cite and reference the source. Case 3 Nick handed in the same assignment for more than one subject/course for credit. Case 4 Tom handed in the same assignment which was submitted during his first attempt of a course when he retook the same course. The assignment in his first attempt was, however, not marked and did not contribute to the final course grade of his first attempt of the course. Case 5 Xiaobo copied his assignment from a classmate’s work, put his own name on it and submitted it to his teacher. Howard Leung / CS1102 Lec 01 33 Academic Honesty Case Studies (2) https://www.cityu.edu.hk/ah/Tutorial/casestudy Case 6 Kit gave Suki his assignment and Suki copied it, put her own name on it, and submitted it to her teacher. Case 7 Chloe and Eason worked on an individual assignment together. They each did a different part of the assignment. Then, they shared their work, put their own name on the assignment and individually submitted the work to their teacher. Case 8 Ming and Doris discussed some ideas about how to do an individual assignment. Then, they completed the assignment on their own, without looking at each other’s work. They put only their own name on their assignment and individually submitted their work to their teacher. Case 9 Peng reported that he was contacted by Sasha via a mobile app to ask for advice on examination questions during an online examination. Case 10 Douglas felt that he did not get along with his groupmates and decided to only put his name in a group project for submission. Howard Leung / CS1102 Lec 01 34 Selected Useful Tips to follow Principles of Academic Honesty https://www.cityu.edu.hk/ah/Tutorial/tips Start early and manage your time (Tip 1) Do your own work (Tip 7) Follow the same principles for online/open-book assessment (Tip 8) Do not give a ‘reference’ copy of your work to someone (Tip 9) Ignorance is no excuse (Tip 12) You are not a child anymore and you have the intelligence to enter university so you Your Honor, nobody has ever told should have known better me what I did was wrong. Also, I what is right and wrong. Just have seen others doing the same because you see other people thing so I should not be guilty! doing bad things does not provide justifications for you to do the same. I therefore find you guilty! Howard Leung / CS1102 Lec 01 35 DO NOT redistribute course materials You do not own the copyright of the course materials even though you can download them from Canvas course page So, you SHOULD NOT redistribute any of the course materials to anyone else who are not taking this course, e.g., you SHOULD NOT upload any course materials to websites such as Course Hero If you are in doubt, first check with the course leader ([email protected]) CS1102 Course materials Howard Leung / CS1102 Lec 01 36 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 37 Binary Number System Computers process information based on binary numbers. Conversion between the decimal and binary numbers. Operations in binary numbers. The Digital Computer (Bits and Bytes, Episode 1) https://www.youtube.com/watch?v=AdF2uk-EscE Classic Video from 1983 Howard Leung / CS1102 Lec 01 38 Boolean Logic A form of algebra with operations to work with values that are either True or False, often denoted by 1 or 0 respectively Howard Leung / CS1102 Lec 01 39 Computer Programming In this course, we will learn with – block-based programming (Scratch) which makes it easier for beginners to understand program logic without worrying about syntax – text-based programming (Javascript) which is closer to real-world programming Why Computational Thinking and Coding is Important Howard Leung / CS1102 Lec 01 https://www.youtube.com/watch?v=TPgXTNMKmNs 40 Computer System Computers are electronic devices that can follow instructions to accept input, process data, and produce information Input Device System Unit Output Device Secondary Storage Howard Leung / CS1102 Lec 01 41 Internet and WWW How the Internet Works in 5 Minutes Howard Leung / CS1102 Lec 01 https://www.youtube.com/watch?v=7_LPdttKXPc 42 Privacy, Security and Ethics Privacy concerns the collection and use of data about individuals Computer security focuses on protecting information, hardware, and software from unauthorized use as well as preventing damage from intrusions, sabotage, and natural disasters Computer ethics are guidelines for the morally acceptable use of computers in our society Howard Leung / CS1102 Lec 01 43 Digital Media Digital Audio Digital Image … … Frame Frame Frame Frame Frame n-1 Frame n 1 2 3 4 44 Digital Video Howard Leung / CS1102 Lec 01 44 Human-Computer Interaction We cover the basic concepts of human-centered computing, design thinking, and data visualization You will learn how to design user-friendly interfaces and conduct evaluation studies https://youtu.be/_r0VX-aU_T8 Howard Leung / CS1102 Lec 01 45 Course overview Binary Number System Boolean Logic Computer Programming Computer System Internet and WWW Privacy, Security and Ethics Digital Media Human-Computer Interaction Howard Leung / CS1102 Lec 01 46 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 47 Predecessors Jacquard Loom: created by Joseph Marie Jacquard to weave cloth using punch cards in the 18th century Charles Babbage: designed the first mechanical computer although he did not get it to work at his time https://www.computerhope.com/jargon/j/jacquard-loom.htm https://en.wikipedia.org/wiki/Charles_Babbage Howard Leung / CS1102 Lec 01 48 First Generation (1951-57) Computers were built with vacuum tubes – electronic tubes that were made of glass and were about the size of lightbulbs Howard Leung / CS1102 Lec 01 49 Second Generation (1958-63) The first computers built with transistors – small devices that transfer electronic signals across a resistor Faster, smaller, and more reliable than the first-generation machines Howard Leung / CS1102 Lec 01 50 Third Generation (1964-69) Computer manufacturers replaced transistors with integrated circuits – complete electronic circuits on a small chip Moore’s Law (Transistor Count, 1965) of silicon More reliable and compact than computers made with transistors Howard Leung / CS1102 Lec 01 51 Fourth Generation (1970-90) Microprocessor – a specialized chip developed for computer memory and logic Use of a single chip to create a smaller “personal” computer revolutionized the computer industry https://en.wikipedia.org/wiki/Windows_3.0 Howard Leung / CS1102 Lec 01 52 Fifth Generation (1991-2021 and beyond) “Connected Generation” – the rapidly expanding Internet, World Wide Web, and intranets have created an information superhighway Howard Leung / CS1102 Lec 01 53 Fifth Generation (2) Howard Leung / CS1102 Lec 01 54 Fifth Generation (3) Howard Leung / CS1102 Lec 01 55 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 56 What Can You Do with Programming? You are not in CS major, and you most likely would not work as a Software Engineer as your future career. Is there any situation in which you can write a program and make good use of it? Howard Leung / CS1102 Lec 01 57 What Can You Do with Programming? You are not in CS major, and you most likely would not work as a Software Engineer as your future career. Is there any situation in which you can write a program and make good use of it? “All things are numbers” –Pythagoras Howard Leung / CS1102 Lec 01 58 Case study: Buffon’s Needle Problem (1) Suppose we have a floor made of parallel strips of wood, each the same width t, and we drop a needle of length l onto the floor. What is the probability that the needle will lie across a line between two strips? Image from Wikipedia Howard Leung / CS1102 Lec 01 59 Case study: Buffon’s Needle Problem (2) Suppose we have a floor made of parallel strips of wood, each the same width t, and we drop a needle of length l onto the floor. What is the probability that the needle will lie across a line between two strips? It might not be intuitive to derive the answer using mathematical induction Image from Wikipedia Howard Leung / CS1102 Lec 01 60 Case study: Buffon’s Needle Problem (3) Suppose we have a floor made of parallel strips of wood, each the same width t, and we drop a needle of length l onto the floor. What is the probability that the needle will lie across a line between two strips? However, we can approximate the solution by computer simulation Image from Wikipedia https://mste.illinois.edu/activity/buffon/ Howard Leung / CS1102 Lec 01 61 Finding the solution to Buffon’s needle problem The ultimate solution 2 𝑙𝑙 (𝜋𝜋 𝑡𝑡 ) may be difficult to understand Mathematical derivation −→ Theoretical results Computer simulation −→ Empirical results Empirical results indicate the A sample JavaScript theoretical ones and will converge given code to simulate the large amount of Buffon's needle simulations. problem Howard Leung / CS1102 Lec 01 62 Case study: Currency exchange (1) Use USD and HKD as an example. Let’s consider the simplest strategy: sell USD for HKD when USD/HKD is higher than a threshold t1 and sell HKD for USD when USD/HKD is lower than a threshold t2. How to properly set t1 and t2? Howard Leung / CS1102 Lec 01 63 Case study: Currency exchange (2) Use USD and HKD as an example. Let’s consider the simplest strategy: sell USD for HKD when USD/HKD is higher than a threshold t1 and sell HKD for USD when USD/HKD is lower than a threshold t2. How to properly set t1 and t2? It might be hard to set an appropriate values, but we could visualize the historical data to get an idea! Howard Leung / CS1102 Lec 01 64 Case study: Currency exchange (2) Use USD and HKD as an example. Let’s consider the simplest strategy: sell USD for HKD when USD/HKD is higher than a threshold t1 and sell HKD for USD when USD/HKD is lower than a threshold t2. How to properly set t1 and t2? Suppose that the person wants to trade t1 within this week t2 with moderate risk tolerance Howard Leung / CS1102 Lec 01 65 Life is about Making Choices In fact, if you can model a situation by quantifying it with various parameters, then you could write a program to run simulations in order to determine the potential outcome or identify the best option among a number of possible choices Programming may help you make smarter choices in your life! Howard Leung / CS1102 Lec 01 66 Other potential benefits of knowing programming as a non-CS major student (1) Broadening career possibilities If you want to work in a tech company (e.g., product manager, an interaction designer), knowing basic programming concepts can help you better understand the product and more efficiently communicate with developers Howard Leung / CS1102 Lec 01 67 Other potential benefits of knowing programming as a non-CS major student (2) Personal growth Enhancing your problem-solving skills (e.g., quickly processing large amounts of data) Boosting creativity: if you have an idea about developing an app or website, you’re more likely to realize it if you know how to program Programming languages are becoming universal (e.g., scholars write code in latex, accountants can run excel commands to execute queries) Howard Leung / CS1102 Lec 01 68 Agenda Introduction & Logistics Course overview The evolution of the Computer Age Problem solving with programming Programming and languages Howard Leung / CS1102 Lec 01 69 Software Development Life Cycle Programming, also known as software development, typically follows a six-step process known as software development life cycle (SDLC) Howard Leung / CS1102 Lec 01 70 Step 1: Program Specification Also known as program definition or program analysis Require the programmer or the end user to specify 5 items: Example: “I want a time-and-billing system to record the time I spend on different jobs for different clients of Advantage Advertising” Example: Add the hours worked for different jobs for different clients Record program objectives, desired outputs, Howard Leung / CS1102 Lec 01 needed inputs, required processing 71 Step 2: Program Design Several design strategies 1. Top-down program design 2. Pseudocode 3. Flowcharts 4. Logic structures Howard Leung / CS1102 Lec 01 72 Step 2: Program Design - Top-Down Program Design Identify the program’s processing steps called program modules (or just modules) Each module should have a single function Howard Leung / CS1102 Lec 01 73 Step 2: Program Design - Pseudocode Outline of the logic of the program, like a summary of the program before it is written Pseudo is between the real code and the human language Howard Leung / CS1102 Lec 01 74 Step 2: Program Design - Flowchart Graphically present the detailed sequences of steps needed to solve a programming problem Howard Leung / CS1102 Lec 01 75 Step 2: Program Design - Logic Structures Various parts of the flowchart can be linked using a combination of 3 logic structures: sequential, selection (conditional) and repetition (loop) Sequence Selection Repetition Howard Leung / CS1102 Lec 01 76 Step 3: Program Code Use the logic developed in the program design step to actually write the program A good program should be – Reliable: work under most conditions to produce the correct output and catch obvious and common input errors – Well documented and understandable by programmers other than the person who wrote it Howard Leung / CS1102 Lec 01 77 Step 4: Program Test Debug: test and eliminate errors, i.e., get the bug out 2 types of programming errors 1. Logic Errors: Programmer uses an incorrect calculation or leaves out a programming procedure, e.g., a payroll program that did not compute overtime hours 2. Syntax Errors: Violation of the rules of the programming language Howard Leung / CS1102 Lec 01 78 Step 4: Program Test - Testing Process Desk Checking – A programmer sitting at a desk checks (proofreads) a program line by line carefully looking for syntax errors and logic errors Manually testing with sample data – A programmer follows each program statement and performs every calculation using sample data to identify logic errors Attempt at translation – The program is run through a computer using a translator program which attempts to translate the written program from the programming language (such as C++) into the machine language – Before the program will run, it must be free of syntax errors that can be identified by the translating program Testing sample data on the computer – After all syntax errors have been corrected, the program is tested for logic errors using sample data Testing by a select group of potential users – Sometimes called beta testing in which potential users try out the program and provide feedback Howard Leung / CS1102 Lec 01 79 Step 5: Program Documentation Documentation consists of written descriptions and procedures about a program and how to use it Program documentation should be carried on throughout all the programming steps. In this step, all prior documentation is reviewed, finalized and distributed Documentation is important for all people who may be involved with the program in the future including users, operators, programmers Howard Leung / CS1102 Lec 01 80 Step 6: Program Maintenance Ensure that current programs are operating error-free, efficiently and effectively Programming modifications or corrections are often referred to as patches. Important patches are known as software updates Some projects may start before all requirements are known so the software development life cycle becomes a cyclical process Howard Leung / CS1102 Lec 01 81 Commonly Used Programming Languages A programming language uses a collection of symbols, words, and phrases that instruct a computer to perform specific operations Language Description C++ Extends C to use objects or program modules that can be reused and interchanged between programs C# A programming language designed by Microsoft to extend C++ for developing applications in the Windows environment Java Primarily used for Internet applications; similar to C++; runs with a variety of operating systems JavaScript Embedded into web pages to provide dynamic and interactive content Python General-purpose programming language that is simple and easy to learn. Frequently used in introductory programming courses Swift Uses graphical user interface and special code for touch screen Howard Leung / CS1102 Lec 01 interfaces to create apps for Apple iOS devices 82 Generations of Programming Languages Generations of programming languages range from “low” to “high” Lower level programming languages are closer to the language the computer itself uses Higher level programming languages are closer to the language humans use 5 generations of programming languages 1st Generation: Machine languages Data represented in 1s and 0s 2nd Generation: Assembly languages Uses abbreviations or mnemonics that are automatically converted to the appropriate sequence of 1s and 0s 3rd Generation: High level procedural languages (3GLs) Designed to express the logic – the procedures – that can solve general problems. Translated into machine language with a compiler or an interpreter 4th Generation: Task-oriented languages (4GLs) Designed to solve specific problems 5th Generation: Problem and Constraint languages (5GL) Computer languages that incorporate the concepts of artificial intelligence to allow a person to provide a system with a problem and some constraints and then request a solution Howard Leung / CS1102 Lec 01 83 Sample Statements Generation Sample Statement First: Machine 111100100111001111010010000100000111000000101011 Second: Assembly ADD 210(8,13),02B(4,7) Third: Procedural if (score > = 90) grade =‘A’; Fourth: Task SELECT client FROM daily Log WHERE serviceEnd >17 Fifth: Problems and Get patientDiagnosis from patientSymptoms "sneezing", Constraints “coughing” “aching” Howard Leung / CS1102 Lec 01 84 Different Programming Philosophies Procedural Programming: a series of computational steps to be carried out. Any given procedure might be called at any point during a program’s execution, including by other procedures or itself. C, Pascal, Fortran Objective-Oriented Programming: based on the concept of “objects” which contains data and code. The data is in the form of fields / attributes / properties, and the code is in the form of procedures / methods / functions. Programs are based on the objects that interact with one another. C++, C#, Java, Python, Swift Functional Programming: constructed by applying and composing functions. Function definitions are trees of expressions that map values to other values, rather than a sequence of imperative statements which update the running state of the program. Scala, Ocaml, Erlang Howard Leung / CS1102 Lec 01 85 Reading Computing Essentials 2023 – Chapter 13 – The Evolution of the Computer Age, p.347-357 Howard Leung / CS1102 Lec 01 86