Blazek Demystifying Programming: Programming for Non-Programmers

Blazek – Demystifying Programming: Programming for Non-Programmers Welcome This material was written with you in mind. It is being distributed in pdf ...
Author: Solomon Scott
0 downloads 1 Views 148KB Size
Blazek – Demystifying Programming: Programming for Non-Programmers Welcome This material was written with you in mind. It is being distributed in pdf format at this time and is undergoing revision. Sample code and exercise code is also available in self-extracting zip format. When you select the links below, text chapters will appear in the browser (adobe pdf plug-in). To save a copy of the chapter to your disk, select the save option on the menu. When you select the code links below, you will be given the options of saving or opening the self-executing zip file. Save this file to your disk into a folder named for the chapter to which it relates. For chapter 6, place the file in a folder named ch6. Then double click the file to automatically extract the files it contains. Overview: Demystifying Programming is a direct response to the needs of the students in my classroom and our program. Non-programming students usually have no prior programming experience and have chosen a non-programming major. They usually have a low level of intrinsic motivation for studying programming. This large group of computer studies students requires a paradigmatic shift in approach to logic and programming from that commonly taken by other textbooks. The approach of Demystifying, as implied in the title, is practical, manageable, and incremental. Each item included has been selected on the basis of its direct contribution to the goal of clarifying and motivating this type of student. The textbook introduces programming logic and design and uses the basics of Java to apply and illustrate good programming logic and style. Early chapters give priority to logic. As the book progresses, more emphasis is given to language elements. Outstanding Features: Textbooks on this subject either assume background or deep interest in the subject of programming. Assuming neither, this book takes a minimalist and incremental approach providing follow-through to logic and design principles in the form of simple, practical Java applets and applications. Students benefits from a controlled, incremental approach. No more language details than are necessary for application of programming logic are introduced at any one time. Language features, tools, and mechanisms are introduced in an additive fashion. It is pedagogically sound to build new layers of detail on those previously presented and mastered. The results are more motivated and successful student performance. Pedagogy: The pedagogy that drives Demystify is that of isolation and repetition. Each chapter is intentionally short and readable. Each chapter introduces a single concept and provides multiple examples and carefully guided opportunities for the student to work with the concept in focused practice. This minimalist approach to the language, although not the usual one seen, is welcomed by students and is carefully crafted to avoid distorting the elements of logic and language presented. The concepts are developed in an incremental manner allowing the student to see a controlled progression through fundamentals. A problem-solution orientation draws the student to seek and discover solutions that work. Each chapter includes valuable examples. Code is syntax colored to emphasize the key words and patterns that make understanding the language easier. Two colors are required. Simple line drawings illustrate as appropriate. Screen shots of running programs and compiler and runtime errors are included. Inline exercises allow students to immediately test their understanding of an idea before continuing with the remainder of the chapter. Each chapter includes tasks specifically focused on the chapter concept. The tasks are staged and classified as “Design”, “Code Analysis”, “Complete the

Code”, “Code to Mend”, “Code Exercises”, and “Review Questions”. In the same way as the text, the exercises guide the student in a step-wise fashion from thinking, to recognition, to production of isolated small units of code in a provided context, to practical debugging, and finally to more comprehensive problem solving. Each chapter also contains one or more “Challenge” inserts, designed to entice the student to apply what has been learned in a new way, to experiment with options, or to research and extend the concept under discussion. Reference is made to several supplemental language elements which are briefly explained and illustrated in appendixes. Each chapter begins with an outline and behavioral objectives. The previous logic and language elements are reviewed. Each chapter ends with a review and an index of key terms and concepts. A “Patterns” section is included in each chapter. The purpose is to assist the learner in recognizing and mastering the pattern that pervades the many examples seen. The ability to view a concrete problem and solution in abstract, repeatable patterns offers a significant simplifying advantage to a student faced with what at first appears to be dozens of learning challenges. Although this text is open to serious editing or revision, it exists in a complete form and has been class-room tested at Robert Morris College by the author and other instructors. It is the product of clear pedagogical understanding and practical class-room experience. This book is intended for students with little or no programming background. It was written to support and motivate those not seriously considering programming as a life goal. It is believed that this approach will appeal to and provide a superior foundation for students who are intrinsically motivated to learn programming. However, it requires no prerequisite programming skills.

The Outline

Demystifying Programming: Table of Contents Detailed

Chapter One: Programming Is Clear Thinking Objectives Tools Input/Process/Output Model and UML Class Diagram Logic Separating input, process, and output in problem solving Background The Java Language – swing is good Language Plan before coding, coding, compiling, executing, and testing Review Exercises Chapter Two: Coding is Putting Thinking into Practice Objectives Class encapsulation- A class is a self-contained unit Compiling step 1: javac.exe compiler. 2: Java Virtual Machine Importing classes and code reuse Compiling and Executing Methods init Language Patterns: declaration, instantiation, add, setText Tips Comments Java Key Words Exercises Chapter Three: Variables Objectives Variables Semantic links to memory locations Problem Solving with Variables A new level of abstraction Language Assignment with int and String Review Concepts Exercises Chapter Four: Action Event Model Objectives

Additional GUI components JLabel, JTextField Inductive Pause Learn from observation Events and Interaction import event library, implements ActionListener, register a listener, event handler Review Concepts Challenge Java Key Words Exercises Chapter Five: Classes Revisited-Pseudocode Objectives Design Methods, sequence, and pseudocode Class Additional classes in the same file; cooperation and collaboration, GUI and non-GUI classes, UML Class Diagram (instance variables and methods) Answers to thought questions Exercises Chapter Six: Methods Objectives Methods void or return; parameters, invocation, passing by value GUI JButton Patterns Review Challenge Java Key Words Exercises Chapter Seven: Decisions Objectives Design Functional analysis with pseudocode Decisions The logic of decisions in life Variables as abstractions initialization, float and double Review Challenge Exercises Chapter Eight: Coding Decisions Objectives Casting Converting; toString method Wrapper.parse Flexibility Order of Precedence and Process Control parentheses, using a counter Language Comparison operators; conditional statements with else Decision Example Event Methods getSource method Debugging Isolation by Insertion Four step debugging Patterns decisions Review Exercises Chapter Nine: Show What You Know Objectives Design Tools and Principles Language Example and Review Patterns Challenge Exercises Chapter Ten: Classes Revisited, Repetition with while Objectives Design Controlled repetition process pseudocode Repetition while loop Patterns while loop

Language GUI-Font and Color class reuse, setFont method, setForeground and setBackground methods Review Control structures for repetiton Challenge Exercises Chapter Eleven: Repetition for-loop Objectives Design Loop revisited; for loop controls stated up front Language The awesome for loop Patterns New Language GUI Component JScrollPane Preventing overflow Review Challenge Exercises Chapter Twelve: GUI Controls Objectives Design Prototyping GUI Components FlowLayout, GridLayout, BorderLayout, JPanel Patterns Review Challenge Exercises Chapter Thirteen: NON-GUI Classes Objectives Design Methods for non-GUI classes Constructor method; Class observer methods Patterns Language Review Challenge Exercises Chapter Fourteen: Data Structures with Arrays Objectives Design The List – linear order, count, search, add, remove, and reorder logic Language Array compared/contrasted with variables; declaring, instantiating, assigning to arrays, viewing elements of an array; Adding to an array-based list Patterns Creating a List using an Array Review Exercises Chapter Fifteen: List of Objects with Arrays Objectives Viewing a List (iterate) Summing a List An Array-based List can include any class Preventing an Array Overflow Review Challenge Challenge Exercises Chapter Sixteen: Add and Search an Array Objectives Design and Implementation A List can include any Class of objects Add Search String method equals; comparing objects Patterns Exercises

Chapter Seventeen: Sort and Remove an Array Objectives Design and Implementation Sort Sorting numbers or Strings, Remove Warning: ArrayIndexOutOfBoundsException; copying objects – Copy Constructor, Polymorphism Sorting Objects Patterns Sort pattern; remove pattern Exercises Chapter Eighteen: Applications Objectives Design Concepts The java.exe interpreter and security issues Applications The method main, super method, JFrame, compiling and executing an application, setSize, setVisible, and setDefaultCloseOperation methods Patterns Six steps to applications Challenge JMenu Exercises Chapter Nineteen: Exception and Error Handling Objectives Design to Prevent Errors/Exceptions By contract and programmer responsibilities, NumberFormatException, Responding to Errors with Try-Catch Blocks, JOptionPane Challenge Review Exercises Chapter Twenty: Writing Text Files Objectives Design data streams Language io import, PrintWriter, FileWriter, print and close methods, requires try/catch block IOException Review Challenge Exercises Chapter Twenty-One: Reading Text Files Objectives Language BufferedReader, FileReader, readLine method Review Exercises Chapter Twenty-Two: StringTokenizer Objectives Design Language StringTokenizer, nextToken method Review Three step processing Challenge Exercises Chapter Twenty-Three: Advanced GUI Features Objectives Language JCheckBox, JRadioButton, JComboBox, JSlider, anonymous ChangeListener Event, boolean, getSelected method, common GUI methods Review Challenge JMenu Exercises Appendixes Appendix Polymorphism Appendix JOptionPane showMessageDialog showOptionDialog

Getting User Input from a Dialog Appendix_Anonymous_Instances and Anonymous Inner Classes Appendix JFileChooser Code Samples Index