NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya
1.
Visit https://ebookultra.com todownload the full version and explore more ebooks NET Programming A Practical Guide Using C 1st Edition Pradeep Tapadiya _____ Click the link below to download _____ https://ebookultra.com/download/net-programming-a- practical-guide-using-c-1st-edition-pradeep-tapadiya/ Explore and download more ebooks at ebookultra.com
2.
Here are somesuggested products you might be interested in. Click the link to download Visual C Net programming 1st Edition Harold Davis https://ebookultra.com/download/visual-c-net-programming-1st-edition- harold-davis/ Build Your Own ASP NET Website Using C VB NET 1st Edition Zak Ruvalcaba https://ebookultra.com/download/build-your-own-asp-net-website-using- c-vb-net-1st-edition-zak-ruvalcaba/ Practical Database Programming with Visual Basic NET Second Edition Ying Bai(Auth.) https://ebookultra.com/download/practical-database-programming-with- visual-basic-net-second-edition-ying-baiauth/ Head First C 2ed A Learner s Guide to Real World Programming with Visual C and NET Head First Guides Second Edition Andrew Stellman https://ebookultra.com/download/head-first-c-2ed-a-learner-s-guide-to- real-world-programming-with-visual-c-and-net-head-first-guides-second- edition-andrew-stellman/
3.
Making and UsingAntibodies A Practical Handbook 1st Edition Gary C. Howard https://ebookultra.com/download/making-and-using-antibodies-a- practical-handbook-1st-edition-gary-c-howard/ Foundations of Object Oriented Programming Using NET 2 0 Patterns 1st Edition Christian Gross (Auth.) https://ebookultra.com/download/foundations-of-object-oriented- programming-using-net-2-0-patterns-1st-edition-christian-gross-auth/ A Programmer s Guide to ADO NET in C 1st Edition Mahesh Chand https://ebookultra.com/download/a-programmer-s-guide-to-ado-net- in-c-1st-edition-mahesh-chand/ Large Scale Software Architecture A Practical Guide using UML 1st Edition Garland https://ebookultra.com/download/large-scale-software-architecture-a- practical-guide-using-uml-1st-edition-garland/ C net Web Developer s Guide 1st Edition Saurabh Nandu https://ebookultra.com/download/c-net-web-developer-s-guide-1st- edition-saurabh-nandu/
5.
NET Programming APractical Guide Using C 1st Edition Pradeep Tapadiya Digital Instant Download Author(s): Pradeep Tapadiya ISBN(s): 9780130669452, 0130669458 Edition: 1st File Details: PDF, 2.04 MB Year: 2002 Language: english
7.
by Pradeep Tapadiya Publisher:Prentice Hall PTR Pub Date: July 11, 2002 ISBN: 0-13-066945-8 Book Info Takes a straightforward, hands-on approach to explain everything you need to know from development to deployment and maintenance for this platform-all from a developer's perspective. Softcover. CD-ROM included. From the Back Cover Enterprise-class .NET programming in C#— from a developer's perspective. * Internals of the .NET Framework— learn to get the most from its services * Build professional applications using C#— quickly and efficiently * Hands-on approach covering the Base Class Library, Remoting, ASP .NET Web Services, concurrency, security, enterprise services, dealing with legacy code, and much more .NET developers need more than buzzwords to get the job done. To tackle enterprise-class projects, they need both a real understanding of the .NET architecture and a working knowledge of how to put its services to work. In .NET Programming: A Practical Guide Using C#, .NET authority Pradeep Tapadiya takes a straightforward, hands-on approach to explain everything you need to know from development to deployment and maintenance for this platform— all from a developer's perspective. Using C# as the primary language, and with plenty of code examples throughout, this book is an excellent way to learn: * The .NET infrastructure— packaging and deployment, the common language runtime and its services, and the .NET Framework class libraries * Distributed computing— develop object-remoting applications for intranets and Web services for the Internet * How to develop thread-safe code using the .NET synchronization infrastructure and learn asynchronous programming * Interoperability with native DLLs and COM applications * How to develop secure applications using role-based security and enforce security for third-party applications using code access permissions * Enterprise services— develop scalable applications, support transactions, and more. Appropriate for experienced developers, .NET Programming will help you get the most from the .NET architecture— today. About the Author PRADEEP TAPADIYA is a lead software architect at the OpenView R&D Division of Hewlett-Packard in Roseville, CA, and has been working with Microsoft enterprise
8.
development technologies since1996. He holds a doctoral degree in computer science from Texas A&M University. Tapadiya is also the author of COM+ Programming: A Practical Guide Using Visual C++ and ATL (Prentice Hall PTR).
9.
1 Introduction Computing lifestyles anddevelopment needs change with time. Over the years, a number of paradigms and programming methodologies have been offered to support the needs of the developers and software vendors. In the mid 1990s we saw monolithic applications being broken into smaller applications that communicated with each other. To facilitate code reusability and application communication across compiler boundaries and programming language boundaries, Microsoft introduced a framework called Component Object Model (COM). To further facilitate the communication across machine boundaries, Microsoft extended the model to Distributed COM (DCOM). The late 1990s witnessed an incredible explosion of the Internet that caused a revolution in the way information was made available to the users. In developing enterprise systems, the traditional client/server model was replaced by a three-tier programming model, enhanced for Internet applications. Developing such enterprise systems was a time- and resource-consuming affair, as the systems had to meet extra enterprise-level requirements such as scalability, robustness, security, transaction support, and so on. To help developers meet these challenges, Microsoft introduced COM+, an advanced runtime environment that ran on Microsoft Windows 2000. Developers could now leverage the services provided by COM+ instead of building the services themselves. In the new millennium, the Internet is evolving from a collection of isolated Web sites and applications into a general "communication bus" for distributed applications that can run on various hardware and operation system (OS) platforms. Microsoft's .NET platform is based around this vision. As part of the .NET initiative, Microsoft has provided a framework and some tools that developers can use to build applications targeting .NET platform. Although .NET achieves many of the same goals that COM does, make no mistake— .NET is a radically new platform. The programming model has been an evolution over COM, but the framework implementation is completely different. However, the enterprise system needs (e.g., scalability, transaction support, etc.) haven't changed much. Therefore, many COM+ services have found their way into .NET. This book focuses on understanding .NET architecture from a developer's perspective and building .NET applications primarily using C#, a new programming language that offers the flexibility of C++ and the simplicity of Visual Basic. About This Book The purpose of writing this book is twofold: 1. To help you understand .NET architecture in detail. 2. To explore the services provided by the .NET Framework in building enterprise-level applications. To achieve the first goal, a hands-on approach is employed in this book. As we progress through unfolding .NET technology, I present a key concept, accompanied by code samples as necessary.
10.
2 The second goalis to use .NET productively in building enterprise-level applications. Enterprise-level requirements include security, transaction support, scalability, dealing with concurrency, distributed three-tier computing, dealing with legacy code, and so on. This book seeks to do the following: • Provide an in-depth analysis of all aspects of .NET technologies related to enterprise-level application development. • Provide ideas to develop robust .NET applications. • Provide programming code to achieve common .NET programming tasks. • Provide concise, complete sample programs to illustrate the concepts presented. I have tried to present the material such that it makes interesting reading for developers. Not only can developers gain an in-depth knowledge of .NET platform, but they can also get familiar with programming in other related technologies such as SOAP, XML, ADO.NET, and ASP.NET. The book starts with an overview of .NET platform from a nontechnical perspective. Then I progress through unfolding the .NET architecture and services. Wherever applicable, code samples are provided to illustrate and explain the concepts. This book provides enough sample code to enable readers to be more productive and to carry out further research. Throughout the book, I have identified important points and tips for effective .NET programming. The pad-and-pencil icon marks important notes: An Important Note The light bulb icon flags tips: A Tip Intended Audience The intended audience includes the following groups: • Software developers and engineers who are involved in developing software products for the Windows platform and typically use C++ or Visual Basic as their programming language.
11.
3 • Managers whoactively supervise a software product. • Computer science students. Today, more and more companies expect job candidates to understand COM and COM+ technologies. Senior students and graduate students are becoming more aware of COM technology as a software engineering discipline. The next logical step for them would be to start programming in .NET. Choice of Programming Language A vast majority of the .NET programming community will be using C# for developing .NET applications. As a matter of fact, a large part of the .NET Framework has been developed in C#. Hence, I chose C# to present samples in most cases. However, in some instances I have used Visual Basic.NET or another language that is appropriate for the given situation. Prerequisites The most important prerequisite for this book is a willingness to learn. The book is written for intermediate to advanced developers. It is assumed that readers have a working knowledge of the following: • C++ or Java programming languages. • Windows 2000 operating system. Note that knowledge of C# is helpful but not mandatory, as long as you are familiar with C++ or Java. As we go through developing sample code, I am confident readers will automatically pick up adequate information about the language. Sample Code All the examples provided in the book are concise and complete. For brevity, I sometimes show only the relevant code sample in the book. However, complete source code is available on the companion Web site. All the examples and tools have been compiled with Microsoft Visual C# 1.0 and the .NET Framework Software Development Kit (SDK), and have been tested on Windows 2000 SP2 and Windows XP. The samples are organized by chapters. Each sample is built as a separate project. A project can be compiled either from VisualStudio .NET or from the command-line makefile. The makefile can be found in the bin directory under each project, except for Chapter 2. In order to illustrate some key compiler concepts, Chapter 2 contains the makefile in the same directory as the project.
12.
4 Note that VisualStudio .NET requires that a project belongs to a solution. The project file has an extension .csproj and the solution file has an extension .sln. In order to build the projects from the command line, you need to set up proper paths in the environment. If you have installed Visual Studio .NET, then you can use the command-line link that is provides called the "Visual Studio .NET Command Prompt." This link initializes the environment for the command window such that the .NET Framework SDK tools can be accessed from the command line. References This book frequently refers to other books, Microsoft's Knowledge Base articles, articles from various journals, and Microsoft's Developers Network (MSDN) Library. All the references for a particular chapter are listed at the end of that chapter. Each reference entry is indexed by a keyword that uses a combination of author's last name and year the reference was published. For example, Don Box's book Essential COM, which was published in 1998, is indexed as [Box-98]. In the book, each time I cite a reference, I use the relevant keyword. Chapter Organization The book is divided into two parts. The first part, Chapters 1— 5, focuses on the fundamentals of .NET Programming Model and shows how to develop .NET-based applications. The second part, Chapters 6— 10, focuses on the services provided by .NET. Each chapter focuses on a specific aspect of .NET. These chapters are largely independent of each other. Chapter 1: What is .NET? .NET is Microsoft's new initiative for building applications regardless of the platforms or languages in use. The .NET label applies to three distinct but related items: a vision for how information technology (IT) will evolve, a software platform to build .NET applications, and an application-hosting business designed to support the vision and market the platform. In this chapter, we inspect each of these items from a fairly nontechnical perspective. By the end of the chapter, the readers will have a good idea of where Microsoft is going with the .NET initiative and will understand the terminology, features, and services offered by the .NET Framework, the software platform for .NET applications. Chapter 2: From C++ to C# This chapter focuses on various stages of building .NET applications— from development to debugging and deploying. You will write simple C# programs to explore common programming paradigms under the .NET Framework. In the process, you will learn the differences and similarities between C++ and C#. By the end of the chapter, readers will understand many key concepts of the .NET Framework and will be fairly comfortable developing simple .NET applications using C#.
13.
5 Chapter 3: Assemblies Under.NET, assemblies form the fundamental building block of program components. In defining the format for the assembly, .NET had many goals. These goals included interoperability among different programming languages, side-by-side execution of multiple versions of the same assembly, performance enhancements, and so on. In this chapter, we take an in-depth look at the assemblies and examine how these goals were achieved. By the end of the chapter, you will have a good knowledge of the assembly internals and the packaging and deployment model under .NET. Chapter 4: Essentials of the .NET Framework In this chapter, we examine the facilities that the .NET Framework provides to load and execute the code and provide services to the executing code. We start with an overview of various components that constitute the .NET Framework. Then we look at the overall process of managed code execution. We will see how .NET applications can be administratively controlled using external configuration files and how the configuration mechanism can be extended to store custom settings. We then look at the type system used by the common language runtime and examine the memory and performance considerations of using reference types versus value types. We examine how the CLS provides for cross-language interoperability. We look at how the execution engine validates the metadata, verifies the MSIL code for type-safety, and performs JIT compilation on the MSIL code. Finally, we look at the automatic memory management features of the runtime and how it simplifies or complicates programming under .NET. By the end of the chapter, you will have a good understanding of .NET architecture and how it helps in producing robust applications that can potentially be reused by any programming language under .NET. You will also learn the strategies of generating efficient code. Chapter 5: Programming with the Base Class Library The .NET BCL includes hundreds of classes that provide a number of useful services to help developers boost their productivity. In this chapter, we look at how to solve many common programming tasks using these classes. By the end of the chapter, you will become familiar with many important classes under the .NET Framework. Chapter 6: Distributed Computing In this chapter, we look at how to develop distributed applications under .NET that can communicate within intranets as well as over the Internet. We will see how .NET remoting offers seamless remote activation and remote method calls, among other things. We examine how to develop intranet applications using this support. Over the Internet, Web services have become the building blocks for distributed Web-based applications. We will look at the support offered by ASP.NET to create and deploy Web services. By the end of this chapter, readers will be comfortable developing applications using the common language runtime object-remoting and will be fairly conversant with ASP.NET Web services development. Chapter 7: Interoperability The .NET Framework provides support for managed code to interoperate with unmanaged code. The unmanaged code could either be COM-based or be in native DLLs. The .NET Framework has been designed to provide smooth
14.
6 interoperability. In thischapter, we examine the support for interoperability provided by the .NET Framework. By the end of the chapter, readers will be comfortable making calls from managed code into unmanaged code and vice versa. Chapter 8: Concurrency Under Windows, and most other modern OSs, a process can execute multiple threads concurrently, each of which carry out a specific task. The .NET Framework supports developing multithreaded applications in two ways— by supporting the creation and use of threads and by providing a mechanism to make asynchronous calls. In this chapter, we examine both these techniques in detail. We also look at various issues involved with multithread programming and the support provided by the .NET Framework in developing classes that are safe from concurrent access. Chapter 9: Security The .NET Framework offers two security mechanisms— code access security and role-based security. Both security mechanisms are built on top of the security provided by the underlying OS. Code access security keeps track of where the assemblies come from and what security permissions should be granted to them. Role-based security enables the code to make security decisions based on the role of the user executing the code. In this chapter, we look at the concepts underlying code access security and role-based security. We also examine the classes and services provided by the .NET Framework to facilitate the use of these security mechanisms. Security is also an important consideration for ASP.NET applications. ASP.NET applications need to authenticate clients and provide restricted access to any sensitive data, based on the client credentials. In addition, the ASP.NET applications may also have to act on behalf of the client in some cases to access OS secured resources such as NTFS files. In this chapter, we also examine various security features that ASP.NET provides to deal with authentication, authorization, and impersonation. Chapter 10: Enterprise Services Enterprise system development has historically been a very time- and resource-consuming process. The development complexity arises from the extra enterprise-level requirements such as scalability, robustness, security, automatic transaction processing, and so on. The .NET Framework provides many infrastructural services to meet the needs of enterprise systems. This allows businesses to focus on their core competencies instead of building the plumbing themselves. In this chapter, we examine in detail some important requirements for enterprise systems and the services provided by .NET to meet these requirements. Companion Web Site The companion Web site (www.phptr.com/tapadiya/dotnet/) contains the source code for all the examples in the book, arranged by chapters. For the most up-to-date information, see the read-me file at the Web site.
15.
7 Author Biography Pradeep Tapadiyais a lead software architect at the OpenView R&D Division of Hewlett-Packard in Roseville, CA, and has been working with Microsoft enterprise development technologies since 1996. He holds a doctoral degree in Computer Science from Texas A&M University. Tapadiya is also the author of COM+ Programming—A Practical Guide Using Visual C++ and ATL. Tapadiya can be reached at pradeep@tapadiya.net.
16.
8 Acknowledgments First of all,I'd like to thank Kent Sharkey, Microsoft Technical Evangelist for the .NET Framework, who provided me with valuable feedback by critically reviewing the technical contents of the book. There were many people who helped me review my manuscript over the course of writing the book. I'd especially like to thank Mihir Dalal and Sanjay Mehta (my colleagues at Hewlett-Packard), and Terrance Simkin (Professor, Computer Engineering Technology, New Hampshire Technical Institute) who offered me valuable suggestions on presenting my thoughts and ideas. A round of gratitude is also due for the following folks for helping me with technology-specific questions 桽 tacey Giard and Connie Sullivan (Managers, Microsoft .NET Authors Web Community), Paddy Srinivasan (Microsoft), Ranjeeth Ramakrishnan (Microsoft), Ron Jacobs (Microsoft), Shajan Dasan (Microsoft), Kit George (Microsoft), Steven Pratschner (Microsoft), Brad Adams (Microsoft), Jim Hogg (Microsoft), Michael Day (Microsoft), Paul Harrington (Microsoft) and Juval Lowy (Author). I'd like to thank David Wilkie, my direct manager at Hewlett Packard, and Russ Daniels (Hewlett Packard) for providing support and encouragement to write the book. I'd also like to thank the editorial team at Prentice Hall PTR and Hewltt-Packard Press Jill Harry (Executive Editor), Anne Garcia (Production Editor), Jim Markham (Developmental Editor), Pat Pekary (Publisher and Manager, HP Books), and Scott Suckling (MetroVoice Publishing Services). Finally, and most important of all, I'd like to thank my wife Vrushali and my 3-year old son Jay, both of whom patiently stood by me despite the fact that I broke my promise of spending more time with them.
17.
9 PART I Chapter 1.What Is .NET? .NET is Microsoft's new initiative for building applications regardless of the platforms or languages in use. The .NET label applies to three distinct but related items: a vision for how information technology (IT) will evolve, a software platform to build .NET applications, and an application-hosting business designed to support the vision and market the platform. In this chapter, we inspect each of these items from a fairly nontechnical perspective. By the end of the chapter, the readers will have a good idea of where Microsoft is going with the .NET initiative and will understand the terminology, features, and services offered by the .NET Framework, the software platform for .NET applications. Introduction In June 2000, Microsoft announced the .NET initiative a major shift in the technical direction for Microsoft and a major shift for those engaged in developing software based on Microsoft tools and technologies. The label .NET has been applied to three distinct entities. They are: 1. A vision of how software will evolve to take advantage of the Internet and encompass the increasing variety of computing devices that are joining the PC in customers' offices, pockets, and homes. 2. A software platform to help developers build such applications and also to address some long-time shortcomings of Windows. 3. An application-hosting business that will deliver applications as services over the Internet. In the rest of the chapter, we examine these three ideas in detail. The Vision The Web has evolved a long way from browsing static Hypertext Markup Language (HTML) pages. Today, users can download music, participate in auctions, buy items online, and even talk to their family face-to-face over the Internet. Even businesses are not behind. They have been implementing business-to-business (B2B) and business-to-consumer (B2C) applications that communicate over the Internet. Microsoft believes that the Internet will evolve from a collection of isolated Web sites and applications into a general "communication bus" for distributed applications. Individual parts of the distributed application could be running on different hardware and software platforms. The computing devices include your desktop systems as well as mobile devices such as cellular phones, Pocket PCs, personal digital assistants (PDAs), and so on. Even household appliances such as microwaves and dishwashers will participate in this communication over the Internet.
18.
10 Web Services To befair, this vision of anytime, anywhere, any-device computing is also shared by many other software companies, such as IBM and Hewlett-Packard, and many respected computer scientists around the world. A key technology enabler for this distributed computing model is Web services. A Web service can be defined as a service that can be accessed programmatically over the Web. Companies can make their business applications available as Web services. These Web services, for example, can be used to integrate applications within various divisions of the same company. The Web services can also be used to automate communication over the Internet between two companies. To be able to develop distributed applications that transcend geographical, hardware, and OS boundaries, Web services need to be based on universally accepted standards. Table 1.1 lays out the foundation elements of Web services. Table 1.1. Web Services Foundation Standard Purpose Internet Ubiquitous communication Extensible Markup Language (XML) Universal data format Simple Object Access Protocol (SOAP) Communication protocol Web Services Description Language (WSDL) Describe the semantics of the methods available on a Web service Universal Description, Discovery, and Integration (UDDI) Publish and find Web services In the "anywhere computing" vision, clients that wish to access Web services can be geographically distant from the servers. As the Internet has a broad geographical reach, it makes sense to deliver the services over the Internet. To develop distributed client/server applications that transcend hardware and OS boundaries, Extensible Markup Language (XML) has been accepted as the universal language for defining data formats. XML provides a common data format that does not require business partners or customers to use a particular programming language, application, OS, or hardware. XML by itself is not enough to achieve the client/server communication. To access a Web service, a client has to make a procedural call to the server, pass in the needed parameters, and get back the return value. A protocol has to be defined for such an exchange of information. To this effect, the W3C[1] has defined a protocol called Simple Object Access Protocol (SOAP). SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It specifies how a remote procedure call can be expressed in XML format. It is an XML-based protocol that consists of three parts: [1] The World Wide Web Consortium (W3C) is a standards body that develops specifications to promote the evolution of the Web. More information on W3C can be found at http://www.w3.org/. 1. An envelope that defines a framework for describing what is in a message and how to process it. 2. A set of encoding rules for expressing instances of application-defined data types. 3. A convention for representing remote procedure calls and responses.
19.
11 Although the SOAPspecification is independent of the underlying transport protocol, Hypertext Transport Protocol (HTTP) has been the sweet spot for the industry. Most companies let HTTP traffic pass through the firewall. Contrast this to other distributed object technologies such as Distributed Component Object Model (DCOM) and Common Object Request Broker Architecture (CORBA) that require opening ports on the firewall, thus compromising security. Also note that although the client and the server can communicate with each other using raw SOAP packets, helper utilities are available on most platforms to hide the grunge work of creating SOAP packets: 1. The client makes a method call passing in the required parameters. 2. A helper utility on the client side packages the method call and its parameters into a SOAP-compliant XML format and sends the SOAP packet to the remote server over a network protocol, preferably HTTP. 3. A helper utility on the server side unpackages the SOAP packet and calls the actual method, passing in the method parameters. On returning from the method, the utility repackages the return value into a SOAP packet and sends it back to the client. 4. The client-side utility unpackages the SOAP packet and returns the value to the client. From a programming perspective, using the SOAP helper utilities makes calling a method to a remote system as simple as making a local method call. Why is SOAP important? Because it provides the foundational invocation mechanism for application-to-application computing, irrespective of the underlying hardware or operating system platforms. The SOAP specification is a work in progress. The current draft of the specification can be found at W3C's Web site [W3C-01]. Now we know how to make method calls on a Web service programmatically. However, we still don't know what methods are available as part of the Web service. We need a mechanism that describes the programmatic "interface" of the Web service; that is, the methods available on the Web service, the parameters for each method, and the return value of each method. A popular choice is to define this interface in Web Services Description Language (WSDL), an XML-based language that lets you express the functions and formats supported at any endpoint of the service. This programmatic interface is referred to as the contract of the Web service. At this point, we know how to obtain method information on a Web service and how to make the method call. The remaining problem is to identify the server running the Web service. It is likely that in some cases the server is known to the client. However, it is possible that the client is not particularly happy with the quality of the service or the cost of accessing the service, and may wish to use a different server. The beauty of the Web services programming model is that it doesn't matter which server provides the service, as long as the server adheres to the Web service contract. Coding-wise, all that is needed is to point to the right server. There is no change required to the rest of the code. An industry-wide effort is underway to promote e-commerce among businesses. This project, called Universal Description, Discovery, and Integration (UDDI[2] ), is an initiative to create an open framework for describing Web services, discovering businesses, and integrating business services over the Internet. UDDI enables business applications to do the following:
20.
12 [2] Complete information onUDDI can be found at http://www.uddi.org/. 1. Discover each other. 2. Define how they interact over the Internet. 3. Share information in a global registry that will more rapidly accelerate the global adoption of B2B e-commerce. Essentially, UDDI provides the "yellow pages" on the Internet for the industry. UDDI has also embraced SOAP and WSDL, making it convenient to obtain information from its repository programmatically. Note that standards such as XML, SOAP, WSDL, UDDI, and so on, are not proprietary to Microsoft, although Microsoft has been a major contributor in driving these standards. Microsoft's .NET initiative is built around XML, SOAP, and WSDL. The .NET technology and tools make it easy for companies to develop Web services and to consume other Web services. Heterogeneous Environment It is possible that Web services and other future applications may run on a variety of computing devices, not just PCs or mainframes. These devices need not run the same operating system. Microsoft Windows is not the only choice for the OS. Therefore, jointly with Intel and Hewlett-Packard, Microsoft has submitted the core .NET Framework specifications to European Computer Manufacturer's Association (ECMA[3] ).This ECMA specification is referred to as the Common Language Infrastructure (CLI). The CLI specifications are not wedded to any OS. The .NET runtime is Microsoft's implementation of the CLI for Windows OS. However, Microsoft has also made available the source code to a working implementation of ECMA CLI that builds and runs on FreeBSD, a variation of the UNIX OS. Currently, there are various other initiatives underway to implement CLI on other variations of UNIX such as Linux. [3] ECMA is an international standards organization. Their purpose is to standardize information and communication systems. More information on ECMA can be found at http://www.ecma.ch/. Among other things, the CLI also specifies that a CLI-compliant application must run on different platforms without being rewritten for each specific platform. A .NET application, for example, can run on many processors and platforms (currently, only x86 compatible CPUs are supported) as long as no OS-specific calls are made. So, if things go as expected by various implementers of CLI, you will be able to take a .NET executable that is built on one OS and run it on many other Windows and non-Windows OSs. Smart Devices In the not so distant future, Microsoft expects that PCs will be joined by many new kinds of smart devices such as data-enabled wireless phones, handheld computers, tablet PCs, home appliances, and so on. If an application has to run on all these devices, the application will have to automatically adapt its user interface to the capabilities of the device it runs on. This not only means adapting to each device's display and input capabilities, but also supporting new modes of communication such as spoken language and handwritten text. To support software development for the smart devices, Microsoft has announced to release a subset of the .NET Framework called the .NET Compact Framework.
21.
13 Compelling User Experience Microsoftbelieves that, in this new distributed computing world, the experience should be very simple and compelling for the end users. To provide such experience, Microsoft intends to host a set of foundation services or building-block services. These building-block services will act as a central repository of data for users, allowing them to store e-mail, calendar information, contacts, and other important data, and present this data as needed to other Web sites. The Platform Figure 1.1 shows an overview of the .NET platform. Figure 1.1. The .NET Platform. The central component of the .NET platform is the .NET Framework. This consists of a runtime environment called the common language runtime and a set of supporting libraries. The runtime environment controls the installation, loading, and execution of .NET applications. The libraries provide code for common programming tasks, thus increasing developer productivity. The libraries also provide a layer over many OS APIs, providing an isolation from OS dependencies. Most enterprise applications and Web services require back-end servers to perform operations such as storing data, exchanging messages via e-mail, and so on. Microsoft's family of .NET servers such as SQL Server, Exchange Server, and so on, can be used to obtain such functionality. The family also includes some special servers that provide a higher level of integration and aggregation of Web services. BizTalk Server and Commerce Server, application frameworks for e-commerce, fall under this category. The .NET platform also includes a set of developer tools such as Visual Studio .NET and programming languages such Visual Basic .NET and C# (pronounced C sharp). In developing applications, developers can also take advantage of the foundation services offered by Microsoft or other software vendors. We take a look at a few important foundation services in a later section of this chapter.
22.
14 Finally, the Windowsoperating system is at the base of the .NET platform. Operating systems such as Windows NT, Windows 2000, and Windows XP do not come preinstalled with the .NET Framework. However, one can install the framework separately by downloading it from Microsoft's Web site. Windows .NET and the newer releases of the Windows operating system are expected to ship with elements of the .NET vision. The .NET Framework The .NET Framework is a high-productivity, standards-based, multilanguage application execution environment. It consists of a runtime environment called the common language runtime and a set of libraries to boost programmers' productivity. Common Language Runtime The common language runtime, or just the runtime, is Microsoft's implementation of the ECMA CLI specification. When a .NET application is run, the common language runtime manages the loading and execution of the code and provides many runtime services to the application. If you have been developing your code under COM, you will be surprised by the simplicity the .NET model offers. Forget dealing with GUIDs, CLSIDs, PROGIDs, IDL, type-libraries, apartments, server registration, AddRef(), Release(), and so on. They all have been replaced by a simpler model of programming. It would not be fair to say that COM is dead. The basic tenet of COM, the ability for applications to communicate across hardware and programming language boundaries, is still present in .NET. In particular, the first release of the .NET Framework still depends on COM+ to provide enterprise services such as transaction and queuing. However, the COM infrastructure has certainly been replaced under .NET. Besides providing a simpler model of communication, the .NET runtime provides many other services to simplify programming and to develop robust and secure applications. Any code that targets the .NET runtime is called the managed code;it can take advantage of the services offered by the .NET runtime. All other code, including existing legacy code, is called the unmanaged code. Although, the common language runtime can execute the unmanaged code, the code cannot avail the services provided by the common language runtime. Let's examine some services provided by the common language runtime. Simplified Deployment In the simplest case, the directory hierarchy of an application can be copied to a machine and the application can be executed. There is no need to modify any registry entry. This is referred to as XCOPY deployment. The framework also solves the "DLL hell" problem. A common problem with Windows is that upgrading a dynamic-link library (DLL) routinely breaks an already installed application. Under .NET, two versions of an application can execute side-by-side without breaking any application.
23.
15 Hardware Independence When a.NET application is built, the code is stored in a language called Microsoft Intermediate Language (MSIL). When the application is executed, the runtime performs a just-in-time (JIT) compilation to convert the MSIL code to machine instructions. This makes a .NET application run on any CPU type, as long as a JIT compiler is available for the CPU. Moreover, the JIT compiler can perform hardware-specific optimizations, boosting execution performance. Automatic Memory Management When writing managed code, developers need not worry about memory deallocation issues. The runtime automatically frees any unused memory using a mechanism called garbage collection. Not only does this simplify programming, but it also makes the application more robust; as programmers sometimes simply forget to free previously allocated memory. Cross-Language Integration The .NET Framework defines a specification called the Common Language Specification (CLS). Among other things, the CLS defines a set of data types that is intended to work across all .NET-compliant programming languages. If these data types are used, the runtime provides seamless integration between applications developed in different programming languages. The integration is so seamless that a type defined in one language can be inherited in another language. Even exceptions can be thrown from one language and caught in another language. Metadata Driven An application developed for .NET contains complete information about the types it implements, the methods each type defines, the parameters for each method, and so on. The presence of such metadata eliminates the need for COM-style IDL and type libraries. This also makes it possible to keep the Windows registry clean. Enhanced Security .NET defines a permission-based security model that offers fine-grained control over which assembly can access what resource on the local machine. The security becomes especially important when users access code over the Internet. The runtime prevents the executions of any unauthorized code. Interoperability The runtime provides the functionality to integrate with legacy COM servers. The runtime also provides the ability to invoke any unmanaged code or Windows APIs (although such an application may not be portable to other platforms). Class Libraries The .NET Framework also provides hundreds of types (classes, interfaces, structures, etc.) that not only enable programmatic access to the features of the common language runtime, but also provide a number of useful high-level services to help developers boost their productivity. These types are collectively referred to as the .NET Framework Class Library.
24.
16 The .NET FrameworkClass Library can roughly be broken down into four groups 梩 he Base Class Library (BCL), ADO.NET and XML, Windows Forms, and ASP.NET. The BCL implements the set of functionality that is shared by all the applications targeting the .NET Framework. It defines and implements all the core data types (e.g., string, integer, float, etc.) used by every application. ADO.NET is the successor to an earlier data access technology called Active Data Object (ADO). ADO.NET provides a set of classes to access and manipulate data. The data is typically obtained from a database and can be converted to XML for better remote manipulation. Windows Forms (often called WinForms) provide features for developing standard Windows desktop applications. They provide a rich, unified set of controls and drawing functions for all languages, effectively wrapping Windows user interface (UI) APIs in such a way that developers rarely would need to access the Windows APIs directly. ASP.NET is the successor to a Web-request processing technology called Active Server Pages (ASP). ASP.NET adds two significant enhancements to ASP: 1. It simplifies the process of developing Web services. 2. It provides a model of developing a Web browser-based UI called Web Forms. Controls on the Web Forms run on the server but the UI is displayed on the client browser. This takes lots of coordination and behind-the-scenes activity. However, the end result is Web interfaces that look and behave very much like WinForms interfaces. Moreover, the Web interfaces can deal with a broad range of browsers such as Microsoft Internet Explorer as well as less capable browsers such as the ones found on wireless palmtop devices. WebForms will render themselves appropriately on the target device. Development Tools A productive set of tools is critical to developer success on a new platform like .NET. Microsoft offers many development tools to build Web services as well as traditional Windows applications. Programming Languages .NET offers an improved ball game for programmers. Features such as automatic memory management make it unnecessary for programmers to deal with these issues. The .NET programming model encourages object-oriented programming. To simplify programming under .NET and to exploit the capability of the .NET Framework to its fullest extent, Microsoft has introduced a new programming language called C#, which offers the simplicity of Visual Basic and the flexibility of C++. C# borrows most of its constructs directly from C++, making C++ and Java programmers feel right at home. More information about the origins of C# can be found in an interview with Anders Hejlsberg [Osb-00], the chief architect for C#.
25.
17 Microsoft has alsointroduced Visual Basic .NET, an upgrade to its popular Visual Basic programming language. Visual Basic .NET adds object-oriented features as well as provides full access to .NET platform features. The new feature list of Visual Basic.NET can be found in [Pat-01a] and [Pat-01b]. Microsoft has also extended C++ to develop code for .NET. This extension is referred to as Managed Extension for C++. Finally, .NET provides an open standard for developing language compilers that target .NET. Many independent software vendors are providing their own programming language support for .NET. The .NET Framework SDK The .NET Framework SDK contains documentation, tools, C# and Visual Basic .NET compilers, and samples for developers to write, build, test, and deploy .NET applications. The SDK also includes the .NET Framework as a redistributable package. The SDK can be downloaded free of charge from Microsoft's Web site. Remember to read the licensing agreement when you download the SDK. Visual Studio .NET Visual Studio .NET is the next generation of Microsoft's popular multilanguage development tool, built especially for .NET. Visual Studio .NET helps you build as well as consume Web services and .NET applications quickly. It supports C#, Visual Basic .NET, and C++. Any other .NET programming language can be easily integrated into Visual Studio .NET. The Integrated Development Editor (IDE) contains many features, such as IntelliSense, to boost programmers' productivity. Visual Studio .NET will likely remain the most popular choice for developing .NET applications. Foundation Services Microsoft also envisions that providing a compelling user experience to consumers is important for the success of Internet as a communication bus. To this effect, Microsoft plans to release some foundation or building block Web services. Software vendors can leverage against these foundation services. With time, Microsoft intends to release more such foundation services. The first set of foundation services are being released as a product called Microsoft .NET My Services. Table 1.2 lists these services. Table 1.2. Microsoft .NET My Services Name Description .NET Address Billing, shipping, and other addresses .NET Profile Name, picture, and so on
26.
18 .NET Contacts Electronicaddress book .NET Location Electronic and geographical locations .NET Alerts Send and/or electronic notifications .NET Inbox E-mail and voice-mail storage .NET Calendar Appointment management .NET Documents Users can store, share, and back up important files .NET ApplicationSettings Application settings .NET FavoriteWebSites List of favorite Web sites .NET Wallet Credit card information, coupons, receipts, and so on .NET Devices Settings for various personal devices .NET Services List of services provided .NET Usage Usage report for the preceding services A common theme behind Microsoft's foundation services is that the user information is stored at a central place and can be retrieved anytime, anywhere. These foundation services open the door for developing innovative software applications. For example, using .NET Calendar, a scheduling application at your doctor's Web site might be able to access your Web-hosted calendar to see when you are available, schedule an appointment at an appropriate time, and remind you using .NET Alerts (on your PC, pager, or any other notification device) when the appointment is approaching. As a Web service is based on open standards, the scheduling application can be developed for Windows, UNIX, or any other OS. The foundation services are built around user identity. Microsoft provides a user authentication service called Microsoft Passport that deserves special attention. User Authentication Service Consumers do their Internet shopping on many Web sites. A common problem that they face today is that they are asked to enter account information, such as user name and password, on each Web site they visit because each Web site maintains its own database of customers. Microsoft Passport promises a solution to this dilemma. Rather than signing up for an account on every Web site, the user signs up for a Passport account, either through http://www.passport.com/ or through related services like Hotmail (every Hotmail user automatically has a Passport account). The user can choose how much information to store in the MS Passport account from a simple user name and password to a complete wallet with credit card information, shipping and billing addresses, and more. Using Microsoft's single sign-in (SSI) service, a Passport member can use one sign-in name and password at all participating Web sites. Passport sign-in names are tied to individuals and not computers, members can access Passport sites from a wide range of devices. What Does It All Mean?
27.
19 Microsoft's .NET initiativeimpacts consumers, businesses, software vendors, and developers. Consumers will be the biggest beneficiaries of .NET and the foundation services. As the data is stored on the Web, they will be able to access documents and other personal information anytime, anywhere, from any smart device. For businesses, implementing applications using Web services solves many of today's B2B and B2C integration challenges. By making their business applications available as Web services, or by providing innovative Web services, software vendors may be able to find newer modes of revenue. Microsoft itself is gravitating toward providing a subscription-based model for its services, thereby ensuring a monthly source of revenue. The .NET Framework helps developers write robust, secure, Internet-enabled code in a language of their choice. The rich set of class libraries provided by the .NET Framework, as well as new features in Visual Studio .NET will boost developer productivity. References [W3C-01] Gudgin, Martin, et al., "SOAP Version 1.2," W3C Working Draft, July 2001. www.w3.org/TR/2001/WD-soap12-20010709/ [Osb-00] Osborn, John, "Deep Inside C#: An Interview with Microsoft Chief Architect Anders Hejlsberg," July 2000. windows.oreilly.com/news/hejlsberg_0800.html [Pat-01a] Pattison, Ted, "Basic Instincts: New Features in Visual Basic .NET," MSDN Magazine, May 2001. msdn.microsoft.com/msdnmag/issues/01/05/instincts/instincts0105.asp [Pat-01b] Pattison, Ted, "Basic Instincts: Exploiting New Language Features in Visual Basic .NET, Part 2," MSDN Magazine, August 2001. msdn.microsoft.com/msdnmag/issues/01/08/Instincts/Instincts0108.asp
28.
20 Chapter 2. FromC++ to C# This chapter focuses on various stages of building .NET applications from development to debugging and deploying. You will write simple C# programs to explore common programming paradigms under the .NET Framework. In the process, you will learn the differences and similarities between C++ and C#. By the end of the chapter, readers will understand many key concepts of the .NET Framework and will be fairly comfortable developing simple .NET applications using C#. A Simple "Hello User" Program Let's get right down to business. The following program displays a greeting to the console: // Project HelloUser class MyApp { public static void Main() { System.String userName = "Jay"; System.Console.WriteLine("Hello " + userName); } } This simple application defines a class called MyApp that has a single static public method called Main. Under .NET, methods must generally be members of a class or a struct. A class or a struct form the basic unit of organization under .NET and are generally referred to as types. We explore the differences between a class and a struct in detail in Chapter 4. Static method Main is considered the entry point for the program. When the program is run, the .NET runtime starts executing the code in Main. Inside method Main is a reference to two other types called System.Console and System.String. These two types are defined in the BCL, a library provided by the .NET Framework, and are implemented in MSCorLib.dll file. Among other methods, System.Console provides a method WriteLine to write a string to the console. This code prefixes a greeting to the specified user name and displays the resultant string to the console. How are we able to call a method such as Writeline from the System.Console class without even creating an instance of the class? This is possible because this method is marked as static. As with C++, for any .NET language, calling a static method on a class does not require the class to be instantiated.
29.
21 System.Console actually isthe fully qualified name of class Console belonging to the namespace System. A namespace provides scope to your data types, thus reducing naming conflicts in large projects. Within a single namespace, no two types can have the same name. However, two types from two different namespaces can have the same name, but by qualifying the type with its namespace, each type can be uniquely identified. Obviously, typing fully qualified class names each time you refer to a class can quickly become unbearable. Fortunately, C# allows a way to declare the namespaces to be used up front. This is done with the using keyword. Using this keyword, our "hello user" code can be rewritten as follows: // Project HelloUser using System; class MyApp { public static void Main() { String userName = "Jay"; Console.WriteLine("Hello " + userName); } } When processing the source file, the compiler searches for an identifier in the current namespace. If the identifier cannot be resolved in the current namespace, the compiler then searches each of the namespaces specified in the using statements. For our application, the compiler automatically resolves references to types Console and String from the namespace System. You may be wondering what the current namespace for class MyApp is. The code doesn't seem to scope the class under any namespace. It just so happens that scoping a C# class within a namespace is optional. If not explicitly scoped, a class automatically gets scoped under an unnamed namespace, also called the global namespace. Let's build our application. The SDK provides a command-line tool, csc.exe, to compile C# programs. Assuming the code is defined in file HelloUser.cs, the following command line, when executed, generates our executable: csc.exe -t:exe -out:HelloUser.exe -r:MSCorLib.dll HelloUser.cs Command-line switch -t:exe tells the compiler to generate a console user interface (CUI) executable as target. Other possible targets are Windows user interface (WUI) executables (switch -t:winexe) and library executables (switch -t:library). Switch -out can be used to specify the filename for the generated executable, HelloUser.exe in our case. Switch -r requires some explanation. The .NET Framework provides a number of library files that implement a variety of classes, such as the one introduced earlier, MSCorLib.dll. These library files are actually referred to as assemblies. We cover assemblies
30.
22 in detail inthe next chapter. For now, it is sufficient to know that an assembly stores a collection of types (class, struct, etc.). Think of an assembly as a logical EXE or DLL file. Even HelloUser.exe is an example of an assembly. While processing HelloUser.cs, the compiler needs to know which assembly to use to resolve reference to external types System.Console and System.String. The specified compiler option, -r:MSCorLib.dll, tells the compiler to look for external types in MSCorLib.dll assembly. Compiler Response File There is yet another way to specify the command-line parameters to the compiler. You can specify some or all of the parameters in a text file and ask the compiler to process this file using the @<file> command-line option. This file is referred to as the response file. For example, you can create a response file HelloUser.rsp that contains the following text: -t:exe -out:HelloUser.exe -r:MSCorLib.dll To generate the executable, you can now use the following command: csc.exe @HelloUser.rsp HelloUser.cs If you just name the file csc.rsp, the compiler will always automatically read it. The .NET Framework supplies a csc.rsp response file that is located in the same directory as csc.exe. The compiler always reads this file first, followed by a csc.rsp file from the current directory, if present. You can turn off reading csc.rsp files by specifying the 杗 oconfig option to the compiler. Note that MSCorLib.dll is a special file in the sense that it contains all the core types such as integers, characters, strings, and so on. As these types are used so frequently, the C# compiler automatically references MSCorLib.dll. This makes our command-line option, -r:MSCorLib.dll, redundant. Besides MSCorLib.dll, there are many other assemblies in the framework that also get used frequently. These assemblies are all listed in the framework-supplied csc.rsp file. The C# compiler generates a console executable by default (i.e., if no target type is specified) and, if the output filename is not specified, it is named as the first source filename with the extension replaced as .exe. Thus, our previous command line can actually be reduced to the following and still would produce the same result: csc.exe HelloUser.cs
31.
23 Let's run ourapplication, HelloUser.exe. The following is the output: Hello Jay Congratulations! You just completed your first .NET program. Behind the Scenes HelloUser.exe is a standard Win32 portable executable (PE) file, that is, the Windows OS should be able to load this file and, if required, execute the instructions stored in the file. However, unlike normal PE files, HelloUser.exe does not contain native machine language instructions. Instead, it contains code in MSIL. MSIL code resembles assembly language instructions. So how does HelloUser.exe run and produce the desired output? After all, a machine can execute only the native code. The .NET Framework provides the common language runtime environment to manage the execution of MSIL code. Any code that targets the common language runtime is called managed code; it benefits from many features offered by the common language runtime. One such feature is on the fly conversion (also referred to as JIT conversion) of MSIL code to native machine language instructions. Why not just produce the native code in the first place? Recall from the previous chapter that Microsoft envisions making .NET available on a wide range of devices. As machine language instructions are tied to a specific processor type, the same executable may not be able to run on a device with a different processor type. By compiling program logic into a processor-independent intermediate language, .NET makes it possible to achieve platform independence. Plus, the generated native code can take advantage of hardware-specific optimizations. What Is Managed Code? For the common language runtime to manage the execution of the code and to provide features to the code, the managed code contains extra information about the code, such as the methods available in a class, the parameters and return value for each method, and so on. This extra information is called the metadata (data about data). MSIL code is always managed code. Unlike managed code, unmanaged code does not contain any .NET style metadata. Examples of unmanaged code are COM applications and any legacy software. Although unmanaged code can execute under the common language runtime, it cannot benefit from its features. We will look at common language runtime and its features in detail in Chapter 4. At this point, we have already covered quite a few important terms used under .NET. Here is a small quiz for you. Can you define the terms MSIL, the common language runtime, type, assembly, namespace, and BCL? For your convenience, I have defined them once again in Table 2.1.
32.
24 Table 2.1. .NETTerminology Name Description MSIL Microsoft Intermediate Language. It resembles assembly language instructions. Common language runtime The heart of .NET. It provides the runtime environment for executing .NET applications. Also referred to as the .NET runtime or simply run-time. Type Basic unit of encapsulating data with a set of behaviors. Classes and structures are examples of types. Assembly A logical DLL or EXE file that contains type definitions and their implementation. Namespace A logical scoping of types. By qualifying a type with a namespace, naming conflicts between types can be reduced. BCL Base Class Library. A library that contains core types such as System.String. The BCL is spread over a couple of assemblies. MSCorLib.dll is one such assembly. Please review Table 2.1. It is very important that you get accustomed to these terms, as we use them quite frequently throughout the book. C# for C++ Programmers C# offers many features that make a C++ or Java programmer feel right at home. The curly braces and the statements ending with semicolons all made their way into the language. However, C# also introduces many new features. Some features will make a Java programmer more at home. Let's take a brief look at a few of these features. In many respects, we really are examining the programming language support provided by the .NET Framework. Before we proceed further, it is worth discussing the coding conventions that has been adopted by the .NET community. The Visual Studio .NET documentation includes an article on coding techniques and programming practices for improving the quality of the source code. Search for "Coding Techniques" under the documentation. Some important ones regarding naming conventions that I wish to mention are as follows: • Since most names are constructed by concatenating several words, use mixed-case formatting to simplify reading them. • Use Pascal casing for methods, properties, and events (the latter two covered shortly). Here, the first letter of each word is capitalized. An example of a method name is GetDirectoryName and a property is UserName. • Use camel casing for member fields, local variables, and method parameters. In this case, the first letter of each word except the first is capitalized. Some examples are dirName and documentType. • Avoid Hungarian notation if possible. Many languages under .NET (e.g., Visual Basic .NET) do not have this notion. The only exception I have is that I prefer member fields to be prefixed with m_. This helps me differentiate between member fields and local variables. Primitive Data Types
33.
25 Like any othertyped programming languages, C# provides its own primitive datatypes. However, C# primitive types are nothing more than a mapping to the base datatypes supported by the common language runtime. For example, C# primitive data type string is an alias of System.String, a class that we have already come across. As a matter of fact, the following two lines of code generate identical compiler output: string = "Jay"; System.String = "Jay"; This begs the following question: Should you use string or String in your code? This is really a matter of personal preference. The base types supported by the common language runtime are all defined in the BCL. Table 2.2 shows a list of C# primitive datatypes and their corresponding BCL counterparts. Table 2.2. C# Primitive Datatypes C# Type Description BCL Type bool 32-bit true/false value System.Boolean sbyte 8-bit signed integer System.SByte byte 8-bit unsigned integer System.Byte char 16-bit Unicode character System.Char short 16-bit signed integer System.Int16 ushort 16-bit unsigned integer System.UInt16 int 32-bit signed integer System.Int32 uint 32-bit unsigned integer System.UInt32 long 64-bit signed integer System.Int64 ulong 64-bit unsigned integer System.UInt64 float IEEE 32-bit float System.Single double IEEE 64-bit float System.Double decimal 96-bit monetary type (used in financial calculations) System.Decimal string String of Unicode characters System.String object Root system class System.Object Take note of the datatype System.Object. This type is the root class; all other types get derived from System.Object, either directly or indirectly (through another type that ultimately gets derived from System.Object). We examine System.Object in detail in Chapter 4 when we discuss the .NET infrastructure. Member Accessibility Under C#, the accessibility level of a type, and each member of the type (method, member field, etc.), can be individually controlled by means of specifying an access modifier on the member. Table 2.3 shows the list of possible access modifiers.
34.
26 Table 2.3. AccessModifiers under C# Modifier Description public Access is not restricted. Any method from any type can access this member. private Access is limited to the containing type. protected Access is limited to the containing type and any of its derived types. internal Same as public except access is limited to the current assembly. External assemblies have no access. protected internal Full access within the current assembly. For external assemblies, access is limited to types that are derived from the containing type. sealed When applied to a class, the class cannot be inherited. When applied to a overridden method, the method cannot be overridden in a derived class. Structs are implicitly sealed. The following code excerpt demonstrates how access modifiers can be applied to a type and its members: // Project AccessModifiers public class Foo { public int x; internal int y; protected internal int z; private void Test1() {} public void Test2() {} } Note that specifying access modifiers is not mandatory. If not specified, the member defaults to private for a class or a struct and public for an interface or an enum. Also note that a top-level type, such as class Foo in our example, can itself be qualified with a public access modifier. This makes the class accessible from external assemblies. If not explicitly specified, a top-level type defaults to the internal accessibility level. Field Initialization Consider the following code excerpt: // Project FieldInit class Foo { private int x; private String y; private Baz z; public Foo() {
35.
27 x = 10; y= "Hello"; z = new Baz(); } // Other methods } Initializing a class' member fields in the class' instance constructor is a common programming technique. C# offers a shorthand mechanism to achieve this task. The fields can be initialized at the time of their declaration, as shown here: class Bar { private int x = 10; private String y = "Hello"; private Baz z = new Baz(); // Other methods } Note that you can still define a constructor and initialize the fields. If a field is initialized in the declaration statement as well as in the instance constructor, the runtime initializes the field twice, first from the declaration and then from the instance constructor. Type Constructors You are already familiar with instance constructors, which are responsible for setting an object instance to its initial state. In addition to instance constructors, C# (and the .NET Framework) supports type constructors (also known as static constructors or class constructors). A type constructor lets you perform any initialization required before any members declared within the type are accessed. The common language runtime guarantees that the type constructor gets executed before any instance of the type is created or before any static field or any method is referenced. To understand type constructors, consider the following C# code: class Foo { static public int x = 10; } When this code is compiled, the compiler automatically generates a type constructor for Foo. This constructor is responsible for initializing the value of static member variable x to 10. In C#, you can also implement the type constructor yourself. You just need to define a constructor on the type and qualify it with static keyword, as illustrated here: // Project TypeConstructor class Foo {
36.
28 static public intx; static Foo() { x = 10; } } Note that a type constructor does not accept any parameters and it can access only the static members of the type. Its usual purpose is to initialize static fields. Reference and Value Types Under C#, some datatypes can be instantiated only on the stack, whereas other datatypes can be instantiated only on the heap. Simple datatypes (int, long, double, etc.) and structs are always instantiated on the stack. These types are called value types. Types that are created on the heap are called reference types. C# classes belong to the reference type; that is, an instance of a class is always created on the heap. There is one exception to the rule 梚 f a value type is contained within a reference type, then the value type is created on the heap (at the time the reference type is being instantiated). A datatype can be instantiated using the new keyword, as shown here: class Foo { ... } ... Foo a = new Foo(); Note that when instantiating an object on the heap, there is no need to use C++ style pointer declaration. As a matter of fact, the C# compiler prevents you from specifying a pointer unless you mark your code as unsafe. Unsafe mode is primarily used for interoperability with C-style APIs, which we discuss in a later chapter. It is possible to instantiate a value type without using new. In this case, however, the instance has to be initialized before it is used. Otherwise, the compiler generates an error. The following code excerpt illustrates this: public void sub() { int a = new int(); // Legal int b; int c = b; // Illegal. b has to be initialized first int d = 5; int e = d; // Legal ... }
37.
29 It is worthnoting the dissimilarity between C# and C++ when treating the value type. Under C++, you can create a value type either on the stack or on the heap. For example, the following C++ line of code creates an instance of int type on the heap: int* p = new int(); The following line under C#, however, creates the instance on the stack. int p = new int(); From a programming perspective, there is an important distinction between the reference type and the value type. When a reference type variable is assigned to another, the memory location for the underlying object is shared. In contrast, value type variables hold a separate copy of the object. The following code excerpt demonstrates the behavior for the reference type: // Project ReferenceType public class Foo { public int x; public static void Test(Foo a, Foo b) { a.x = 5; b.x = 10; b = a; Console.WriteLine(b.x); // will display "5" a.x = 20; Console.WriteLine(b.x); // will display "20" } }; Note that if one reference type variable is assigned to another, changing a member field's value via one variable causes the value for the corresponding member field in the other variable to change. Finally, the common language runtime provides for automatic conversion between a value type and a reference type wherever possible. Conversion of a value type to a reference type is called boxing and the conversion from a reference type to a value type is called unboxing. We look at boxing and unboxing and its performance impact when we discuss the internals of the common language runtime in Chapter 4. Arrays The notion of an array is similar to that in C and C++: An array contains elements that can be accessed through indexes. All the elements in an array should be of the same type. The length of the array is the number of elements it can contain and the rank of an array is the number of dimensions in the array.
38.
30 The following codeshows how to create an array of four elements of type int: int[] arr = new int[4]; The following code shows how to create an array and initialize it with values: int[] arr = new int[] {20, 10, 40, 30}; Note that the length of the array need not be explicitly specified. The compiler automatically computes the proper length based on the number of elements. Here is the traditional C way of accessing the elements in an array: // Project Arrays for(int i=0;i<arr.Length;i++) { Console.WriteLine(arr[i]); } C# also defined a keyword foreach to repeat a group of statements for each element in an array, as shown in the following code excerpt: // Project Arrays foreach(int elem in arr) { Console.WriteLine(elem); } Behind the scenes, an array gets derived from System.Array class. This class provides methods for creating, manipulating, searching, and sorting arrays. For example, the following code sorts our array in ascending order: Array.Sort(arr); The following code searches for an element of value 50 in the sorted array using the binary search algorithm: int index = Array.BinarySearch(arr, 50); Console.WriteLine (( index < 0) ? "Not found" : "Found"); The returned value contains the index of the element if a match is found. Otherwise, it returns a negative number that is a bitwise complement of the index of the first element that is larger than the specified value. Arrays and Binary Search
39.
31 Always ensure thatthe array to be binary-searched has been sorted. Performing a binary search on an unsorted array results in unpredictable behavior. Also, note that if a match is not found, the return value could be any negative number and not necessarily ?. Do not specifically check for ? in your code. Once allocated, the size of an array cannot be changed. If you need an array that can grow dynamically, take a look at ArrayList, a smarter cousin of Array. Properties Under the common language runtime, a property is a controlled way of exposing a class's member fields to the client code. Instead of exposing the member field directly to the client, using a property provides a smart way to validate the input value or to restrict access to the data member. A property can have a get accessor (code responsible for reading a member field's value), a set accessor (code responsible for setting a member field's value), or both. A property without a get accessor is write-only and a property without a set accessor is read-only. The following code excerpt demonstrates how to define a property under C#: // Project Properties class Foo { private String m_userName; ... public String UserName { set { m_userName = value; } get { return m_userName; } } } Under C#, keyword get is used to implement the get accessor and keyword set is used to implement the set accessor. For the set accessor, the input value is stored in an implicit parameter named value. The preceding code shows how the member variable m_userName can be exposed via property UserName. The following C# code excerpt shows how to set or get a property:
40.
32 Foo x =new Foo(); ... x.UserName = "Jay"; // calls the set accessor on UserName String y = x.UserName; // calls the get accessor on UserName Indexers Much like C/C++, C# provides indexed access to an element of an array. Under C#, however, indexed access is not just limited to array types. A type such as a class or a struct can also be accessed using an index. This is done by defining an indexer on the type. An indexer is a special property named this that takes an index as parameter. The following code excerpt shows how to define an indexer. Here, class Foo is just a wrapper for a string array: // Project Indexer class Foo { public Foo(int val) { m_arr = new String[val]; } public String this[int index] { get { return m_arr[index]; } set { m_arr[index] = value; } } private String[] m_arr; }; As can be seen, defining an indexer is similar to defining a property. As with properties, you can drop either one of the accessors. The following code excerpt illustrates how to get indexed access to Foo: public static void Main() { Foo f = new Foo(5); f[0] = "Jay"; Console.WriteLine(f[0]); }
41.
33 Remember that allthe code used in this book is available on the companion Web site. Delegates and Events A delegate is roughly equivalent to a function pointer in C; it encapsulates a method with a specific signature. Unlike a function pointer, however, a delegate is type-safe; the prototype of the function assigned to the delegate has to strictly match the delegate definition. The following code shows an example of defining a delegate: public delegate void MyDelegate(); In this code, type MyDelegate encapsulates a function that takes an empty parameter list and has a void return type. The following code excerpt shows how to declare a variable of MyDelegate type. The intention is to simulate clicking a Windows button. public class MyButton { public MyDelegate Click; }; Even though a member variable can be exposed to the public directly, it is a good practice to expose it as a property. The revised code is shown here: // Project Delegates public class MyButton { private MyDelegate m_Click; public MyDelegate Click { get { return m_Click; } set { m_Click = value; } } } A delegate can store either a static method or an instance method as a callback element, as shown in the following code: public class MyApp { public void X() { Console.WriteLine("Instance method called"); }
42.
34 static public voidY() { Console.WriteLine("Static method called"); } static void Main() { // create a button MyButton btn = new MyButton(); // Case 1: Adding a static method to the delegate btn.Click += new MyDelegate(MyApp.Y); // Case 2: Add an instance method to the delegate MyApp a = new MyApp(); btn.Click += new MyDelegate(a.X); // Simulate button click (invoke the delegate) btn.Click(); } } The last statement in the preceding code invokes the delegate (this is equivalent to simulating a button click in our example). When the delegate is invoked, it results in calling each element on the invocation list. Here is the output from the program: Static method called Instance method called Note that the code uses += syntax for specifying the callback elements. Under C, you are used to assigning a single callback function to a function pointer. This functionality is still supported under .NET 梱 ou can assign a single callback element to a delegate using the = operator. However, delegates under .NET also support multicast functionality; that is, a single delegate can have a callback list of more than one element. C# uses += syntax to specify additional callback elements on a delegate. Although delegates can be used as a notification mechanism, the .NET Framework introduces a formal notion of event for this purpose. Keyword event can be applied to a delegate field or a delegate property to convert it to an event, as shown in the following code: // Project Events public class MyButton { private event MyDelegate m_Click; public event MyDelegate Click { add { m_Click += value;
43.
35 } remove { m_Click -=value; } } } Note that an event property differs from a normal property in the sense that the accessors are defined using add and remove keywords. Also, unlike a normal property where defining just one accessor is permitted, an event property requires both the accessors to be defined. The callbacks can be added to the event similar to that for delegates. However, the preferred term for the callbacks in this case is event handlers. Events introduce a few subtle changes to the way a delegate works. One important change is that only the class that defines the event can raise the event. The following line of code taken from class MyApp of our previous example on delegates will not work any more: btn.Click(); A work-around is to add a method to the event holder class to raise the event, as highlighted in the following code: public class MyButton { private event MyDelegate m_Click; public event MyDelegate Click { add { m_Click += value; } remove { m_Click -= value; } } public void RaiseEvent() { if (null != m_Click) { m_Click(); } } }; Now the users of class MyButton can call RaiseEvent to raise the event. Note that the event variable holds a null reference until an event handler gets added. Therefore, it is a good idea to check for null before invoking the delegate.
44.
36 Invoking a Delegate Alwayscheck for null before invoking a delegate. Programming sample Events also defines a Visual Basic .NET project MyVBApp that demonstrates how events can be used across languages. Interested readers may wish to look at the source code which can be found in the file MyVBApp.vb. Method Parameters Under C#, when a method is defined, each argument can be marked as either an input to the method, an output from the method, or an input as well as an output. Specifying an input parameter is similar to pass-by-value semantics in C++. Here is an example: void MyMethod(int val1, String val2); As in C++, the parameters are passed on the stack; that is, MyMethod gets a local copy of the parameters. Any change made to these parameters within the function does not get reflected in the caller's space. Obviously, if a parameter is of reference type, it is pointing to the memory in the heap. Therefore, any change made to its contents is also reflected in the caller's space. If the parameter is intended to be used purely as an output type, then it can be attributed with the out keyword, as shown in the following code: // Project Parameters // Method declaration void MyMethod(out Int32 val1, out String val2); // Caller code Int32 count; String name; MyMethod(out count, out name); Note that the caller need not initialize the out type arguments. As the out type arguments are meant only for updates within the method, any attempt to read the parameter within the method is flagged as an error by the compiler.
45.
37 To indicate thata parameter will be used both as an input to the method and an output from the method, the parameter must be qualified with the ref keyword. If a ref keyword is specified, the parameters must be initialized (assigned a value) before the method can be called, as demonstrated in the following code excerpt: // Method declaration void MyMethod(ref Int32 val1, ref String val2); // Caller code Int32 count = 5; String name = "Pradeep"; MyMethod(ref count, ref name); Implementation Inheritance C# lets one class inherit implementation from another class, much like C++. The following C# code excerpt demonstrates the syntax for implementation inheritance: class DerivedClass : SomeBaseClass { ... } Unlike C++, however, C# restricts the implementation inheritance to a single parent; that is, a child class cannot have more than one class as its parent. Note that this restriction is actually placed by the common language run-time; C# just enforces it. Later in the chapter, we look at another kind of inheritance called interface inheritance that somewhat offsets for this restriction. If a class is not explicitly inherited from another class, as in our previous examples, then C# implicitly inherits it from System.Object. Recall that System.Object is the root class for any type defined under .NET. Often, a base class needs to be initialized with some value during the construction of the derived class. C# provides a keyword base for this purpose. The following code excerpt demonstrates the use of this keyword: // Project Inheritance class MyBaseClass { public MyBaseClass(String a) { ... } ... } class MyDerivedClass : MyBaseClass {
46.
38 public MyDerivedClass(String b): base(b) { ... } ... } In this sample, MyBaseClass requires a String parameter in its constructor. When MyDerivedClass is instantiated in the code, the constructor argument passed to MyDerivedClass (which is a String type) gets passed to its base class, MyBaseClass. Keyword base can also be used from any method in the derived class to explicitly indicate that the method or the field being accessed is that of the base class, as illustrated in the following code excerpt: // Project Inheritance class MyBaseClass { ... public String MyMethod1() { return m_val; } } class MyDerivedClass : MyBaseClass { ... public String MyMethod2() { return "Hello " + base.MyMethod1(); } } Error Handling Windows C++ programmers have to deal with myriad (and inconsistent) ways of obtaining error information. For example, Win32 APIs return DWORD error code. COM APIs return HRESULT. Visual C++ built-in support for COM throws _com_error exceptions. Under the .NET Framework, there is only one way of indicating an error 梑 y throwing an exception. Moreover, exception handling is uniform across all the languages. For example, an exception thrown from C# can be handled by Visual Basic .NET. All exceptions under .NET are ultimately derived from System.Exception, a class defined in the BCL. The following line of code shows how to throw an exception containing an error string: // Project ErrorHandling void MyMethod() {
47.
39 ... throw new Exception("Houston,we have a problem"); } Although one can throw exceptions using System.Exception, it is intended to be used only by the common language runtime and the .NET Framework classes. For application developers, the preferred way is to use another exception class, System.ApplicationException, to return application-specific errors. System.ApplicationException extends System.Exception but does not add any new functionality. An exception that is thrown by a method can be caught by any of the callers in the call chain using a try-catch block, as illustrated in the following code excerpt: public void Test() { try { MyMethod(); }catch(Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); Console.Error.WriteLine(e.Source); } } System.Exception provides a number of helpful properties such as Message (contains the error message), StackTrace (the trace of call sequence), Source (the name of the application), and so on. If the caller wishes to provide some cleanup code, a try-finally block can be used, as shown in the following code excerpt: public void Test() { try { MyMethod(); }finally { Console.WriteLine("My cleanup"); } } Note that the code in the finally block is called irrespective of whether or not an exception occurs. If an exception does occur, it gets propagated to the next try-catch block in the call stack. To catch an exception and provide the cleanup code, a try-catch-finally block can be used, as shown here: public void Test() { try { MyMethod(); }catch(Exception e) {
48.
40 Console.Error.WriteLine(e.Message); }finally { Console.WriteLine("My cleanup"); } } Thelanguage also provides the mechanism to throw the same exception that was caught, as shown in the following code excerpt: public void Test() { try { MyMethod(); }catch(Exception e) { Console.Error.WriteLine(e.Message); throw; } } Even though System.Exception (or System.ApplicationException) provides a mechanism to return an error string, sometimes it is desirable to obtain extra error information. This can be done by extending the ApplicationException class. The following code excerpt shows an exception class that also returns an integer error code: public class MyException : ApplicationException { private int m_errorCode; public MyException(String sMsg, int eCode) : base(sMsg) { // pass error string to the base class m_errorCode = eCode; } public int ErrorCode { get { return m_errorCode; } } }; The caller can catch this specific exception type, if interested, as demonstrated in the following code: public void Test() { try { MyMethod(); }catch(MyException e) { Console.WriteLine(e.Message); Console.WriteLine(e.ErrorCode);
49.
41 }catch(Exception e) { Console.Error.WriteLine(e.Message); } } Finally,when the caller catches an exception, it can rethrow a new type of exception while still preserving the information from the caught exception. The Exception class provides a property called InnerException that can be used to store the caught exception. This in effect provides a mechanism to cascade all the exceptions in the call stack. The following code excerpt shows a class that preserves the old exception while providing for its own error information: public class MyExceptionEx : ApplicationException { private int m_errorCode; public MyExceptionEx(String sMsg, int eCode, Exception e) : base(sMsg, e) { m_errorCode = eCode; } public int ErrorCode { get {return m_errorCode;} } }; The following code excerpt demonstrates displaying error messages from a cascaded exception: void DumpExceptionInfo(Exception e) { Console.Error.WriteLine(e.Message); Exception innerE = e.InnerException; while(null != innerE) { Console.Error.WriteLine(innerE.Message); innerE = innerE.InnerException; } } Garbage Collection C++ programmers will detect the noticeable absence of the delete keyword in C#. We know that under traditional C++, an instance of a class created (with keyword new) if not deleted (with keyword delete) results in a resource leak. Things are different for code that targets the common language runtime. Recall that any code that targets the common language runtime is called managed code; it benefits from many features offered by the common language runtime. One such feature is memory management the common language runtime automatically detects if an allocated memory resource is no longer in use and frees it for us. This mechanism is called garbage collection. Because the garbage collector knows when to delete an object, there is no need to explicitly delete the object.
50.
42 Note that, asin C++, you can define destructors on your C# classes. However, the destruction of your object is not deterministic under .NET. You cannot rely on the destructor to be called, for example, at the time a variable goes out of scope. The destructor may be called later, at the time of the garbage collection. To help cope with this lack of deterministic finalization, .NET proposes an alternate technique. We look at this technique in Chapter 4 when we examine the mechanics of garbage collection. At this stage, I think we have covered enough basics of C# language. As we go through the rest of this chapter and the following chapters, we will discover many other features of the language. Meanwhile, those who wish to get more familiar with C# may wish to read Joshua Trupin's MSDN article [Tru-00] or can pick up a copy of Eric Gunnerson's book, A Programmer's Introduction to C# [Gun-00]. Some C# traps awaiting the unwary programmer can be found in [Lib-01]. C# has also been submitted to the ECMA, an international standards organization. The draft specifications of the language can be picked up from [Misc-00]. For now, I am anxious to do some coding. Common Programming Paradigms In this section, we explore some common programming paradigms under .NET Client/Server Programming Software engineering, to a large extent, is about writing software such that generic code can be reused in multiple applications. Let's rewrite the very first program we wrote. This time we factor out the logic for greeting the user. The intent is to provide the ability to reuse this greeting code in any other application. We first develop a console-based application. Console-Based Greeting Here is our new class that implements the greeting logic: // Project ReusableCode, File ConsoleGreeting.cs using System; namespace MyGreeting { class ConsoleGreeting { private String m_userName; public void Greet() { Console.WriteLine("Hello " + m_userName);
+ + Ath. 1905, 2:41. Jl. 8. 500w. “Where he fails, it is for lack of the supreme touch of art, not of the high and ardent intention.” + Critic. 47: 284. S. ‘05. 450w. “It is characteristic Gissing, but not good Gissing. His familiar effects are reproduced in a fainter form than of old, and there are no new effects indicating how, with further experiences of life, his talents would have developed.” + — Lond. Times. 4: 209. Je. 30, ‘05. 660w. “Each character, however lightly touched, is true, true to a hair, stepping forth from the page a rounded, breathing figure. It is excellent in workmanship and large of vision.” + + N. Y. Times. 10: 487. Jl. 22, ‘05. 590w. “Certainly it leaves one with a warmer personal feeling toward the author than did some of his earlier and abler books.” + Outlook. 80: 644. Jl. 8, ‘05. 110w. “Although not by any means the best of his books, shows no failure in power.” + Sat. R. 100: 251. Ag. 19, ‘05. 600w. + Spec. 95: 19. Jl. 1, ‘05. 750w. Given, Charles Stewart. Fleece of gold. *35c. Meth. bk. Five lessons derived from Jason’s quest of the Golden fleece are the contents of this work added to the “Modern messages”
53.
series. They areThe ruling element, The golden quality, The messenger of fate, The active hand, and Ethics of activity. * Gladden, Rev. Washington. Christianity and socialism. *$1. Meth. bk. “The subjects of these lectures, which were delivered before the students of the Drew theological seminary, are as follows: The Sermon on the Mount as a basis of social reconstruction, labor wars, the programme of socialism, and lights and shadows of municipal reform. Dr. Gladden’s attitude on most of these topics has been made known in earlier works. It has been his endeavor ... to bring Christianity and socialism into ‘more intelligible and more friendly relations.’”—R. of Rs. * “His volume may be characterized in a word as one of wise counsels.” + + Outlook. 81: 680. N. 18, ‘05. 130w. * + R. of Rs. 32: 752. D. ‘05. 120w. Gladden, Washington. Where does the sky begin? **$1.25. Houghton. Twenty sermons by the present moderator of the national council of Congregational churches. “They are concerned with the difficulties and needs of the religious life of the individual, rather than with the social problems to which Dr. Gladden hitherto has been more inclined.” (Ind.) “Those who are fortunate enough to read ‘Where does the sky begin?’ will be convinced that he is a preacher of marked spirituality.”
54.
+ + Am. J. ofTheol. 9: 600. Jl. ‘05. 120w. Atlan. 95: 706. My. ‘05. 180w. “He treats large and serious themes in a large and serious way, with a simple, direct and grave diction.” + + Bib. World. 26: 154. Ag. ‘05. 100w. “They are good sermons from the points of view of easy style and sincere moral enthusiasm; but very saddening sermons from their feeble content of doctrine.” + Cath. World. 80: 547. Ja. ‘05. 200w. “The twenty sermons here published are earnest, original and thoughtful, with forceful religious appeal and in excellent literary style.” + + Ind. 58: 500. Mr. 2, ‘05. 80w. Gladys, Evelyn, pseud. Thoughts of a fool. $1.50. Rosenthal. Twenty-six chapters “of virile iconoclasm ... of challenge to all the schools, with unfailing good humor to temper its plain speaking.” “A message to the inner life of man. In keen words the book endeavors to lay bare the heart and mind of the world. Satire, irony, and derision in all their forms are used to expose human nature to its own gaze.” (Bookm.) “A new writer of vigor and point.” + R. of Rs. 31: 384. Mr. ‘05. 100w.
55.
Glasfurd, A. I.R. Rifle and romance in the Indian jungle: being the record of thirteen years of Indian jungle life. *$5. Lane. The author has aimed “to present an old, though still engrossing subject in what is perhaps a novel manner: to carry the reader into more direct contact with the surroundings of the Indian sportsman and naturalist, and, while avoiding as much as possible the recital of personal experience with its stereotyped accompaniments, to lead him into the jungle, with all its fascinating variety of scene and season, hill and plain, where in spirit he may make acquaintance or renew an intimacy with its shy denizens and their habits.” The illustrations are taken from photographs or from sketches by the author. “Has succeeded in preparing a most cunning and admirable blend of fact, romance, weird mystery and sound advice. Search where one will through this entertaining book, one happens always upon sound literature, fine descriptions, good natural history and lively adventure.” + + + Acad. 68: 632. Je. 17, ‘05. 890w. “As sound and readable a book of its class as we have seen for many a day. The book generally, though occasionally a little slack in its phrasing, may be commended to young sportsmen as a guide, and to old as recalling pleasant reminiscences.” + + — Ath. 1905, 2: 45. Jl. 8. 530w. Reviewed by H. E. Coblentz. * + Dial. 39: 377. D. 1. ‘05. 290w.
56.
“That out ofsuch materials Capt. Glasfurd has succeeded in composing so excellent a book is greatly to his credit.” + Nation. 81: 206. S. 7, ‘05. 840w. + N. Y. Times. 10: 399. Je. 17, ‘05. 260w. + N. Y. Times. 10: 527. Ag. 12, ‘05. 960w. “He is an observer and a naturalist, as well as a sportsman, and he imports at times into his narrative an air of mystery and of romance which adds greatly to the charm of his work.” + + + Sat. R. 99: 848. Je. 24, ‘05. 260w. Glover, T. R. Studies in Virgil. $3. Longmans. “It falls naturally into four parts. The first is a chapter on the age and the man, and in it we are shown how Virgil, himself the child of a darker period, had a vision of a brighter day to come, and taught his countrymen to look forward hopefully to the age which was opening before them. The next consists of three chapters of literary studies: the first treats of the literary influences to which Virgil was subject, the second of his contemporaries, and the third about the growth of the myths about Aeneas. The third portion of the book deals, in three chapters, with the land and the nation, the three topics being Italy, Rome, and Augustus. The last part of the book is on Virgil’s interpretation of life, and here we have chapters on Dido, Aeneas, Hades, and Olympus, and a final summary.”— Nation. “In the long list of writings on Virgil and his poetry, Mr. Glover’s new book deserves a high place. The chapter about Dido is perhaps the best in the book, and certainly it is one of the
57.
most interesting andsensible essays on that famous episode of the Aeneid which we have ever read. The chapter on Aeneas is unconvincing, and almost a failure. Neither do we care much for the last chapter. But as a whole the book ought to be of great assistance to all who wish to get a true conception of the powers and the weaknesses of the greatest of the Roman poets.” + + — Nation. 80: 160. F. 23, ‘05. 760w. Spec. 94: 367. Mr. 11, ‘05. 1220w. Glyn, Elinor. Vicissitudes of Evangeline. †$1.50. Harper. The autobiography of a distracting and unconventional red- haired girl. She is the granddaughter of an earl, but her grand parents “forgot to marry,” and she is brought up by a rich old lady who leaves her to the bachelor heir as a part of his estate. Then come the vicissitudes. There are many characters, a handsome guardsman, a Scotch family, a lovely selfish married woman, and many others. The story is cleverly told and ends happily. + Acad. 68: 241. Mr. 11, ‘05. 360w. — + Ath. 1905, 1: 395. Ap. 1. 420w. “It has the whipped-cream consistency of its predecessors. It is mildly amusing.” William Morton Payne. + Dial. 38: 389. Je. 1, ‘05. 110w. “This Evangeline, though not without the serene egotism of lovely youth, is mighty good company. The men are not half
58.
bad, and thebook is full of cleverness.” + N. Y. Times. 10: 156. Mr. 11, ‘05. 690w. + — Outlook. 79: 762. Mr. 25, ‘05. 40w. Pub. Opin. 38: 943. Je. 17, ‘05. 190w. “The intention of the book seems to be to present a ‘naughty’ heroine. Evangeline is ‘not nice’.” — Reader. 6: 476. S. ‘05. 220w. “The story is witty, fluent, and amusing.” + R. of Rs. 31: 758. Je. ‘05. 60w. Gocher, W. H. Wadsworth; or, The charter oak. $2. W: H: Gocher, Hartford, Conn. “It purports to give all that is ascertainable relating to the hiding of the colonial charter, in 1687, in the famous oak tree at Hartford,—an incident of which Captain Joseph Wadsworth, according to doubtful tradition, was the hero. Wadsworth himself, is made to tell the story of the charter and its hiding, in language that is undisguisedly hodiernal, and with many interpolations of matter remotely or not at all connected with the main theme. The chapters on the Royal oak, on Cromwell, and on the regicides, are of this irrelevant nature. The wording, and still more the spelling, of Joseph Wadsworth’s will, which is printed in full, are so strikingly in contrast with the modernity of his supposed narrative, that not the faintest touch of illusion can cling to the latter. Mr. Gocher’s work is lavishly illustrated from old prints, old portraits, and modern photographs, and is provided with numerous footnotes bearing evidence of painstaking research.”—Dial.
59.
“A mingling offiction and somewhat delusive fact gives the text ... a doubtful historic value.” + — Am. Hist. R. 10: 720. Ap. ‘05. 50w. “Mr. Gocher has shown commendable antiquarian zeal in prosecuting his researches; yet his readers will probably wish he had not chosen to weave fact and fiction into the same web in a book that professes to be history rather than a novel.” + — Dial. 38: 130. F. 16, ‘05. 410w. “A book showing long and careful historical research, this volume will add much to the lore of the Connecticut colony, for the author treats of the story of the regicides, of the New Haven and other colonies, and includes interesting memoirs of Roger Ludlow, John Hooker, John Winthrop, and others who worked so effectively for the establishment of the first pure democracy in the New World.” + + N. Y. Times. 10: 32. Ja. 14, ‘05. 1690w. Goddard, Pliny Earle. Morphology of the Hupa language. $3.50. Univ. of Cal. press. Volume III. of the “American archæology and ethnology” series issued by the University of California. An extended examination of the Hupa language in which the various words and forms have been studied, analyzed and assembled into classes “that an adequate conception of the language as a whole might be obtained.” Goff, Clarissa (Mrs. Robert Goff). Florence and some Tuscan cities. *$6. Macmillan.
60.
“‘The purpose ofColonel and Mrs. Goff in this handsome volume is to describe the most characteristic monuments of Tuscany and to introduce into the account, legends and stories which are not always within reach of the traveler.... On a basis of historical narrative ... Mrs. Goff has given her readers a vivid picture of a city with a passion for politics, a passion for war, and a passion for art. Large attention is given to the churches of Florence.... The volume is richly illustrated in colors by Colonel Goff and issued with a decorative cover.”—Outlook. “To this charming series of pictures Mrs. Goff has provided an agreeable and easily-written commentary. Too easily written, we fear, to be quite exact in all its information. Mrs. Goff is at her best when she leaves the town for the country, and when she turns from history to describing the life of the Tuscan people of to-day, their festivals, quaint observances and ancient superstitions. The last chapter of the book is devoted entirely to such subjects, and it is one of the most enjoyable.” + + — Acad. 68: 235. Mr. 11, ‘05. 430w. “Mrs. Goff is an excellent guide round Florence, and supplies just the right sort of gossipy commentary for a book of this sort.” + + Ath. 1905, 2: 312. S. 2. 120w. Ind. 58: 1069. My. 11, ‘05. 130w. “Altogether the book is a charming one, likely to be of real value to the traveller, as well as a pleasing memento of some of the fairest scenes in Italy.” + + Int. Studio. 25: 273. My. ‘05. 520w. “The book seems the most satisfactory of the series.”
61.
+ + Nation. 80: 381.My. 11, ‘05. 410w. + + N. Y. Times. 10: 166. Mr. 18, ‘05. 960w. + + Outlook. 79: 856. Ap. 1, ‘05. 140w. “Mrs. Goff’s text is the pleasantest reading. Her touch is light, her knowledge wide, her style entirely natural, her sympathy and insight vivid and kindly. Slips in the book are more numerous than they should be.” + + — Sat. R. 99: 777. Je. 10, ‘05. 1030w. “The letterpress is written by Mrs. Goff, and contains much disconnected information. It is not quite safe to assume that it is all accurate.” + — Spec. 95: 261. Ag. 19, ‘05. 120w. Goldenberg, Samuel L. Lace; its origin and history. *$1.50. Brentano’s. The different kinds of lace are arranged alphabetically, with particulars as to their characteristics, their various subdivisions, and the manner in which they are made. The illustrations are especially clear and useful for purposes of lace study. The book contains much valuable information on machine-made laces, with diagrams and explanations of the lace and embroidery machines now in use. It tells also of the nets made for the
62.
foundations of certainkinds of lace. The opening article treats of the origin and history of lace. “The book is well adapted for its purpose, the enlightenment of ‘the busy man of affairs,’ but it is evident our author is hampered by having to express his meaning in English, and sometimes fails to convey what he intends.” + — Nation. 80: 158. F. 23, ‘05. 330w. Goldring, W. Book of the lily. *$1. Lane. “The author gives a clear general statement in regard to the cultivable species, hybrids, and varieties, and illustrates the handy treatise by exquisite pictures of a few of the best kinds and their most artistic setting.”—Nation. “It is written for those who delight in flowers and who love their gardens rather than for the connoisseur.” + + Ath. 1905, 2: 85. Jl. 15. 500w. + + Nation. 80: 290. Ap. 13, ‘05. 160w. “The introductory chapter on the geography and history of the lily is particularly interesting, as well as the treatise upon diseases and insect pests—that closes the book.” Mabel Osgood Wright. + + N. Y. Times. 10: 369. Je. 10. ‘05. 290w. “The great value of the book, however, is that it enables one without much trouble to get a conspectus of the whole lily- group. A much too ambitious title.”
63.
+ + — Sat. R. 100:156. Jl. 29, ‘05. 150w. Gomperz, Theodor. Greek thinkers: a history of ancient philosophy. v. 2 and 3. ea. *$4. Scribner. Volume I covered the period of Greek philosophy previous to Socrates, volumes II. and III. contain a discussion of Socrates, his life, his followers, and the great philosophical movement which he fathered; also an account of Plato and his philosophy. 13 chapters are given wholly to a critical analysis of the course and structure of Plato’s works. “It will admirably serve the purpose of the general reader who is interested in philosophy as an element in the history of human culture. And for the technical student who has mastered some of the more rigorous treatises, it will be useful in completing and vivifying his picture of the great thinkers of Greece.” Walter G. Everett. + + Am. Hist. R. 11: 123. O. ‘05. 560 w. (Review of v. 2 and 3.) “It may be said with confidence that Prof. Gomperz has succeeded admirably in accomplishing his design of composing ‘a comprehensive picture’ of the development of Greek thought, in which the historical setting of the narrative, the background of the picture, is ‘not unduly contracted.’ It is written in a vigorous, lively style.” + + Ath. 1905, 1: 520. Ap. 29. 2690w. (Review of v. 1-3.) “It offers not merely a cold technical enumeration of the tenets of the Greek philosophers, but a broad and rational discussion of the permanent significance of each great thought as it presents itself in historical sequence.” Paul Shorey.
64.
+ + Dial. 39: 31.Jl. 16, ‘05. 3110w. “Mr. Berry, like Mr. Magnus, has managed to give his translation the air of real English, and his version is on the whole a great improvement on the curiously abrupt and disjointed style of the original German. It is his moderation, his avoidance of extreme views, that makes Professor Gomperz so satisfactory a critic. The proof-reading of the English translation is far from perfect.” + + — Nation. 80: 442. Je. 1, ‘05. 1550w. (Review of v. 2 and 3.) “The arguments are concisely stated. A rich subject, it is richly treated by this veteran scholar.” + + Outlook. 79: 759. Mr. 25, ‘05. (Review of Vols. II. and III.) “In his last two volumes Professor Gomperz proves himself to be a thinker and a writer of distinction.” + + Sat. R. 99: 596. My. 6, ‘05. 1940w. Goodhart, Simon P. See Sidis, Boris, jt. auth. Goodhue, Isabel. Good things and graces. **50c. Elder. The following recipe shows the character of the group: Hygienic bread, Mix together the flour of love, made from the whole kernel (giving the all-inclusive flavor and quality); the leaven of spirit; the salt of common sense; the water of life appreciated. Let this rise in the encouraging atmosphere of
65.
patience. Knead andmold in the silence. Butter with cheerfulness, and serve to the entire family. * “In both form and spirit it is a thorough-going holiday booklet.” + Dial. 39: 385. D. 1, ‘05. 130w. * “The book is better than its outward appearance suggests, and is not one to be thrown aside after a single reading.” + N. Y. Times. 10: 797. N. 25, ‘05. 130w. * “The idea is cleverly carried out, and the directions for breakfast food, game pie, deviled tongue, and so on, are often witty as well as admonitory.” + Outlook. 81: 835. D. 2, ‘05. 110w. Goodloe, Carter. At the foot of the Rockies. †$1.50. Scribner. “Capital short stories of Canadian military and social life in the Northwest, with Indian customs and superstitions as the background.”—Outlook. “While lacking in individuality, are yet pleasantly readable.” + — Bookm. 22: 87. S. ‘05. 330w. “In her treatment, as well as in her situations, Miss Goodloe is rather too markedly Kiplingesque.” + — N. Y. Times. 10: 365. Je. 3, ‘05. 220w. “The tales have originality and force, with the added element of quiet humor.” + Outlook. 80: 244. My. 27, ‘05. 40w.
66.
Goodnow, Frank Johnson.City government in the United States. *$1.25. Century. Professor Goodnow of Columbia university contributes this volume to “The American state series.” He is known for his authoritative works on “Municipal home rule,” and “Municipal problems.” “In the present work, the author confines himself almost exclusively to a study of American conditions, and at the same time broadens the scope of the inquiry so as to embrace the entire field of city government, so far as that is regarded from the viewpoint of organization and structure.” (R. of Rs.) “Professor Goodnow’s book will be found eminently readable and useful as a text.” James T. Young. + + Ann. Am. Acad. 25: 348. Mr. ‘05. 670w. Reviewed by Winthrop More Daniels. Atlan. 95: 554. Ap. ‘05. 420w. R. of Rs. 31: 128. Ja. ‘05. 100w. * Goodnow, Frank Johnson. Principles of administrative law of the United States. *$3. Putnam. “In his ‘Comparative administrative law,’ published twelve years ago, Professor Goodnow gave an analysis of the administrative system, national and local, of the United States, England, France, and Germany. The rapid growth of the public interest in our system was thought by Professor Goodnow a sufficient justification for a new book giving a fuller account of American conditions, with special emphasis upon the legal side.”—Dial. * “The volume is a notable contribution to the literature of public law, and will prove of great use, not only to students,
67.
but also toofficials in the actual work of administration. But to the writer there appears to be a few omissions of importance, some of which would probably indicate a defect in our constitutional law.” David Y. Thomas. + + — Dial. 39: 304. N. 16, ‘05. 1410w. * “By his masterly grasp of the subject and his power of lucid exposition Prof. Goodnow has rendered great service to students and administrative officers. He has also made a distinct contribution to political science.” + + N. Y. Times. 10: 776. N. 18, ‘05. 330w. Goodwin, Maud Wilder. Claims and counterclaims. † $1.50. Doubleday. A young physician, the hero of Mrs. Goodwin’s story, has been rescued from death by a young man for whom he conceives a strong dislike. The situation becomes complicated by the fact that both men love the same girl, and Dr. Dilke is called upon by the father of the girl to endorse the character of a dishonest rival. “How to adjust the heroic savior of one’s life with the counterclaim of truth and of loyalty to a woman beloved is the problem Mrs. Goodwin’s hero has to solve.” (N. Y. Times.). “One can hardly help feeling that in ‘Claims and counterclaims’ Mrs. Maud Wilder Goodwin has not done justice to a motif and scheme which were very good. Mrs. Goodwin botches her climaxes by improbability or cumbrous narration.” — + Lit. D. 31: 666. N. 4, ‘05. 620w.
68.
“Its unique plot,its life-like characters, its brilliant execution in both dialogue and movement, are all crowned by a novel’s raison d’etre—its absorbing interest.” + + N. Y. Times. 10: 542. Ag. 19, ‘05. 1260w. Gordon, Armistead C. Gift of the morning star. $1.50. Funk. “He that overcometh ... I will give him the morning star.” The blood of a French mother flowing warm in the veins of her Dunker son sends him out in the world at the age of forty to seek his fortune, his whole being crying out against the repressed life of silent labor on the farm with which his older brother and sister are content. He wins his fortune as a boomer, he loses it in a single night, and in the end comes home again self conquered and content with his Dunker life and his Dunker sweetheart. “Mr. Gordon has made his book of somewhat incongruous material.” + — N. Y. Times. 10: 450. Jl. 8, ‘05. 550w. “A truly original story of Dunkard character. His pictures have all the vividness of reality.” + — Outlook. 80: 192. My. 20, ‘05. 100w. “A forcible and an original tale.” + + Pub. Opin. 39: 93. Jl. 15, ‘05. 150w. Gordon, John Brown. Reminiscences of the civil war. $1.50. Scribner.
69.
“A new andmoderate-priced edition of one of the very best of Southern books of reminiscences, written by a famous Southern soldier.”—Outlook. + + N. Y. Times. 10: 717. O. 21, ‘05. 140w. + Outlook. 81: 282. S. 30, ‘05. 20w. Goss, Charles Frederick. Husband, wife and home. **$1. Vir. A collection of forty-six sketches from life. “Such titles as True wife or married mistress, Curing your partner’s faults, Observing conventionalities, A good word for the ‘bad boy,’ Ability of parents to see a joke, Humanizing the beast, Nerve strain, indicate the extent of the field, and it is well dotted with pithy anecdotes and amusing stories. The whole is pervaded by strong and pure moral feeling.” (Pub. Opin.) “A book of good advice to husbands and wives, easy to read, not so easy to follow, but worth reading and worthy to be followed.” + Bib. World. 26: 400. N. ‘05. 20w. “Wide experience and keen observation of real life yield material which is treated with plain common sense, good wit, and no lack of humor.” + Outlook. 80: 790. Jl. 22, ‘05. 180w. Gosse, Edmund William. Coventry Patmore. **$1. Scribner. This fourth volume of the “Literary lives series,” contains a sketch of the poet’s life by one who knew him well in his later years. There is an account of his childhood, his life in London,
70.
and his lateryears, with a description of his personality, his work, and an estimate of his place in the world of letters. Acad. 68: 265. Mr. 18, ‘05. 1190w. “His volume is not without its limitations. But it is, on the whole, able, at times brilliant. Among Mr. Gosse’s faults dulness has no place. His book shows discriminating taste.” + + Ath. 1905, 1: 389. Ap. 1. 3560w. Reviewed by H. W. Boynton. Atlan. 96: 278. Ag. ‘05. 420w. “Mr. Gosse’s biography is highly interesting; explaining much that is mysterious in Patmore’s poetry through the strange personality of the poet, the biographer adds something of distinct value to the critical estimate. But his conclusions are at least open to debate.” + + — Dial. 38: 272. Ap. 16, ‘05. 360w. “Though he says too little about Patmore’s prose essays, which have singular merits of style, his attractive little volume, with its excellent illustrations, can be recommended to all to whom the more exhaustive Life by Mr. Champneys is not accessible.” + + — Nation. 80: 399. My. 18, ‘05. 2210w. “A delightful little book.” + + N. Y. Times. 10: 134. Mr. 4, ‘05. 1780w.
71.
“A well-balanced andinteresting biography. There is a careful, sympathetic, but entirely clear-sighted estimate of Patmore’s poetic gifts and of the value of his work.” + + Outlook. 79: 652. Mr. 11, ‘05. 220w. “Having the helpfulness neither of hostility nor of enthusiasm, and being needlessly apologetic both for Patmore’s domesticity and his mysticism.” — Sat. R. 99: 597. My. 6, ‘05. 1050w. Gosse, Edmund William. French profiles. *$1.60. Dodd. Sketches of French writers nearly all of whom are still living or only lately dead. They are given “in profile” not “from the front” or “from a direct and complete point of view,” and are chiefly “snap-shots, as it were, at authors in the course of their progress.” “Biography and criticism are deftly blended into an intermediate something and the last thing that the reader need apprehend is to be bored.” Richard Garnett. + + Acad. 68: 78. Ja. 28, ‘05. 700w. * “Mr. Gosse owed it to his readers to rewrite and revise more diligently. But his book is an agreeable and profitable one.” Edward Fuller. + + — Critic. 47: 568. D. ‘05. 530w. “It is far from being an indispensable book, but it is decidedly a useful one.”
72.
+ + N. Y. Times.10: 624. S. 23, ‘05. 700w. “A successful book, very agreeable to read, and more likely than any we have lately seen on the subject to attract that difficult creature, the general reader. If not infallible the book is full of interest. Any one who cares at all for French literature, and does not mind a little intellectual irritation, will read it both with pleasure and advantage.” + + — Spec. 94: 676. My. 6, ‘05. 1480w. * Gosse, Edmund William. Sir Thomas Browne. **75c. Macmillan. This volume in the “English men of letters” series, a monograph on Sir Thomas Browne, “bears every sign of care and of minute and skillful investigation. Browne himself is set before us with fullness of detail, his work is analysed with scholarly patience.... Browne was that rare favorite of the gods, a happy man of genius. His serene and serious mind was ever preoccupied with high, impersonal, ‘un-mating things.’ His daily life was that of a fond husband and father; a perfect friend; an alert citizen; a busy and successful doctor. But ... no man of letters ever tasted more deeply the lonely and exquisite gratifications known to the vividly inquiring, experimentalizing mind.” (Lond. Times.) * “Mr. Gosse has made a careful study of the materials at his disposal and in a comparatively short space embodies all that is known of the famous writer and physician. The faults of the book lie on the surface and may be briefly dismissed.” + + Acad. 68: 1070. O. 14, ‘05. 1500w.
73.
— Reviewed by H.W. Boynton. * + Atlan. 96: 842. D. ‘05. 310w. * “To put it crudely, what we miss in Mr. Gosse’s estimate of Browne is a feeling of pleasure. This is a very skilful biography; very intelligent criticism; but it is not the fine, the suggestive, the liberal, and illuminating criticism which we expected from a writer of Mr. Edmund Gosse’s accomplishments.” + + — Lond. Times. 4: 333. O. 13, ‘05. 3250w. * + — Nation. 81: 486. D. 14, ‘05. 3140w. * + Sat. R. 100: sup. 4. N. 18, ‘05. 890w. Gould, George Milbry. Biographic clinics. v. 3. Essays concerning the influence of visual function pathologic and physiologic upon the health of patients. *$1. Blakiston. These essays fully cover the ground indicated by the subject, and in them numerous common ailments are unhesitatingly traced to defective eyesight, and much good advice is given for school children and men engaged in literary or clerical work, all of which is borne out by illustrations from life. The technical terms used in the table of contents need not alarm the casual reader, who will find the text clear and easily understood. Gower, Edward Frederick Leveson. Bygone years. *$3.50. Dutton.
74.
Memoirs written bythe Honorable F. Leveson-Gower in his 86th year. As he never kept a diary, he chats merrily from memory of well-known people and things he has met with in the course of his long life. + + Acad. 68: 706. Jl. 8, ‘05. 1030w. “The author’s style is pleasant, though singularly familiar.” + Ath. 1905, 1: 710. Je. 10. 1110w. Reviewed by Jeannette L. Gilder. + + Critic. 47: 346. O. ‘05. 1180w. “Good humor, good sense, good birth and breeding, an entire absence of airs and pretensions, these are among the qualities that commend him to the reader.” + + Dial. 39: 211. O. 1, ‘05. 390w. “The volume is worth the attention of those who delight in the pleasant gossip of a genial and generous-hearted man of vast experience and wide information.” + Ind. 59: 988. O. 26, ‘05. 240w. “His book is like him, and it will therefore attract and give pleasure to a large number of readers.” + + Lond. Times. 4: 192. Je. 16, ‘05. 1130w. + Nation. 81: 220. S. 14, ‘05. 620w. N. Y. Times. 10: 481. Jl. 22, ‘05. 660w.
75.
“It is neverdull: it is never absorbing.” + N. Y. Times. 10: 568. Ag. 26, ‘05. 470w. “The book is characterized by good sense and wit and an agreeable conversational style.” + + Outlook. 81: 43. S. 2, ‘05. 260w. + + Spec. 95: 18. Jl. 1, ‘05. 1070w. Grafton, Rt. Rev. Charles Chapman. Christian and Catholic. *$1.50. Longmans. “The aim of the good bishop ... is ‘not controversial’ but to help souls who are in honest doubt to come into closer union with Christ ... The mass of Christians ... he designates as ‘the sects’ in distinction from ‘the church’ ... To secede from the Anglican church to the Roman is pronounced to be ‘the most terrible sin we believe a Christian man can commit.’”—Outlook. + + Ind. 59: 330. Ag. 10, ‘05. 70w. Outlook. 79: 855. Ap. 1, ‘05. 150w. Grant, Mrs. Colquhoun. Mother of czars. *$3.50. (*12s.) Dutton. “This ‘Mother of czars’ was the princess Dorothea of Würtemberg who married the Czarevitch Paul, son of Catherine II.... The czar’s two sons were Alexander I. and Nicholas I.... Mrs. Grant’s book consists largely of details of a tour made by
76.
the Grand DukePaul and his wife during the years 1780-81. The most enjoyable time was spent in France.”—Spec. “A very innocuous sketch of the wife of Paul I. of Russia.” + Critic. 47: 95. Jl. ‘05. 70w. “Neither as a study of personality nor as an historical monograph can this volume be praised with much heartiness.” + Nation. 81: 166. Ag. 24, ‘05. 480w. N. Y. Times. 10: 329. My. 20, ‘05. 270w. “Here related in an agreeable, sympathetic, unpretentious way.” + Outlook. 80: 393. Je. 10, ‘05. 110w. “With merits as an entertainment this book is marred as an authoritative portrayal of local colour by certain inaccuracies.” + — Sat. R. 100: 309. S. 2, ‘05. 1130w. + Spec. 94: 719. My. 13. ‘05. 250w. Grant, Robert. Orchid. †$1.25. Scribner. The orchid is a society belle in a set where money counts for everything. She marries a wealthy man whom she does not love, then comes to care for a poor man, secures a divorce and the custody of her child, which she later relinquishes to the father in return for two million dollars, and is thereby established once more upon a secure social foundation. “Clever as it is in its scenes, its dialogues, its enjoyable diversity of types, the real merit of the little volume lies not so much in what it actually gives as in what it suggests. ‘The
77.
orchid’ is aninteresting example of a psychological problem, worked out along lines almost purely realistic.” Frederic Taber Cooper. + + — Bookm. 21: 365. Je. ‘05. 480w. “The novel is as empty of psychological content as a headline. In this novel his style seems to be even more hard and colorless than formerly, his phrasing even more stereotyped and inaccurate.” O. H. D. — — Critic. 47: 90. Jl. ‘05. 750w. “Judge Grant’s characters are like chessmen: they are well defined and they move in a straightforward and logical manner. This simile does not imply that his characters are wooden, or that the situation lacks complexity.” + Ind. 58: 1008. My. 4, ‘05. 220w. “Told ... in this accomplished writer’s crispest and most interesting style.” + + N. Y. Times. 10: 356. Je. 3, ‘05. 800w. “It is a story which not only makes one think, but holds the interest as well.” + + N. Y. Times. 10: 390. Je. 17, ‘05. 190w. “A more thoroughgoing study of feminine selfishness and lawlessness is not to be found in American fiction.” + + Outlook. 79: 772. Ap. 1, ‘05. 90w.
78.
+ — Pub. Opin. 38:796. My. 20, ‘05. 170w. “Judge Grant’s sure touch and craftmanship are here, but ‘The orchid’ is hardly a worthy successor to ‘The undercurrent.’” + — R. of Rs. 31: 758. Je. ‘05. 120w. Grant, Robert. Undercurrent. $1.50. Scribner. “His theme is the very modern problem of the divorce evil, and he shows us how the undercurrent of emotion eventually triumphs over reason, and sweeps away the intellectual objections which stand in the path of a woman’s happiness. The situation is subtly handled, and one of the oldest of stories thereby acquires new distinction. It is the familiar story of marriage without much thought, the husband’s rapid development into a vulgar brute, and his final desertion of wife and children. Then the right man appears upon the scene, and the deserted wife is torn by the conflict between desire and duty. The plea of duty is voiced by the representatives of church and society, and their argument convinces her intellect, yet it takes only a slight mishap to the man whom she loves to bring about her surrender.”—Dial. Reviewed by W. M. Payne. + + Dial. 38: 15. Ja. 1, ‘05. 440w. (Statement of theme.) “The opposing claims of church and state to the regulation of marriage have never been more interestingly presented than in the debate between the rector and the lawyer in this book.” + Ind. 58: 1008. My. 4, ‘05. 190w.
79.
“As a carefullyconsidered, well-rounded, unimpassioned treatment, this book deserves attentive reading and deep pondering. The legal clearness with which Judge Grant has analyzed the question, and the thoroughness and skill with which he has embodied all its aspects in the individual characters and the action of the story, make ‘The undercurrent’ a constructive master-piece. Its interest is timely, therefore, rather than literary, and its value practical and ethical, not artistic. Neither of these facts, nevertheless, derogates from its literary importance. A notable literary expression of conviction among the books of its day.” + + Reader. 5: 254. Ja. ‘05. 550w. “Deals with two insistent problems of American society—the problem of enormous wealth and the problem of divorce. Judge Grant treats both with calmness and sanity. The characters and the story by means of which Judge Grant illustrates his views are thoroughly attractive from the point of view of literature. ‘The undercurrent’ is first of all a novel, and an excellent one, and only secondarily a book of purpose.” + + + R. of Rs. 31: 118. Ja. ‘05. 210w. “A sane and two-sided view of this problem. The author is master of many of the secret traits of woman’s nature, he rises with dramatic force to a crisis, and his method is always wholesome. But one must regret his excessive use of monologue, as though he could not let his characters interpret themselves.” J. R. Ormond. + + — South Atlantic Quarterly. 4: 96. Ja. ‘05. 140w.
80.
Granville, W. A.Elements of differential and integral calculus. $2.50. Ginn. To meet the need of a modern text-book on calculus which is at once rigorous and elementary, is the rather difficult task of the author. “On the one hand it is necessary to avoid the worthless and even vicious forms of reasoning which mar so many elementary treatises and which are simply intolerable to one educated according to modern standards of rigor. On the other hand, the author must not introduce subtleties of reasoning and logical refinements beyond the needs and comprehension of those who are to use the book. The volume under review is an attempt to solve this problem.” (Science). “Its first quality is clearness; its second, judicious accentuation. The ground notions are admirably handled, and throughout, the nature and limitations of important theorems are conscientiously indicated.” C. J. Keyser. + + + Educ. R. 29: 208. F. ‘05. 250w. “This is a book the main object of which seems to be to enable the student to acquire a knowledge of the subject with little or no assistance from a teacher; and, after a very careful study of it, we are enabled to say that the work is admirably constructed for the purpose.” George M. Minchin. + + — Nature. 72: 26. My. 11, ‘05. 670w. “In perusing Dr. Granville’s book one feels throughout that the author has in mind the requirements of modern rigor. We believe the present volume is eminently a safe book to put in the hands of the beginner. He will get no false notions which afterwards will have to be eradicated, with much difficulty; he will, on the other hand, acquire a considerable acquaintance
81.
with the principlesof the calculus and a good working knowledge of its methods. The relatively few blemishes in this work, the reviewer is glad to state, will be removed in the next edition.” James Pierpont. + + — Science, n.s. 21: 64. Ja. 13, ‘05. 1180w. “As well in its scope as in its spirit, the work is distinctly more than its author modestly styles it ‘essentially a drill book.’” Cassius J. Keyser. + + + Science, n.s. 22: 115. Jl. 28, ‘05. 150w. Gratacap, Lewis Pope. World as intention: a contribution to teleology, *$1.25. Eaton. “Under this title the author exhibits the movement which the world shows towards a purposed end. His aim is to help perplexed thinkers out of a state of mind which can neither get on without religion, nor get on with much that is claimed in the name of religion.”—Outlook. N. Y. Times. 10: 336. My. 20, ‘05. 360w. “Mr. Gratacap is certainly an independent and vigorous thinker; though his reading has evidently been more thorough in scientific lines than in philosophical. For lack of proportionate equipment in the latter his contribution to the problems of modern thought is hardly equal to the need.” + — Outlook. 79: 762. Mr. 25, ‘05. 400w.
82.
Graves, Algernon, comp.Royal academy of arts. v. I. *$11. Macmillan. This “complete dictionary of contributors and their work from its foundation in 1769 to 1904,” is compiled with the sanction of the president and council of the Royal academy. The artists’ names are arranged alphabetically and their works are listed under their names. Volume I. now issued, covers Abbayne to Carrington. Acad. 68: 623. Je. 10, ‘05. 110w. (Review of v. 1.) + + + Ath. 1905, 2: 87. Jl. 15. 2560w. (Review of v. 1.) + + + Nation. 81: 38. Jl. 13, ‘05. 770w. (Review of v. 1.) + + + Sat. R. 99: 671. My. 20, ‘05. 470w. (Review of v. 1.) Gray, Charles H. Lodowick Carliell. *$1.50. Univ. of Chicago press. Lodowick Carliell was a courtier dramatist of the reigns of Charles I and II. The name of Carliell is a conspicuous one in English literature, having as a later representative Thomas Carlyle. The present work includes a sketch of Carliell’s life, a discussion of his plays, and “The deserving favorite.” “He has shown a German thoroughness of work.”
83.
+ + — N. Y. Times.10: 574. S. 2, ‘05. 540w. “This is an interesting contribution to the history of the English drama.” + + Outlook. 80: 983. Ag. 19, ‘05. 90w. Green, Anna Katharine. Amethyst box. †75c. Bobbs. The spiriting away of an amethyst box in which was hidden a tiny vial containing a drop of deadly poison is followed by a sudden death. This furnishes the plot for one of Mrs. Green’s characteristic mystery stories into which is woven a double romance. The volume is uniform with the “Pocket book” series. * “This American writer ... builds better puzzles and controls her surprises more skilfully than any living sensation writer we can call to mind.” + + Acad. 68: 1155. N. 4, ‘05. 350w. “It is an absorbing story.” + N. Y. Times. 10: 324. My. 20, ‘05. 220w. * “They are utterly improbable, and full of extravagances and absurdities.” — Sat. R. 100: 600. N. 4, ‘05. 70w. Green, Anna Katharine. House in the mist. †75c. Bobbs. The first of these stories, “The house in the mist,” is the tale of vengeance which a wealthy testator wreaks upon his debauched heirs. According to the will they assemble, are
84.
apportioned their shares,and then trapped to their death. The harrowing succession of events is relieved only by the escape of the one worthy heir. The other story, “The ruby and the caldron,” shows the steps taken along the wrong scent in recovering a lost ruby. N. Y. Times. 10: 386. Je. 17, ‘05. 210w. + — Outlook. 80: 140. My. 13, ‘05. 70w. Pub. Opin. 39: 61. Jl. 8, ‘05. 30w. Green, Anna Katharine (Mrs. Charles Rohlfs). Millionaire baby. $1.50. Bobbs. The spiriting away of a baby, the heiress to three fortunes, furnishes a plot for a unique detective story. The detective himself, in the race with others for the fifty thousand dollar reward, narrates the steps that lead up to the mystery-solving stroke,—this latter involving a surprise even for the wily disciple of Sherlock Holmes. The book is illustrated by Arthur I. Keller. + — Acad. 68: 568. My. 27, ‘05. 340w. “She is, we think, the best American author of detective tales of the present, and in ‘The millionaire baby’ we have one of her very best books. It is clever in conception and treatment, it holds the interest.” + + Arena. 33: 340. Mr. ‘05. 260w. “Granted its fundamental improbability, the plot is skilfully constructed, and the interest of the story is successfully
85.
maintained.” + + Ath. 1905, 1:714. Je. 10. 150w. “As a detective story, ‘The millionaire baby,’ is as clever as anything Anna Katharine Green has written. You will not lay it aside until you know the whole story.” + + N. Y. Times. 10: 40. Ja. 21, ‘05. 550w. N. Y. Times. 10: 393. Je. 17, ‘05. 160w. “As a detective story it is ingenious; as fiction in any other sense it is worthless.” + Outlook. 79: 246. Ja. 28, ‘05. 40w. “A good story of compelling and sustained interest. Is quite the equal of any of the long line of stories which she has created.” + + — Pub. Opin. 38: 95. Ja. 15, ‘05. 450w. + — R. of Rs. 31: 762. Je. ‘05. 60w. Green, Evelyn Everett-. Secret of Wold Hall. †$1. McClurg. The marriage between Marcus Drummond and Lady Marcia Defresne was for the one the fulfillment of a ten-years’ dream —dating back to a moment when a bronzed traveler boy of sixteen rescued a child from her fall over a precipice—for the other, a release for herself and family from pecuniary predicaments. The man loves his wife, and the course of
86.
Welcome to ourwebsite – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookultra.com