AspectJ in Action(2)

aspectj_in_action_second_edition AspectJ has matured greatly since the first edition. It now has comprehensive support for Java annotations, along with support for other language improvements such as generics, variable-length argument lists, and covariant return types. 立即下载

1.8.1 Costs of AOP

Some of the costs associated with AOP are the usual suspects associated with any new
technology:
■ Making an investment in learning AOP
■ Hiring skilled programmers
■ Following an adoption path to ensure that you don’t risk the project by overextending yourself
■ Modifying the build and other development processes
■ Dealing with the availability of tools
Well-understood mitigation techniques are available for some of these issues:
■ Making a proper investment in learning the technology (and you already took a
step by reading this book)
■ Doing due diligence in checking skill availability (which is becoming increasingly easy due to Spring’s popularity)
■ Following a gradual adoption path, which we’ll show in part 2 of the book
Tools for AOP aren’t as mature as they are for Java (although they’re more mature
than for most other languages that run inside the Java VM). Fortunately, a lot of effort
is currently under way to improve the tooling around AOP, so this isn’t a serious
impediment to adopting it.

But one cost, still common to most new technologies, deserves more in-depth
treatment: the cost of abstraction. Abstraction lets you hide inessential details and
thus reduce the complexity of the underlying system. Good abstraction leads to the
creation of well-isolated modules. Because each module represents a much smaller
subsystem, abstraction offers a way to contain complexity at a level you can cope with.
Modularity is a divide-and-conquer approach to managing complexity. But the
abstraction introduced by AOP isn’t without costs.
NEED FOR GREATER SKILLS
Creating the right level of abstraction is a highly skilled job (many correct abstractions
are possible in a given system). A thorough understanding of the costs and benefits is
a hallmark of good software engineering. Merely understanding the implementation
mechanisms won’t yield useful abstractions.
In the context of AOP, you must understand how to fit the new unit of modularity—aspects—into the system. For that, you must apply decomposition techniques to
separate core concerns from crosscutting concerns. All this requires experience that is
often best gained by applying AOP in a gradual manner. The second part of the book
provides details of this strategy.
On the flip side, crosscutting logic is separated from business logic. This enables
you to use developers who understand only the business logic and not the intricacies
of the crosscutting functionality.
COMPLEX PROGRAM FLOW
Abstraction, by its nature, hides the details. In software systems, higher levels of abstraction always mean that less information is available at the code level. Looking at a code
segment doesn’t tell you the whole story that will unfold during system execution. For
example, in OOP, due to polymorphic methods, you can’t tell the exact method that will
be executed at runtime, because the choice of method is based on the type of the
object, not the static type of the declared variable. This makes analyzing program flow
a complex task. Even in procedural languages such as C, if you use function pointers,
the program flow isn’t static and requires some effort to be understood.
AOP abstracts away program flow even further. You may not know (except through
good tooling support) that a crosscutting action will take place in a certain part of the
code. Many programmers new to AOP get stuck until they realize that this separation
of concerns is the whole point. If you insist on understanding the exact program flow,
it’s a sign that you need to reflect a little longer on the core ideas of AOP. But just as
OOP requires a few years of practice before you understand the underlying core ideas,
most developers get AOP eventually.

1.8.2 Benefits of AOP

Now that you know the costs, let’s look at the benefits.
SIMPLIFIED DESIGN
The architect of a system is often faced with underdesign/overdesign issues. If you
underdesign, you may have to make massive changes later in the development cycle.
If you overdesign, the implementation may be burdened with code of questionable
usefulness. With AOP, you can delay making design decisions for future requirements
because you can implement those as separate aspects. You can focus on the current
requirements of the system.
AOP works in harmony with one of the most popular trends of agile programming
by supporting the practice of “You aren’t gonna need it” (YAGNI). Implementing a feature just because you may need it in the future often results in wasted effort because you
won’t actually need it. With AOP, you can practice YAGNI; and if you do need a particular
kind of functionality later, you can implement it without having to make system-wide
modifications. Even for the feature that you need, agile programming promotes developing them progressively. AOP helps you add features incrementally through the introduction of aspects, often without modifying the rest of the code.
CLEANER IMPLEMENTATION
AOP allows a module to take responsibility only for its core concern, thus following
the SRP; a module is no longer liable for other crosscutting concerns. For example, a
module implementing business logic is no longer responsible for the security functionality. This results in cleaner assignments of responsibilities, reduced code clutter,
and less duplication. It also improves the traceability of requirements to their implementation, and vice versa.
Reduced code tangling makes it simpler to test code, spot potential problems, and
perform code reviews. Reviewing the code of a module that implements only one concern requires the participation of an expert in the functionality implemented by that
module. Such a simplified process leads to higher-quality code.
Reduced code scattering avoids the cost of modifying many modules to implement
a crosscutting concern. Thus, AOP makes it cheaper to implement a crosscutting feature. By letting you focus on the core concern of a module and make the most of your
expertise, AOP also reduces the cost of the core concerns.
The end effect is a cheaper overall feature implementation, better time-to-market,
and easier system evolution.
BETTER CODE REUSE
The key to greater code reuse is a more loosely coupled implementation. If a module
is implementing multiple concerns, other systems requiring similar functionality may
not be able to use the module if they implement a different set of crosscutting concerns. With AOP, because you can implement each crosscutting module as an aspect,
core modules aren’t aware of crosscutting functionality. By modifying the aspects, you
can change the system configuration. For example, a service layer may be secured in a
project with one security scheme, in another project with another scheme, or in still
another project with no security at all by including or excluding appropriate aspects.
Without AOP, a service layer tied with a specific security implementation may not be
reused in another project.

1.9 Summary

The most fundamental principle in software engineering is that the separation of concerns leads to a system that is simpler to understand and easier to maintain. Various
methodologies and frameworks support this principle in some form. For instance,
with OOP, by separating interfaces from their implementation, you can modularize
the core concerns well. But for crosscutting concerns, OOP forces the core modules to
embed the crosscutting concern’s logic. Although the crosscutting concerns are independent of each other, using OOP leads to an implementation that no longer preserves independence in the implementation.
Aspect-oriented programming changes this by modularizing crosscutting concerns
in a generic and methodical fashion. With AOP, crosscutting concerns are modularized by encapsulating them in a new unit called an aspect. Core concerns no longer
embed the crosscutting concern’s logic, and all the associated complexity of the crosscutting concerns is isolated into the aspects. AOP marks the beginning of a new way of
dealing with a software system by viewing it as a composition of mutually independent
concerns. By building on top of existing programming methodologies, AOP preserves
the investment in knowledge gained over the last few decades.
In the last few years, AOP has become a practical technology. It has been deployed
in many organizations, big and small, to add powerful features that we might have otherwise shied away from or implemented in a laborious manner.
In the next eight chapters, we’ll study a specific implementation of AOP for Java,
AspectJ, as well as its integration with Spring. Those chapters and the rest of the book
will provide examples that use this technology to solve real problems. In chapter 2,
you’ll see how AspectJ implements AOP for Java.

AspectJinActionDriveBookPdf.pdf 英文原版 AspectJ in Action, Drive Book Pdf 立即下载

相关推荐

Aspectj_in_action_second_edition.pdf

Aspectj in action second edition

AspectJ in Action2版 中文版 简明的内容

AspectJ 是一个面向切面的框架. 定义了AOP语法, 用一个专门的编译器用来生成遵守Java字节编码规范的Class文件.

belldeep的专栏 3657

AspectJ_in_Action.pdf

AspectJ_in_Action.pdfAspectJ_in_Action.pdfAspectJ_in_Action.pdfAspectJ_in_Action.pdfAspectJ_in_Action.pdfAspectJ_in_Action.pdfAspectJ_in_Action.pdf

AspectJ in Action2版 中文目录

AspectJ 是一个面向切面的框架. 定义了AOP语法, 用一个专门的编译器用来生成遵守Java字节编码规范的Class文件.

belldeep的专栏 2338

虫洞java_java – 使用AspectJ实现虫洞模式

确实在AspectJ in Action中有一个例子.如果你看一下table of contents,你会注意到第12.2章正是你要找的.买这本书是个好主意.我可以热情地推荐它.因为我不确定是否可以复制&粘贴本书的部分内容,我将在此处引用模板:public aspect WormholeAspect {pointcut callerSpace() :;pointcut calleeSpac...

weixin_39960710的博客 132

Boston Spring Group First Meeting

Engineering Mark Fisher September 25, 2006 I am very excited to announce that the Spring SIG within the New England Java Users Group will be having our first meeting this Thursday (September 28th, 200...

[Blog][Domain] programb.blog.csdn.net 338

AspectJ in action

This chapter covers ■ Understanding crosscutting concerns ■ Modularizing crosscutting concerns using AOP ■ Understanding AOP languagesReflect back on your last project, and compare it with a project you worked on a few years back. What’s the difference? On

Cyber 923

book :aspectj in action

学习aspectj必须看得书籍,旧了点儿,不过思路上都没有太大的问题 新版2nd edition就要出来了,拭目以待

nlslzf的专栏 215

AspectJ in Action学习笔记

从今天开始,每天看一点AspectJ in Action,把学习笔记发到这儿。对自己也是一个促进,并希望与大家多多交流。以前看过Eclipse AspectJ,多少了解一些,也用它做过一点东西。现在由于论文的需要,我想把AspectJ的知识进行整理,使之体系化。...

cipherman 271

AspectJ in Action

HIGHLIGHT AspectJ in Action, Second Edition is a revised and udated edition, now covering AspectJ 6 and Spring 2.5. It guides Java developers through AOP and AspectJ using practical applications. DESCRIPTION AspectJ shows its real power when combined with Spring. This new edition focuses on Spring-AspectJ integration, which is a major feature of Spring 2.5. Readers will find this edition immensely helpful in answering questions like: What are the ways to leverage these technologies? What applications is AOP suitable for? What are the best practices and traps? Which kind of weaving should you use? When to use Spring AOP and AspectJ AOP? Expert author Ramnivas Laddad shows how to combine technologies such as Spring, Hibernate, Swing, and JDBC with AspectJ. The book fully covers the latest AspectJ 6 features. The applications and reusable code presented in this book show how AOP vastly simplifies enterprise development. This book is for developers who have experience in AOP and AspectJ, but also for those who are new to both. KEY POINTS Thorough coverage of AspectJ syntax Spring integration and weaving models Enterprise applications of AspectJ Monitoring and tracing, transaction management, and security MARKET INFORMATION Aspect Oriented Programming has found its way into the mainstream of Java development - most notably through Spring and a variety of JBoss technologies. AspectJ is by far the most widely recognized tool for AOP, and its recent integration into Spring 2.5 creates a strong motivation for the millions of Spring users to take a closer look at AOP and AspectJ.

Aspectj in Action: Enterprise AOP with Spring Applications (2nd Edition)

To allow the creation of truly modular software, OOP has evolved into aspect-oriented programming. AspectJ is a mature AOP implementation for Java, now integrated with Spring. AspectJ in Action, Second Edition is a fully updated, major revision of Ramnivas Laddad's best-selling first edition. It's a hands-on guide for Java developers. After introducing the core principles of AOP, it shows you how to create reusable solutions using AspectJ 6 and Spring 3. You'll master key features including annotation-based syntax, load-time weaver, annotation-based crosscutting, and Spring-AspectJ integration. Building on familiar technologies such as JDBC, Hibernate, JPA, Spring Security, Spring MVC, and Swing, you'll apply AOP to common problems encountered in enterprise applications. This book requires no previous experience in AOP and AspectJ, but it assumes you're familiar with OOP, Java, and the basics of Spring. "Clear, concisely worded, well-organized ... a pleasure to read." -From the Foreword by Rod Johnson, Creator of the Spring Framework "This book teaches you how to think in aspects. It is essential reading for both beginners who know nothing about AOP and experts who think they know it all." -Andrew Eisenberg, AspectJ Development Tools Project Committer "Ramnivas showcases how to get the best out of AspectJ and Spring." -Andy Clement, AspectJ Project Lead "One of the best Java books in years." -Andrew Rhine, Software Engineer, eSecLending "By far the best reference for Spring AOP and AspectJ." -Paul Benedict, Software Engineer, Argus Health Systems "Ramnivas expertly demystifies the awesome power of aspect-oriented programming." -Craig Walls, author of Spring in Action

【Spring in Action 4】 【Bugs && Solutions】AspectJ与JDK 版本冲突问题

原报错信息 这里只是截取核心报错信息,如下: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut aused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pefor...

乌哩哇啦的技术学习记录 1787

aop拦截action

使用@Aspectj风格的切面拦截action 第一种方式:1.切面: @Aspectpublic class ActionBeforeAspect {     private Logger logger = Logger.getLogger(this.getClass().getName());  @Pointcut("within(com.makeprogress.struts

wangwei9966的专栏 1569

PostgreSQL 日报|GiST 重扫误标死元组(8 月 17 日)

Tom Lane 提交了一个补丁,修复了 PL/Perl 中的两个 bug:hstore_plperl 中的空指针解引用,以及 plperl 处理 Perl tied 对象时的无限循环。Alexandre Felipe 澄清,真正的问题不在于持锁时长,而在于自旋锁保护下操作的安全性复杂度。作者将出席海得拉巴 PGDays 2026 大会,并在第二天的合规专题环节发表演讲,主题围绕如何在不影响开发和运维团队效率的前提下,对 PostgreSQL 环境实施有序的治理与管控。来支持列选择,无需引入新的数据结构。

IvorySQL的博客 233
上一篇: AspectJ in action
下一篇: 代码的坏味道之将 JSONObject 作为控制器层接口入参
crawlertinux
博客等级 码龄8年 32粉丝 97原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值