Introduction 1 About This Book 1 Foolish Assumptions 2 Icons Used in This Book 2 Beyond the Book 3 Where to Go from Here 3 Book 1: Getting Started with Programming 5 Chapter 1: Getting Started Programming a Computer 7 How Computer Programming Works 8 Identifying the problem 8 Defining the steps 9 The History of Computer Programming 10 Talking to a processor in machine language 11 Using assembly language as a shortcut to machine language 12 Hiding the details of a computer with a high-level language 15 Combining the best of both worlds with the C programming language 15 Weighing the pros and cons of programming languages 16 Figuring Out Programming 18 Desire beats technical training every time 19 Picking a computer and an operating system 19 Writing programs with an editor 21 Converting source code with an assembler or compiler 23 Translating source code with an interpreter 25 Combining a compiler with an interpreter to create p-code 25 Taking the time to understand 26 Chapter 2: Different Methods for Writing Programs 29 Spaghetti Programming 31 Structured Programming 34 The three parts of structured programming 34 Top-down programming 36 Event-Driven Programming 38 Designing a user interface 41 Writing event handlers 42 Writing your program 44 Object-Oriented Programming 44 Isolating data 46 Simplifying modifications 47 Using Protocol-Oriented Programming 49 Design Patterns 50 Chapter 3: Types of Programming Languages 53 Your First Language 54 BASICally disrespected 55 Visual programming with Scratch 56 Programming robots with LEGO Mindstorms 57 Learning object-oriented programming with Alice 57 Programming a killer robot 58 Curly-Bracket Languages 60 Learning programming with C 60 Adding object-oriented programming with C++ 62 Gaining true portability with Java 63 Programming more safely with C# 64 Choosing a curly-bracket language 66 Artificial Intelligence Languages 67 Scripting Languages 71 Automating a program 72 Customizing a program 73 Transferring data among multiple programs 74 Creating stand-alone programs 74 Database Programming Languages 75 Comparing Programming Languages 76 Chapter 4: Programming Tools 77 Choosing a Compiler 78 Defining your needs for a compiler 79 Evaluating the technical features of a compiler 80 Finding an Interpreter 84 Compiling to a Virtual Machine 86 Writing a Program with an Editor 88 Stand-alone editors 88 Integrated development environments 90 Fixing a Program with a Debugger 91 Stepping line-by-line 92 Watching variables 95 Saving Time with Third-Party Components 96 Optimizing a Program with a Profiler 97 Managing Source Code 97 Creating a Help File 99 Installing a Program 99 Dissecting Programs with a Disassembler 99 Book 2: Programming Basics 101 Chapter 1: How Programs Work 103 Using Keywords as Building Blocks 105 Organizing a Program 108 Dividing a Program into Subprograms 109 Dividing a Program into Objects 113 Creating a User Interface 115 Chapter 2: Variables, Data Types, and Constants 119 Declaring Variables 120 Variable naming conventions 121 Creating variables in a command 122 Declaring the data type of a variable 124 Using Different Data Types 126 Storing Data in a Variable 130 Retrieving Data from a Variable 132 Using Constant Values 133 Defining the Scope of a Variable 135 Handling global variables with care 136 Restricting scope to a module 137 Isolating variables in a subprogram 138 Passing data among subprograms 139 Chapter 3: Manipulating Data 141 Storing Data with the Assignment Operator 142 Using Math to Manipulate Numbers 143 Organizing equations with operator precedence 144 Using built-in math functions 146 Manipulating Strings 147 Finding Strings with Regular Expressions 148 Pattern-matching with the single character (.) wildcard 149 Pattern-matching for specific characters 149 Pattern-matching with the multiple-character (*) and plus (+) wildcards 150 Pattern-matching with ranges 151 Using Comparison Operators 153 Using Boolean Operators 156 Using the Not operator 156 Using the And operator 157 Using the Or operator 158 Using the Xor operator 159 Converting Data Types 160 Chapter 4: Making Decisions by Branching 163 Picking One Choice with the IF-THEN Statement 164 Picking Two Choices with the IF-THEN-ELSE Statement 166 Picking Three or More Choices with the IF-THEN-ELSEIF Statement 168 Checking a condition for each set of commands 168 Offering three or more choices 170 Playing with Multiple Boolean Operators 171 Making Multiple Choices with the SELECT CASE Statement 174 Matching multiple values in a SELECT CASE statement 177 Checking a range of values 178 Comparing values 179 Chapter 5: Repeating Commands by Looping 181 Looping a Fixed Number of Times with the FOR-NEXT Loop 182 Using a FOR-NEXT loop variable 183 Counting by a different range 185 Counting by different increments 186 Counting backward 187 Counting over arrays and other items 188 Looping Zero or More Times with the WHILE Loop 189 Looping at Least Once with the DO Loop 192 Playing with Nested Loops 193 Prematurely Exiting from a Loop 195 Checking Your Loops 195 Chapter 6: Breaking a Large Program into Subprograms 197 Creating and Using Subprograms 199 Creating a subprogram 200 "Calling" a subprogram 201 Passing Parameters 203 Passing parameters by reference 206 Storing values in a subprogram name 210 Repeating a Subprogram with Recursion 212 Chapter 7: Breaking a Large Program into Objects 215 How Object-Oriented Programming Works 216 Encapsulation Isolates Data and Subprograms 219 Shielding data inside an object 221 Grouping methods inside of an object 221 Protecting code from other programmers 222 Sharing Code with Inheritance 223 Polymorphism: Modifying Code without Changing Its Name 226 Design Patterns 228 Object-Oriented Languages 230 Hybrid languages 231 Pure languages 231 Disadvantages of object-oriented programming 232 Real-Life Programming Examples 233 Defining an object with a class 233 Creating an object from a class 236 Running methods stored in an object 236 Inheriting an object 238 Using method overloading to rewrite an inherited subprogram 239 Chapter 8: Reading and Saving Files 243 Storing Data in Text Files 243 Creating a text file 246 Reading a text file 247 Storing Fixed-Size Data in Random-Access Files 250 Writing data 251 Reading data 252 Storing Varying-Size Data in Untyped Files 253 Writing data 254 Reading data 255 Using Database Files 257 Looking at the structure of a database 257 Connecting to a database 259 Chapter 9: Documenting Your Program 263 Adding Comments to Source Code 264 Identifying the two types of comments 265 Describing code and algorithms 268 Documentation 270 Debugging 271 Writing Software Documentation 272 Documentation types 272 Documentation tools 274 Help files 275 Chapter 10: Principles of User Interface Design 277 The Evolution of User Interfaces 278 Command-line interface 278 Menus 278 Graphical user interface 280 Elements of a User Interface 281 Displaying commands to a user interface 281 Giving data to the user interface 284 Showing information back to the user 288 Organizing a user interface 290 Designing a User Interface 291 Know the user 291 Hide/disable unusable options 292 Tolerate mistakes 293 Be consistent 294 Give the user freedom to customize the user interface 295 Make navigation easy 295 Chapter 11: Debugging and Testing 297 Common Types of Programming Errors 297 Debugging with Comments and Print Statements 300 Breakpoints, Stepping, and Watching 302 Stepping through code 304 Watching variables 305 Testing Code 306 Unit tests 307 Integration tests 308 User interface testing 309 Book 3: Data Structures 311 Chapter 1: Structures and Arrays 313 Using Structures 314 Storing data 315 Retrieving data 315 Using an Array 316 Defining the size 317 Storing data 320 Retrieving data 321 Working with Resizable Arrays 321 BASIC 322 C# 323 Swift 323 Working with Multidimensional Arrays 323 Creating a multidimensional array 324 Storing and retrieving data 325 Using Structures with Arrays 325 Drawbacks of Arrays 327 Data types 328 Searchin.
Beginning Programming All-In-One for Dummies