.Net元編程【Metaprogramming in NET】 序-翻譯

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

書的具體地址爲:express

http://www.amazon.cn/Metaprogramming-in-NET-Hazzard-Kevin/dp/1617290262/ref=sr_1_1?ie=UTF8&qid=1374625885&sr=8-1&keywords=Metaprogramming++in+.NET編程

 

對元編程這個問題,我從三個方面的經驗進行闡述:做爲一個計算機科學家,業務開發員,以及。NET框架的做者。app

從計算機科學的角度來看,從語言的角度來看,咱們的行業已經基本停滯,並且是很是長的時間。緩慢演變3GLs(第三代語言)從C到Ç+ +到Java到Ç#已在逐步改善,但沒有在開發人員的工做效率,代碼的可維護性,減小複雜性,或其餘有意義的指標方面的重大飛躍。框架

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

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

做爲一個超過25年的業務開發員,我 已經看到元編程已經成爲最主流和最重要的軟件開發工具之一。元編程能夠用於代碼生成器,以及軟件在運行時能夠動態調整其行爲。ide

在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分佈式框架。

http://www.cslanet.com/

 

--以下是原文

foreword

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.

ROCKFORD LHOTKA

CTO AT MAGENIC

CREATOR OF THE CSLA .NET FRAMEWORK

相關文章
相關標籤/搜索