ATL Internals: Working with ATL 8 (2nd Edition)
|
| List Price: | $64.99 |
| Price: | $44.02 & eligible for FREE Super Saver Shipping on orders over $25. Details |
Availability: Usually ships in 24 hours
Ships from and sold by Amazon.com
33 new or used available from $37.63
Average customer review:Product Description
The Active Template Library (ATL) is a set of small, efficient, and flexible classes created by Microsoft that facilitate the creation of interoperable components for developing Windows applications. The latest version of ATL is version 8, released with Visual Studio 2005. While .NET has been getting all the attention recently, there is still a huge base of installed COM/ATL code. Many programmers are dealing with difficult issues adding new .NET code to that installed base. At the same time there are many instances where ATL is still the superior choice for new applications - applications that have to run fast and efficiently on Windows, where the CPU doesn't have the memory or bandwidth to run .NET. This book will be a godsend to developers in both of those situations. As one tech reviewer put it, "Any programmer needing to transition ATL code to .NET will need this book." The first edition was widely praised, and sold close to 20,000 units. While ATL is no longer the cutting edge of Microsoft developer tools, there should still be a strong market for authoritative, complete, deep coverage of the newest version of this standard tool.
Product Details
- Amazon Sales Rank: #487740 in Books
- Published on: 2006-07-15
- Original language: English
- Number of items: 1
- Binding: Paperback
- 888 pages
Editorial Reviews
From the Back Cover
The Classic Guide to ATL–Now Updated for ATL 8 and Visual Studio 2005
Four leading Windows programming experts systematically reveal ATL’s inner workings, explaining not just how ATL works, but why it works the way it does. Client-side developers will master ATL’s resources for windowing, COM control, MFC integration, web service proxy generation, and more. Server-side programmers will discover ATL’s full COM server and object services, and its extensive support for high-throughput, high-concurrency web applications, and services. Every Windows developer will learn powerful ways to increase flexibility, reduce overhead, and maximize transparency and control.
• Discover ATL’s internals through diagrams, example code, and internal ATL implementation code
• Walk through wizards that simplify ATL usage in common applications
• Master string handling in C++, COM, and ATL
• Leverage ATL smart types, including CComPtr, CComQIPtr, CComBSTR, and CComVariant
• Understand and choose the right options for implementing IUnknown
• Create glue code that exposes COM objects from COM servers
• Use canned interface implementations to support object persistence, COM
collections, enumerators, and connection points
• Build standalone applications and UI components with ATL window classes
and controls
• Use ATL Server to develop web applications that run on Microsoft IIS
About the Author
Chris Tavares is currently a software development engineer in the Microsoft patterns and practices group, where he strives to help developers learn the best way to develop on the Microsoft platform. He first touched a computer in third grade, doing hand-assembly of machine code on an Intel 8080 machine with 512 bytes (yes, bytes) of memory, a hex keypad, and 7 segment LCD display. He’s been digging into computers and software ever since.
Kirk Fertitta is CTO of Pacific MindWorks, a leading provider of tools and services for electronic test and measurement. With his team at Pacific MindWorks, Kirk works extensively on code generation technology and Visual Studio extensibility. He is also a .NET/C# instructor for Pluralsight.
Brent Rector, president and founder of Wise Owl Consulting, is a noted speaker, consultant, and author, specializing in .NET, ASP.NET, XML, COM+, and ATL.
Chris Sells is a program manager for the Connected Systems Division. He’s written several books, including Programming Windows Presentation Foundation, Windows Forms Programming in C#, and ATL Internals. In his free time, Chris hosts various conferences and makes a pest of himself on Microsoft internal product team discussion lists. More information about Chris, and his various projects, is available at http://www.sellsbrothers.com.
Excerpt. © Reprinted by permission. All rights reserved.
Preface
.NET has hit the Windows programmer community like a tornado, tipping over the trailer homes of the ways that we used to do things. It's pretty much swept up the needs of most web applications and service applications, as well of most of the line-of-business applications for which we previously used Visual Basic and MFC.
However, a few stubborn hold-outs in their root cellars will give up their native code only at the end of a gun. These are the folks with years of investment in C++ code who don't trust some new-fangled compiler switches to make their native code "managed." Those folks won't ever move their code, whether there are benefits to be gained or not. This book is partially for them, if they can be talked into moving their ATL 3/Visual C++ 6 projects forward to ATL 8 and Visual Studio 2005.
Another class of developers that inhabit downtown Windows city aren't touched by tornados and barely notice them when they happen. These are the ones shipping applications that have to run fast and well on Windows 95 on up, that don't have the CPU or the memory to run a .NET application or the bandwidth to download the .NET Framework even if they wanted to. These are the ones who also have to squeeze the maximum out of server machines, to take advantage of every resource that's available. These are the ones who don't have the luxury of the CPU, memory or storage resources provided by the clear weather of modern machines needed for garbage collection, just-in-time compilation, or a giant class library filled with things they don't need. These developers value load time, execution speed, and direct access to the platform in rain, sleet, or dark of night. For them, any framework they use must have a strict policy when it comes to zero-overhead for features they don't use, maximum flexibility for customization, and hard-core performance. For these developers, there's ATL 8, the last, best native framework for the Windows platform.
For clients, ATL provides windowing, COM client smart types, extensive COM control and control hosting, MFC integration (including several MFC classes that no longer require the rest of MFC), and web service proxy generation. For servers, ATL provides full COM server and object services, and extensive support for high-throughput, high-concurrency web applications and services. For both clients and services, ATL makes aggressive use of macros and templates to give you maximum flexibility and low overhead, making sure you pay for only the features you use and giving you full transparency via the source code into how those classes map their functions to the platform. For productivity, ATL provides a full set of wizards for starting and building client and server projects.
Attributes
Pushing the productivity idea, in ATL 7 and Visual Studio 2003, the ATL team introduced attributed ATL, allowing ATL programmers to annotate their code using the same techniques that you would use to add metadata to IDL interfaces and coclasses (such as the uuid attribute). In fact, the wizards were so happy to show you this style of code that, in VS03, the Attributed option was on by default. However, all is not sunshine and bluebirds with attributes. In .NET and IDL, attributes are a real part of the programming model; support for them exists all the way down. In ATL, attributes are more of a compiler trick, like super-macros, generating base classes, macro maps, Registry scripts, and IDL files.
Unlike macros, however, ATL attributes are not transparent—you can't see what is going on very well. A compiler switch is included to show a representation of generated code, such as what base classes were added, but it has regressed in VS05. This has led to problems in understanding and debugging issues, which was not helped by bugs in the attribute-generated code. That's not to say that the rest of ATL is bug free (or that any software is bug free), but when it comes to problems in base classes or macros, ATL has always enabled you to replace problem functionality in several ways. In fact, code to work around problems was a big part of the first edition of this book because you could so easily sidestep problems.
Cues in VS05 indicate that attributes are no longer a major part of the ATL team's focus. For example, the compiler switch shows less information, not more, about what attributes generate. Most telling, however, is that the Attributed option in the VS05 wizards is no longer checked by default.1 For that reason, although we cover the principles of ATL attributes in Appendix D, "Attributed ATL," you won't find them sprinkled throughout the book. We believe that half-hearted attributes won't make ATL 8 programmers the happiest with their native framework of choice.
Audience
This book is for the C++/COM programmer moving to ATL 8, as provided with Visual Studio 2005. ATL was built with a set of assumptions, so to be an effective ATL programmer, you need to understand not only how ATL is built, but also why. Of course, to understand the why of ATL, you must understand the environment in which ATL was developed: COM. Instead of attempting to compress all required COM knowledge into one or two chapters, this book assumes that you already know COM and spends all its time showing you the design, use, and internals of ATL. Don Box's Essential COM (Addison-Wesley Professional, 1997) is a good source of COM knowledge, if you'd like to brush up before diving into ATL.
Outline
With the exception of the first chapter, this book is arranged from the lowest levels of ATL to the highest; each chapter builds on knowledge in previous chapters. The first chapter is a brief overview of some of the more common uses for ATL and the wizards that aid in those uses. Whenever things get too detailed in the first chapter, however, we refer you to a subsequent chapter that provides more in depth coverage.
Chapters 2 through 5 present the core of ATL. Chapter 2, "Strings and Text," covers the messy world of string handling in C++, COM, and ATL. Chapter 3, "ATL Smart Types," discusses ATL smart types, such as CComPtr, CComQIPtr, CComBSTR, and CComVariant. Chapter 4, "Objects in ATL," discusses how objects are implemented in ATL and concentrates on the great range of choices you have when implementing IUnknown. Chapter 5, "COM Servers," discusses the glue code required to expose COM objects from COM servers. Chapter 6, "Interface Maps," delves into the implementation of IUnknown again, this time concentrating on how to implement QueryInterface; this chapter shows techniques such as tear-off interfaces and aggregation. Chapters 7, "Persistence in ATL"; 8, "Collections and Enumerators"; and 9, "Connection Points," discuss canned interface implementations that ATL provides to support object persistence, COM collections and enumerators, and connection points, respectively. These services can be used by components that might or might not provide a user interface. Chapters 10, "Windowing"; 11, "ActiveX Controls"; and 12, "Control Containment," concentrate on building both standalone applications and user interface components. These chapters cover the ATL window classes, controls, and control containment, respectively. Finally, Chapters 13, "Hello, ATL Server," and 14, "ATL Server Internals," cover ATL Server, which lets you build web applications on IIS. Chapter 13 introduces ISAPI and ATL Server, and Chapter 14 looks under the hood of ATL Server.
Much of what makes the ATL source difficult to read is its advanced use of templates. Appendix A, "C++ Templates by Example," provides a set of examples that illustrate how templates are used and built. If you've seen ATL source code and wondered why you pass the name of a deriving class to a base class template, you will find this appendix useful. Appendix B, "ATL Header Files," provides a list of the ATL header files, along with descriptions to help you track down your favorite parts of the ATL implementation. If you're already an ATL 3 programmer and you want to hit the ground running on what's new in ATL 8, Appendix C, "Moving to ATL 8," is for you. Finally, if you'd like an introduction to attributes (and a bit more information about why we've relegated attribute coverage to a lowly appendix), you'll want to read Appendix D, "Attributed ATL."
Conventions
When writing these chapters, it became necessary to show you not only diagrams and sample code, but also internal ATL implementation code. This book often becomes your personal tour guide through the ATL source code. To help you distinguish author-generated code from Microsoft-employee-generated code, we've adopted the following convention:
// This code is author-generated and is an example of what you'd type.// Bold-faced code requires your particular attention.CComBSTR bstr = OLESTR("Hello, World.");// Code with a gray background is part of ATL or Windows.CComBSTR(LPCOLESTR pSrc) { m_str = ::SysAllocString(pSrc); } Because the ATL team didn't write its code to be published in book form, we often had to reformat it or even abbreviate it. Every effort has been made to retain the essence of the original code, but, as always, the ATL source code is the final arbiter.
Sample Code and Further Information
More information about this book, including the sample source code, is available at http://www.sellsbrothers.com/writing/atlbook. On that site, you'll also find contact information so that you can report errors or give feedback.<...
Customer Reviews
deals with many legacy issues
Tavares and his co-authors present a specialised guide to the latest version of Active Template Library. It's for the C++ programmer on a Microsoft machine, who is also familiar with the Component Object Model. The authors specifically state that you really do need expertise in the latter.
The book deals with various legacy issues, mostly dating back to MFC, which is now largely deprecated. But there are also other aspects that are grubby and mostly unavoidable. For example, when dealing with character types, there is an abstraction called OLECHAR. Under Win32, it maps to wchar_t, while under Win16 [and the Mac] it maps to char. The need for this was due to the hardware improvements that took us from 16 bit CPUs to 32 bits. A transition that occurred mostly in the 80s. But for Microsoft, the legacy code remains in use. So there has to be low level logic that maps the character type to an actual appropriately sized memory allocation.
By the way, don't think this issue is confined to Microsoft. C code from that era that was developed for Unix machines, and which might still be in use, often has a similar problem. C macros dealing with this are a notorious source of porting errors.
The text deals with many other aspects of ATL. Some, like collections and enumerations, are very cleanly done. These classes are inherently meant to be high level abstractions. And the C++ code examples that use these are very easy to follow. The discussion of this also includes some sample Visual Basic code. (Most of the book has C++ code.)
ATL Internals: Working with ATL 8 (2nd Edition)
Most reviews on this book were very good. It was the reason I bought this book. This book covers topic on the ATL 8 as its title says.
However, I don't like this book although I will read this book to the end.
The reason is this. Each chapter discuss about its own topics like strings, and so on. However, it just describes each methods of a given class. It is like that of the MSDN. Why doesn't it show some sample code lines which shows how to use some of them and what the result is? By doing so, it is much easier to understand and read. After reading a few chapters, I started skipping explanations because of the pattern.
Also, just like other books nowadays, it is too descriptive. It will be good if it is a book about explaining concept of the COM, or if it should give some idea on the topic. However, readers of this book already knows about the COM and if they consider "COM", they are already fairly experienced programmers. Then explaining things like the MSDN documents do is not helpful. Probably it would be better if it can explain thing more clearly than the MSDN do, but I guess it is not the case for this book.
Also, what lacks seriously among most COM books is that they fails to describe the automatically inserted macros and their relationship.
Also, for the Visual C++ 2005 IDE, there are some peculiar things. For example, the IDE displays the same interface under class and under interface on its solution pane. You may wonder where to put codes for a certain interface. It could be better if this book explains about them too.
Because COM is designed very confusing way, the Objective-C remote messaging, it needs good explanation. However, this ( and most ) book fails in doing so.
Additionally, it would be better if it has some tutorial chapters.
By following step by step, you can figure out things more clearly, but this book fails in that too. At least the first chapter seems to be written for that purpose. However, it omits some declarations and it is not implied where to put those. So, I gave up writing codes for the chapter.
However, as for the coverage of the topic, it seems to be chosen well.
I know.. people are moving to the C#/C++ .NET remoting.
Nowadays many books on COM/.NET interop are published. So, probably the important of COM is diminishing.
However, COM is still the core of the technology, and I'm not sure if the .NET stands for long-time. Even MS changed things about .NET abruptly so much, and people using .NET seem to use C# instead of C++ generally, I think it is not good idea to rely on proprietary technology. Yeah.. COM is proprietary. But your code using COM doesn't totally rely on proprietary code... at least C++ part...
I hope this book would be improved.





