1 / 17

CS 102

CS 102. Programs/Algorithms. Overview. Computer Architecture What is a computer program? Flow chart Data states Data Variables History – Why VB? Procedural programming Object oriented programming Visual programming Example: Hello world. Computer Architecture. Drawn in figure 1-1

cynthiah
Download Presentation

CS 102

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. CS 102 Programs/Algorithms

  2. Overview • Computer Architecture • What is a computer program? • Flow chart • Data states • Data • Variables • History – Why VB? • Procedural programming • Object oriented programming • Visual programming • Example: Hello world

  3. Computer Architecture • Drawn in figure 1-1 • Main components: • CPU • Main memory • Secondary storage • Input devices • Keyboard • Mouse • Scanner • Camera (still/video/webcam)

  4. Computer Architecture • Main components (contd): • Output devices • Monitor • Printer • Software • Operating System • Application Programs

  5. What Is A Computer Program? • Set of tasks/instructions • Related? • How? • Set of data (states) • Can be in main memory (temporary) • Can be persistent • Long-term • Often stored in a database or data file

  6. Flow Charts • Help visualize the flow of the program. Shows mainly the instructions and decisions • Is a blueprint for the logic in how to write the program • Historically, different symbols used for different types of logic • Variable assignment • Decisions

  7. Flow Charts • Symbols: • Start/End of program: Ovals • Flow of control: Arrows • Actions: Rectangle • Input/Output: Parallelogram • Conditional: Diamond

  8. Flow Chart Example

  9. State of Data: Variable • Variables are ESSENTIAL in programming • Variables hold things • Data • State • Variables typically have names that are meaningful • Descriptive is better • Older languages only allowed one letter • i, j, etc… • Now they can be as long as needed

  10. Variable Names • Sometimes use underscore (_) • sum_total • number_of_tries • “CamelCasing” • Start each word with a capital letter • No underscores • Ex: • SumTotal • NumberOfTries

  11. Examples • Hello World • No data • No states • Just a control flow • Gross pay calculator • Data: Hours worked, hourly pay rate • Ask them to exit • Or exit button (control)

  12. Examples • Create flowchart on board • Demo of example programs

  13. Programming Methods • Procedural programming • Original style • Set of steps (including Input/Output) • Goes from “Start” to “End” • Can be shown in a flow chart easily • More difficult to reuse code

  14. Programming Methods • Object-Oriented programming • Current style • Create “objects” that mimic real-world things • Ex: Automobile • Objects have properties (data) • Objects have methods (actions) • Car example. What are properties, methods • Properties: Color, Location, Speed, Direction • Actions: Honk horn, Speed up, slow down, turn to right

  15. Visual Programming • Graphical User Interface (GUI) • Many, many objects have been created for visual objects • Makes it easier to program • Looks great • Don’t have to “reinvent the wheel” • Graphical environment to write programs • Graphical environment to debug programs

  16. Event-Driven Programming • GUI programming is event-driven • Screen “sits there” in a loop, waiting for user action • You write “event handlers” that handle each action that might be taken • Button clicks • Typing text • Check a checkbox • Only have to write a little bit of code at a time • Much, much easier to debug!

  17. Demo • Demonstrate graphical version of the two example programs

More Related