.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

相关文章
相关标签/搜索