Beginning Programming All-in-One For Dummies. Wallace Wang. Читать онлайн. Newlib. NEWLIB.NET

Автор: Wallace Wang
Издательство: John Wiley & Sons Limited
Серия:
Жанр произведения: Программы
Год издания: 0
isbn: 9781119884422
Скачать книгу
tasks, such as always displaying program commands in uppercase letters. If the editor doesn’t offer a feature you want or need, its macro language lets you add that feature. Without a macro language, an editor won’t give you the flexibility to work the way you want.

       Project management helps you keep your source code files organized. Most programs no longer consist of a single file but of multiple files. Trying to keep track of which files belong to which project can be confusing, so an editor can help you store and organize your files so you won’t lose track of them.

      Integrated development environments

Snapshot shows an IDE provides access to multiple programming tools within a single UI.

      FIGURE 4-5: An IDE provides access to multiple programming tools within a single UI.

      

If you mostly write programs in a single programming language, using an IDE can be more convenient than a stand-alone editor.

      Features

      In addition to a compiler and all the usual features of stand-alone editors (see the “Common editor features” sidebar), many IDEs include other features in a convenient UI:

       A debugger helps identify problems in your program.

       File management helps organize the source code for your various projects.

       A profiler helps identify which parts of your program may be slowing down the performance of your entire program.

       A graphical user interface (GUI) designer helps you design the appearance of your program’s windows, drop-down lists, and buttons.

      Free software

      Many compilers come with their own IDE, but you can always use another IDE or a stand-alone editor instead. These IDEs are popular (and free):

       Apache NetBeans (https://netbeans.apache.org): Designed for writing Java programs, it can be used for writing C and C++ programs as well. NetBeans is available for multiple operating systems.

       Atom (https://atom.io): Atom is an open-source editor for Linux, macOS, and Windows.

       Eclipse (www.eclipse.org): Designed for writing Java programs, it can also be used for writing C, C++, PHP, and even COBOL programs. Eclipse is available for multiple operating systems.

      Eventually, everyone makes a mistake writing a program. That mistake could be as simple as incorrectly typing a command or forgetting a closing parenthesis, or it could be as complicated as an algorithm that works perfectly except when receiving certain data. Because writing error-free programs is nearly impossible, most programmers use a special tool called a debugger.

      

Program errors are called bugs, so a debugger helps you find and eliminate bugs in your program.

      Two common debugger features include

       Stepping or tracing

       Variable watching

      

Not all bugs are created equal:

       Some bugs are just annoying, such as the wrong color on a drop-down list.

       Some bugs are critical, such as a bug that adds two numbers wrong in an accounting program.

       Any bug that keeps a program from running correctly is a showstopper.

      Stepping line-by-line

Snapshot shows stepping through a program, line-by-line, can help you find errors or bugs in your program.

      FIGURE 4-6: Stepping through a program, line-by-line, can help you find errors or bugs in your program.

      

Sometimes when programmers find one error and fix it, their fix accidentally creates another error in the program.

      

Here are the two types of debuggers:

       Source level: Lets you examine your source code line-by-line. So if you write a program in C++, a source-level debugger shows you each line of your entire C++ program.

       Machine language: Lets you examine the machine language code, line-by-line, that your compiler created from your source code. Programmers often use machine-language debuggers to examine programs when they don’t have access to the source code, such as a computer virus or a rival’s program.

      Breakpoints

      A breakpoint lets you skip over the parts of your program that you already know work. So, if you have a program that’s 10,000 lines long and you know the problem is somewhere in the last 1,000 lines of code, there’s no point in stepping through those first 9,000 lines of code.

Snapshot shows breakpoints let you skip over parts of your program that you don’t want to examine line-by-line.

      Over and out

      The stepping over and stepping out commands are used to debug a large program that consists of multiple