.Net元编程【Metaprogramming in NET】 序-翻译

最近在看这本书,比较实用。抽点时间把公开的部分内容简单的翻译了一下,下文是序部分。

书的具体地址为:

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框架的作者。

从计算机科学的角度来看,从语言的角度来看,我们的行业已经基本停滞,而且是非常长的时间。缓慢演变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分布式框架。

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

你可能感兴趣的:(programming)