Programlama Süreci
STAIR problem çözme süreci State the problem (Problemi tanımlayın) Identify the tools available for solving the problem (Problemi çözmek için mevcut araçları belirleyin) Write an algorithm (Bir algoritma yazın) Implement the solution (Çözümü gerçekleştirin) Refine the solution (Çözümü sadeleştirin) Testing the solution, fixing bugs, and making enhancements
Debug terimi nerden geliyor? National Museum of American History
Hataları Gidermek Neden Önemli? Tarihteki Büyük Yazılım Hataları July 28, 1962 -- Mariner I space probe 1982 -- Soviet gas pipeline 1985-1987 -- Therac-25 medical accelerator 1988 -- Buffer overflow in Berkeley Unix finger daemon 1988-1996 -- Kerberos Random Number Generator January 15, 1990 -- AT&T Network Outage 1993 -- Intel Pentium floating point divide 1995/1996 -- The Ping of Death June 4, 1996 -- Ariane 5 Flight 501 November 2000 -- National Cancer Institute, Panama City
Debugging (Hata Ayıklama, Hata Giderme) Errors are a fact of life when it comes to programming. The trick is knowing how to trace them and then fixing them before other people get their hands on your program! Bu derste bahsedeceklerimiz: Programlama hataları çeşitleri, Programlama hataları neden olur, Programlama hataları nasıl düzeltilir, Programlama hatalarının ardındaki psikoloji ve bazı hatalarla neden diğerlerinden fazla karşılaştığımız.
Yamalar, düzeltmeler, güncellemeler, v.s. Microsoft Windows XP SP1, SP2, SP3 Microsoft Windows 2000 SP1, SP2, SP3, SP4 Office 2003 Örnek Güncellemeler, yamalar, düzeltmeler
Psikolojik Gaz New programmers quickly get the impression that making mistakes and getting error messages is something to be ashamed of, and that they are a sign of failure and something to be embarrassed about. Errors are a fact of life, and any programmers who tell you that they can write prefect code all the time are either lying through their teeth or don’t actually do much programming — at least, much serious programming. Eliminate any testing and beta test stages of software releases, and save millions of dollars, releasing perfect software that didn’t need service packs, maintenance releases, or patches and so save even more money. Windows Vista: Ekimde çıkan hazırlık sürümlerinden RC2’yi 50,000 - 100,000 arası kullanıcı sınadı. Windows Vista Geliştirme Tarihçesi Dell Windows Vista Hazırlıkları: >100,000 hours of testing (52 years)
Herkes hata yapabilir. Bu hayatın gerçeği.
Initially, you are bound to make more errors in your coding simply because you are learning. The syntax of statements takes time to grasp, operators are unfamiliar, and basic coding practices are foreign to you: until you are comfortable with these, errors will happen. Look at mistakes as learning pointers, showing you areas that you need to pay attention to, while error-free statements are examples of things that you are doing right! Stick with programming, and you’ll notice that you make fewer and fewer errors in your code — that’s good progress and something you should feel proud of. But don’t worry with trying to be 100 percent error-free, leave that to the “perfect” programmers who feel they have to show off!
Hata Çeşitleri Are errors all created the same? Are there different types of errors? Different Kinds of Error Compiler errors Runtime errors Logic errors
Compiler errors (Derleyici Hataları) A compiler error is an error thrown up by the compiler as you are in the process or turning your source code into a standalone application. It’s important to note that you will only get a compiler error if you use a compiler
Compiler Errors: Örnek 1
Compiler Errors: Örnek 2
Compiler Errors: Örnek 3
Compiler Errors: Örnek 4
Compiler Errors: Örnek 5
Compilers also can generate warnings.
Error vs. Warning When the compiler encounters an error it aborts the compile and generates the warning. With a warning, the compiler doesn’t abort compiling and still builds an executable as normal.
Runtime Errors (Çalışma Zamanı Hataları) Runtime errors are errors that appear in your program when you run it. With an application that you’ve compiled, such as a C++ application, runtime errors generally mean that you have to go back to the source code to discover what the problem is. With languages that are interpreted, an error like this means that you have to go back to the code and examine it. When you are using a language that is an interpreted language as opposed to a compiled language, the errors that would normally be picked up and highlighted by the compiler will not show up until the code is run and these become runtime errors.
Runtime Errors: Örnek Tracing runtime errors in compiled code is tricky in that the application gives you a memory address and not much more. Debugging can be time-consuming and tricky.
Logic Errors (Mantık Hataları) Logic errors are among the hardest errors to spot simply because they aren’t errors that affect whether the code runs or compiles, but they are errors that affect how the code works. Usually, you wanted your code to do one thing, but wrote something else by mistake.
Logic Errors: Örnek Olması gereken Dükkan zararda Müşteri zararda
Logic Errors: Infinite Loops
Logic Errors: Using the wrong operator = (Atama) == (Karşılaştırma)
Mantık hataları nasıl önlenir? The only effective ways to prevent code containing logic errors from making it out into the wide world is by thorough analysis of the code and careful, comprehensive testing of the code, using a variety of inputs and checking them against independently worked-out outputs.
Spotting Errors (Hataların Bulunması) Proper Testing Is Vital Perform desk checking Perform a beta test Compare results of the beta test against the old system's parallel test results Read Each Line After You Press Enter Does it look right? Can you spot any typos or other odd errors? Does it accomplish what you set out for it to do? Have you used the appropriate line terminator? Check the Preceding Statements
Spotting Errors (Hataların Bulunması) Keep the Layout Clear void functionname() { // Code goes here. } Comments, Comments, Comments! If you comment out a line of code to replace it with another or just to get rid of it, remember to add a comment detailing why you removed it and when
Spotting Errors (Hataların Bulunması) Remove Ambiguity (Belirsizlik) in Code Semicolons Semicolons go after complete statements. for( x = 0; x < 100; x++); { cout << “Hello, World!” << endl; }
Spotting Errors (Hataların Bulunması) Test the Code Keep Track of Variables