CHAPTER 7: Code Optimization with Mike Lee, the World s Toughest Programmer
QR Creation In Objective-CUsing Barcode encoder for iPhone Control to generate, create QR image in iPhone applications.
www.OnBarcode.com QR-Code Creation In Objective-CUsing Barcode encoder for iPhone Control to generate, create QR Code image in iPhone applications.
www.OnBarcode.com Worse, it s likely such optimizations make no difference to your application s performance. An application is only as fast as its slowest part, and even trivial applications contain a mindboggling web of parts. Shaving off picoseconds at random is like spitting in the ocean. You re much more likely to get in trouble than you are to hit a fish. Rather than worry about the efficiency of every line of code, worry about your own efficiency. Adding code complexity to an application without making it faster is a waste of time. It s much more efficient to write 100 percent of your code to be readable, logical, and terse, then go back and speed up the 3 percent that s actually slow. The code you do not write is a gift that keeps on giving. It doesn t cause bugs or get in the way of adding features. It doesn t take time to figure out later, and it requires no maintenance. Unwritten code is never broken by an operating system update, nor does it ever become obsolete. The best way to keep your code base fast, small, and future-proof is to use the vendorprovided frameworks. This code is written by platform experts who are better engineers than you or I. Let them deal with hardware-specific optimizations. Not only do you not need to worry about your code breaking, but you ll also get future performance upgrades for free. When Core Animation debuted at Apple s Worldwide Developers Conference in 2006, it obsoleted thousands of lines of painstaking animation code in the nascent Delicious Library 2. Although our code was arguably better than what Apple had demonstrated, our boss, Wil Shipley, knew better than to let hubris lead us down the road of rolling our own. We ripped out our code and spent the next year helping Apple nail down bugs in the new framework by filing reports with Apple s Bug Reporter (also known as RadarWeb). Our work paid off the next year, as shown in Figure 7-6. Delicious Library 2 won the Apple Design Award for Best Leopard Application. Apple demoed our app on the same stage where Steve Jobs had delivered the keynote speech days before. The application loaded, looking much like the shipping version, with its iconic woodgrain shelves. Then the sample library materialized in a gorgeous fade-in animation, and the entire room literally gasped. The funny thing is that we gasped, too. We had never seen anything like it before either, because we didn t do that. All we did was use the Core Animation framework. The sexy fadein that so impressed our peers was a gift from Apple.
Generating Code 128A In Objective-CUsing Barcode printer for iPhone Control to generate, create Code 128 Code Set A image in iPhone applications.
www.OnBarcode.com Code 3/9 Creation In Objective-CUsing Barcode printer for iPhone Control to generate, create Code39 image in iPhone applications.
www.OnBarcode.com CHAPTER 7: Code Optimization with Mike Lee, the World s Toughest Programmer
Encoding UPC-A Supplement 2 In Objective-CUsing Barcode generator for iPhone Control to generate, create Universal Product Code version A image in iPhone applications.
www.OnBarcode.com Print European Article Number 13 In Objective-CUsing Barcode encoder for iPhone Control to generate, create EAN13 image in iPhone applications.
www.OnBarcode.com Figure 7-6. The Delicious Monster team, from left: Lucas Newman, Wil Shipley, and Mike Lee
Barcode Maker In Objective-CUsing Barcode generator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com EAN-8 Supplement 2 Add-On Printer In Objective-CUsing Barcode printer for iPhone Control to generate, create EAN 8 image in iPhone applications.
www.OnBarcode.com Algorithmic Efficiency
Creating QR Code JIS X 0510 In C#Using Barcode maker for .NET framework Control to generate, create QR Code 2d barcode image in VS .NET applications.
www.OnBarcode.com QR Code Recognizer In Visual C#Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com While individual lines of codes almost always don t matter, the order those lines appear in almost always does. The efficiency of the algorithm the code implements has a significant effect on its performance. Before I broke the bad habit of code-level optimization, I wrote a na ve array comparison based on the assumption that sorting the arrays before comparing them would take longer. I could have tested that assumption by writing it both ways and timing them, but it s much more efficient to familiarize yourself with the efficiency of basic algorithms. Sorted arrays can be compared in O(n log n), while my unsorted solution was O(n2). This means that if the arrays each contained 10,000 items, the na ve algorithm would require 100,000,000 operations, while the sorted algorithm would require 133,000 operations. With one million items, the better algorithm will perform eighty million operations, while the na ve algorithm will cause your computer to burst into flames on its way to one quadrillion operations.
Creating Barcode In NoneUsing Barcode creation for Excel Control to generate, create Barcode image in Office Excel applications.
www.OnBarcode.com Code 3 Of 9 Recognizer In Visual Basic .NETUsing Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com Code 39 Full ASCII Generation In Visual Studio .NETUsing Barcode encoder for Visual Studio .NET Control to generate, create Code 3/9 image in .NET framework applications.
www.OnBarcode.com GS1 DataBar Stacked Encoder In JavaUsing Barcode maker for Java Control to generate, create GS1 DataBar Truncated image in Java applications.
www.OnBarcode.com Draw QR Code JIS X 0510 In Visual Basic .NETUsing Barcode drawer for VS .NET Control to generate, create QR-Code image in Visual Studio .NET applications.
www.OnBarcode.com Generate DataMatrix In Visual C#.NETUsing Barcode generation for .NET Control to generate, create Data Matrix ECC200 image in .NET applications.
www.OnBarcode.com Creating USS Code 128 In NoneUsing Barcode encoder for Word Control to generate, create Code 128 Code Set B image in Microsoft Word applications.
www.OnBarcode.com Draw PDF417 In Visual Studio .NETUsing Barcode maker for VS .NET Control to generate, create PDF417 image in VS .NET applications.
www.OnBarcode.com Draw Code 128 In VB.NETUsing Barcode drawer for .NET Control to generate, create Code 128 Code Set B image in Visual Studio .NET applications.
www.OnBarcode.com Data Matrix 2d Barcode Maker In JavaUsing Barcode creation for Eclipse BIRT Control to generate, create DataMatrix image in BIRT reports applications.
www.OnBarcode.com