Wallace Wang - Beginning Programming All-in-One For Dummies

Здесь есть возможность читать онлайн «Wallace Wang - Beginning Programming All-in-One For Dummies» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Beginning Programming All-in-One For Dummies: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Beginning Programming All-in-One For Dummies»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Let there be code!
Beginning Programming All-in-One For Dummies

Beginning Programming All-in-One For Dummies — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Beginning Programming All-in-One For Dummies», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

The step overcommand lets you completely skip over any lines of code stored inside of a subprogram.

STEP OUT

Suppose you start examining a subprogram line-by-line and suddenly want to stop. As an alternative to stepping through the rest of the subprogram, you can use the step outcommand, which tells the computer, “Stop stepping through the subprogram line-by-line right now!”

Watching variables

When you step or trace through a program, line-by-line, you can see how the program works. For more insight into your program's behavior, you can watch your variables.

Beginning Programming AllinOne For Dummies - изображение 50You can read more about variables in Book 2, Chapter 2. For now, just think of a variable as a temporary place to store data, such as a number or a word.

Watching a variable lets you see what data your program is storing and using at any given time. That way, if your program is supposed to print a name but actually prints that person’s phone number, you can step through your program line-by-line and watch to see which line stores the wrong data for the program to print.

Not only can you “watch” how your program stores data, but a debugger lets you change data while your program is running. By changing data, you can see how your program responds.

For example, suppose a program converts temperatures between Celsius and Fahrenheit. If you store a valid temperature, such as 15, you can see how your program handles the number 15. But what happens if the user types in an invalid number, such as 500000 or –1700000?

To find out how and why your program seems to randomly change the temperature, you can step through your program and watch the number stored as the age. By changing your variable while the program is running, you can type in different temperaturevalues to see how your program responds.

Beginning Programming AllinOne For Dummies - изображение 51When testing different values, always start off with values for which you already know how your program should respond. For example, a temperature of 0 in Celsius should be 32 in Fahrenheit. Likewise, a temperature of 100 in Celsius should be 212 in Fahrenheit.

Without the ability to change the value of variables while the program is running, debugging a program is much slower and more tedious. By changing the value of variables while the program is running, you can test different values without having to trace through the program multiple times using different values. Just run the program once, and change the value of the variable as many times as you want, as shown in Figure 4-9.

FIGURE 49Watching and changing variables can show you how a program reacts to - фото 52

FIGURE 4-9:Watching and changing variables can show you how a program reacts to different data.

Saving Time with Third-Party Components

Programmers are naturally lazy and often look for the simplest way to solve any problem. When faced with creating a program, programmers prefer to cheat by using third-party components, which are programs that somebody else has created already (and, hopefully, tested).

Third-party components usually offer commonly needed features, such as a word processor, a spreadsheet, or a database, that you can plug into your own program. So, instead of having to write your own word processor, you can buy a word processor component and plug it into your own program — now your program has word-processing capabilities with little additional programming on your part.

Beginning Programming AllinOne For Dummies - изображение 53Third-party components can give your program instant features, but they can also give you instant problems, too. If the third-party component doesn’t work right, your program won’t work right either, and you can’t fix the problem until the company that sells the third-party component fixes the problem. Basically, third-party components put you at the mercy of another company. If that other company stops updating and improving their component, you’re stuck with an outdated and possibly buggy component.

Depending on the features, third-party components can range in cost from a few hundred dollars to a few thousand dollars or more. Most third-party components aren’t cheap, but because they can save you a lot of time, they may be worth the price.

Optimizing a Program with a Profiler

Not all parts of a program are equal. Some parts of a program may run only once or twice, whereas other parts of a program may run hundreds or even thousands of times. For example, suppose you have a program that stores names and addresses. To use this program, you must first type in your name and password before you can sort and search through the program’s list of names and addresses.

In this example, the part of the program that asks for a username and password runs only once, but the part of the program that searches and sorts through your list of names and addresses may run multiple times. So, which part of your program determines its speed? The part that runs once (asking for a username and password) or the part that runs multiple times (searching and sorting names and addresses)?

Obviously, if you wanted to speed up your program, you’d focus on the part that runs most often, and that’s what a profiler does. A profiler examines your program and identifies the most frequently used parts of that program. After you know which parts of your program run most often, you can work on making that part of the program run faster, a process known as optimizing.

Profilers typically use two methods for examining a program:

Sampling: Sampling examines your entire program at fixed time intervals. Through sampling, a profiler can get a rough estimate on which parts of your program (often referred to as hot spots ) are being run most often.

Instrumentation mode: After you use sampling to identify hot spots, you can use this mode to examine the program in more detail to determine exactly what each program line does and how much time it takes.By identifying the hot spots, you can speed up your entire program by rewriting or optimizing those frequently run parts of the program. By optimizing a small part of your program, such as 10 percent of it, you can often improve the entire program’s performance dramatically.

Managing Source Code

In the old days, programs were often created by an individual or small teams of people who worked in the same room. If they needed to talk to each other or share code, they could simply copy files from one computer to another.

However, as programs have gotten much larger and more complicated, it has become common for multiple teams to work on a single program. Even worse, these separate teams may be located in completely different parts of the world and in different time zones. How can multiple teams work on the same program simultaneously? The answer is through version control or source management.

The problem is that at any given time, only one person can work on a program. Because most large programs are divided into multiple files, all files get stored in a central repository so there’s only one copy of a program.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Beginning Programming All-in-One For Dummies»

Представляем Вашему вниманию похожие книги на «Beginning Programming All-in-One For Dummies» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Beginning Programming All-in-One For Dummies»

Обсуждение, отзывы о книге «Beginning Programming All-in-One For Dummies» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x