天天看點

.Net元程式設計【Metaprogramming in NET】 序-翻譯

最近在看這本書,比較實用。抽點時間把公開的部分内容簡單的翻譯了一下,下文是序部分。

書的具體位址為:

<a href="http://www.amazon.cn/Metaprogramming-in-NET-Hazzard-Kevin/dp/1617290262/ref=sr_1_1?ie=UTF8&amp;qid=1374625885&amp;sr=8-1&amp;keywords=Metaprogramming++in+.NET">http://www.amazon.cn/Metaprogramming-in-NET-Hazzard-Kevin/dp/1617290262/ref=sr_1_1?ie=UTF8&amp;qid=1374625885&amp;sr=8-1&amp;keywords=Metaprogramming++in+.NET</a>

對元程式設計這個問題,我從三個方面的經驗進行闡述:作為一個計算機科學家,業務開發員,以及。NET架構的作者。

從計算機科學的角度來看,從語言的角度來看,我們的行業已經基本停滞,而且是非常長的時間。緩慢演變3GLs(第三代語言)從C到Ç+ +到Java到Ç#已在逐漸改善,但沒有在開發人員的工作效率,代碼的可維護性,減少複雜性,或其他有意義的名額方面的重大飛躍。

(在這個例子中我選擇的是C語言的進展,因為它也許是最廣為人知的。相對BASIC,Pascal和許多其他語言家族有可數量級的多。)

圍繞DSL和其他抽象的概念這些最終可能打破我們過去的20-30年3GL世界的概念,元程式設計提供了有趣的可能。這本書雖然不關注這樣一個長遠的目标,我覺得可以作為一個起點。在.NET中使用元程式設計來獲得有價值的觀點,可能會激發你想了解我們行業的未來無數的核心思想。

作為一個超過25年的業務開發員,我 已經看到元程式設計已經成為最主流和最重要的軟體開發工具之一。元程式設計可以用于代碼生成器,以及軟體在運作時可以動态調整其行為。

在20世紀90年代中期由微軟和其他人嘗試建立 “ 向導 ” 針對不同的業務應用場景生成代碼被人們嘲笑。今天,這樣的代碼生成工具,在如Ruby on Rails,Eclipse和Visual Studio這樣而環境下被認為是無價的。大多數企業開發人員每天依靠他們的工具在開發過程中所産生的大量的代碼和建構過程。

同樣,開發者依靠在運作時生成的代碼Mock架構測試,動态UI生成工具,規則引擎等這些工具工作。更微妙的方面,如使用内省(反射)來建立資料綁定架構,元程式設計是無孔不入。

這本書探讨了用于實作代碼生成和動态應用程式的一些相關技術和方法,用于開發,建構和運作應用程式生命周期階段。了解這些概念,對有效地利用現有的工具很重要,同時對于建立您自己或改善那些存在工具的非常關鍵。

最後,作為廣泛使用的CLSA.NET業務對象架構的作者。我的架構内,我廣泛使用了許多在這本書中讨論的技術,包括反射,動态類型裝載,和表達式樹。

如果沒有這些技術,沒有元程式設計的基本概念,就不會有CSLA.NET架構。CSLA.NET在這方面也不不是唯一的。許多資料層,業務層和表現層架構,大量使用元程式設計技術,在對象 - 關系映射,業務規則,驗證規則,資料綁定和動态UI生成方面提供靈活的支援。

在我看來,元程式設計是非常重要的,因為它的核心概念在流行的開發和測試的架構和工具中,以及為使代碼生成工具和動态應用行為中使用。這也是我們這個行業的未來,我們期待提高可維護性和降低軟體生命周期的的成本方法,元程式設計時最有前途的重點領域之一。

這本書作為開始了解和充分發揮元程式設計能力,是一個很好的方式。

ROCKFORD LHOTKA

首席技術官 AT MAGENIC

CSLA.NET架構作者 CSLA .NET是一個.NET軟體開發架構,幫助開發者“為Windows、Web、面向服務和工作流等應用建構強大和可維護的業務邏輯層”。 CSLA是Component-based, Scalable, Logical Architecture的簡寫,CSLA . NET是Rockford Lhotka基于.Net設計的一套N-tier分布式架構。

<a href="http://www.cslanet.com/">http://www.cslanet.com/</a>

--如下是原文

When I think about metaprogramming I view it through three sets of experience: as a computer scientist, a business developer, and a .NET framework author.

From a computer science perspective, it is clear that our industry has been largely stagnant from a language perspective for an extremely long time. The slow evolution of  3GLs (third-generation languages) from C to C++ to Java to C# has resulted in incremental improvements, but no major leaps in terms of developer productivity, maintainability of code, reduction of complexity, or other meaningful metrics.

  (I chose the C language progression in my example because it is perhaps the most widely known. Comparable progressions exist for BASIC, Pascal, and many other language families.)

Metaprogramming offers interesting possibilities around the creation of domain-specific languages and other abstraction concepts that could eventually break us out of the 3GL world we’ve lived in for the past 20-30 years. Although this book doesn't focus on such a long-term goal, I think you can use Metaprogramming in .NET as a starting point to gain valuable perspective on myriad core ideas that might inspire you to think more about the future of our industry.

As someone who’s been a business developer for over 25 years, I’ve watched as metaprogramming has become one of the most mainstream and important tools for software development. Metaprogramming enables development time code generation as well as software that can dynamically adapt its behaviors at runtime.

In the mid-1990s people mocked attempts by Microsoft and others to create “wizards” that generated code for various business application scenarios. Today, such code generation tools are considered invaluable in environments as varied as Ruby on Rails, Eclipse, and Visual Studio. Most business developers rely daily on massive amounts of code generated by their tools during the development and build process.

Similarly, developers rely on runtime-generated code created by test mocking frameworks, dynamic UI generation tools, rules engines, and more. Even more subtle aspects of metaprogramming, such as the use of introspection (reflection) to create data binding frameworks, are pervasive.

This book explores a number of the underlying technologies and techniques used to implement code generation and dynamic applications during the development, build, and runtime phases of an application’s lifecycle. Understanding these concepts is important for effective use of existing tools, and critical for creating your own or improving those that exist.

Finally, I am the author of the widely used CSLA .NET business objects framework.  Within my framework I make extensive use of many of the techniques discussed in this book, including reflection, dynamic type loading, and expression trees.

A framework such as CSLA .NET couldn’t exist without these technologies, and without the basic concepts of metaprogramming. Nor is CSLA .NET unique in this regard. Many frameworks in the data layer, business layer, and presentation layer make heavy use of metaprogramming techniques to provide broad and flexible support for object-relational mapping, business rules, validation rules, data binding, and dynamic UI generation.

In my view, metaprogramming is extremely important because its core concepts are used in popular development and testing frameworks and tools, as well as to enable code generation tooling and dynamic application behaviors. It is also one of the most promising areas of focus for the future of our industry as we look for ways to improve maintainability and reduce the cost of software over its lifetime.

This book is an excellent way to get started down the road of understanding and fully using the power of metaprogramming.

CTO AT MAGENIC

CREATOR OF THE CSLA .NET FRAMEWORK