【笔记】《Expert One on One J2EE Design And Development》笔记

《Expert One on One J2EE Design And Development without EJB》笔记(点击查看)

《Expert One on One J2EE Design And Development》笔记(本文)


博主:注意:该书出版时间是2004年。仅需阅读自己关注的部分。


第一章

讨论J2EE的架构,分布式架构下是否必须使用EJB组件。大意是:J2EE是个伟大的平台和技术标准,但是官方却误导了大家。官方(当年,2002年)推荐的书籍和实践是不对的,应该是问题驱动而不是用J2EE驱动开发,致使很多人为了用J2EE而用J2EE,而不是根据项目的实际情况选择合适的技术。

首先,官方推荐的“J2EE开发模式”扭曲了我们熟悉的GoF中的设计模式。其次,J2EE的EJB组件并非是开发分布应用必需的技术,还可以使用SOAP中的WebService技术。

全都是陈年旧事儿,大致看看即可。

1. 三层结构(P27)

作者提到的三层结构与我的认识不同。

1. Enterprise Information System(EIS) Tier

有时也叫 Integration Tier

包括:DBMS,legacy mainframe applications。The EIS tier is outside the control of the J2EE server.

2. Middle Tier

This tier contains the application's business objects, and mediates access to EIS tier resources.

3. User Interface(UI) Tier

In web applications, the UI tier consists of servlets, helper classes used by servlets, and view components such as JSP pages.

 

可以看到,作者认为,EIS层是中间层之外的,不受J2EE控制的外部事物。而UI层则包括 JSP/Servlet,中间层包括业务逻辑和与EIS层交互必不可少的中间件。

 

2.  Non-distributed Architectures(P28)

Web Application with Business Component Interfaces

博主:这莫非就是 service/serviceImple 两层结构的由来?

 

3. MVC(P37)

Model, view, and controller objects map onto J2EE components as follows:
❑ A model is a JavaBean that exposes data. A model object should not know how to retrieve
data from business objects, but instead, should expose bean properties that enable its state to
be initialized by a controller.
Thus, the rendering of a view will never fail because of reasons
such as failure to retrieve data. This greatly simplifies error handling in the presentation tier (it
is also possible to use XML documents as models).
❑ A view is a component that is used to display the data in a model. A view should never
perform business logic or obtain data other than that which is made available to it in a model.
View components in J2EE systems are most often JSP pages. Each view in this architectural
pattern is analogous to one implementation of a simple contract ("display a certain set of
objects"). Thus, each view can be replaced with another view that displays the same model
differently, without altering the application's behavior.
❑ A controller is a Java class that handles incoming requests, interacts with business objects,
builds models, and forwards each request to the appropriate view. A request controller does
not implement business logic (this would impinge on the responsibilities of the middle tier).

 

4. 可移植性(P39)

接口级别(设计级别)的可移植,源代码级别的可移植。作者认可接口级别的可移植,源代码级别的移植代价很高。

We must distinguish between implementation portability ("this code runs without
change on any application server") and design portability ("this application will work
correctly and efficiently on any application server, if a small number of clearly
identified interfaces are re-implemented"). Total implementation portability can be
achieved in J2EE, but may not be a realistic or even a very worthwhile outcome.
Design portability is achievable, and delivers most of the business value of portability.
Even when portability is not a business requirement, design portability should flow
from good OO design practice

 

第二章

可直接略过,信息有些过时。主要讲选择J2EE中间件,组建团队,选择开发工具,识别和防范风险。

 

第三章

测试J2EE应用。

5. 常见测试

很贴心的把常见的测试种类都解释了一遍。

Definitions
o Unit tests
Unit tests test a single unit of functionality. In Java, this is often a single class. Unit tests are the
finest level of granularity in testing, and should test that each method in a class satisfies its
documented contract.


o Test coverage
This refers to the proportion of application code that is tested (usually, by unit tests). For example,
we might aim to check that every line of code is executed by at least one test, or that every logical
branch in the code is tested.


o Black-box testing
This considers only the public interfaces of classes under test. It is not based on knowledge of
implementation details.


o White-box testing
Testing that is aware of the internals of classes under test. In a Java context, white-box testing
considers private and protected data and methods. It doesn't merely test whether the class does
what is required of it; it also tests how it does it. I don't advocate white-box testing (more of this
later). White-box testing is sometimes called "glass-box testing".


o Regression tests
These establish that, following changes or additions, code still does what it did before. Given
adequate coverage, unit tests can serve as regression tests.


o Boundary-value tests
These test unusual or extreme situations that code under test should be able to handle (for example,
unexpected null arguments to a method).


o Acceptance tests (sometimes called Functional tests)
These are tests from a customer's viewpoint. An acceptance test is concerned with how the
application meets business requirements. While unit tests test how each part of an application does
its job, acceptance tests ignore the implementation details and test the ultimate functionality,
using concepts that make sense to a user (or customer, in XP terminology).


o Load tests
These test an application's behavior as load increases (for example, to simulate a greater
population of users). The aim of load testing is to prove that the application can cope with the load
it is expected to encounter in production and to establish the maximum load it can support. Load
tests will often be run over long periods of time, to test stability. Load testing may uncover
concurrency issues. Throughput targets are an important part of an application's non-functional
requirements and should be defined as part of business requirements.

o Stress tests
These go beyond load testing to increase load on the application beyond the projected limits. The aim
is not to simulate expected load, but to cause the application to fail or exhibit unacceptable response
times
, thus demonstrating its weak links from the point of view of throughput and stability. This can
suggest improvements in design or code and establish whether overloading the application can lead to
erroneous behavior such as loss of data or crashing.

都是常见的名词,注意最后2个测试:负载测试和压力测试的区别。

 

本文暂停,已经转看这本中文书了:《Expert One on One J2EE Design And Development without EJB》笔记(点击查看)

 What is this book about? The results of using J2EE in practice are often disappointing: applications are often slow, unduly complex, and take too long to develop. Rod Johnson believes that the problem lies not in J2EE itself, but in that it is often used badly. Many J2EE publications advocate approaches that, while fine in theory, often fail in reality, or deliver no real business value. "Expert One-on-One: J2EE Design and Development" aims to demystify J2EE development. Using a practical focus, it shows how to use J2EE technologies to reduce, rather than increase, complexity. Rod draws on his experience of designing successful high-volume J2EE applications and salvaging failing projects, as well as intimate knowledge of the J2EE specifications, to offer a real-world, how-to guide on how you too can make J2EE work in practice. It will help you to solve common problems with J2EE and avoid the expensive mistakes often made in J2EE projects. It will guide you through the complexity of the J2EE services and APIs to enable you to build the simplest possible solution, on time and on budget. Rod takes a practical, pragmatic approach, questioning J2EE orthodoxy where it has failed to deliver results in practice and instead suggesting effective, proven approaches. What does this book cover? In this book, you will learn When to use a distributed architecture When and how to use EJB How to develop an efficient data access strategy How to design a clean and maintainable web interface How to design J2EE applications for performance Who is this book for? This book would be of value to most enterprise developers. Although some of the discussion (for example, on performance and scalability) would be most relevant to architects and lead developers, the practical focus would make it useful to anyone with some familiarity with J2EE. Because of the complete design-deployment coverage, a less advanced developer could work through the book along with a more introductory text, and successfully build and understand the sample application. This comprehensive coverage would also be useful to developers in smaller organisations, who might be called upon to fill several normally distinct roles. What is special about this book? Wondering what differentiates this book from others like it in the market? Take a look: It does not just discuss technology, but stress its practical application. The book is driven from the need to solve common tasks, rather than by the elements of J2EE. It discuss risks in J2EE development It takes the reader through the entire design, development and build process of a non-trivial application. This wouldn't be compressed into one or two chapters, like the Java Pet Store, but would be a realistic example comparable to the complexity of applications readers would need to build. At each point in the design, alternative choices would be discussed. This would be important both where there's a real problem with the obvious alternative, and where the obvious alternatives are perhaps equally valid. It emphasizes the use of OO design and design patterns in J2EE, without becoming a theoretical book ,高清文档 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qilei2010

送我一张彩票中了平分

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值