First of all you have to be clear that, AOP and OOP are two different point of view of cognition, not to say that just should not have AOP OOP.AOP concern is that the traditional OOP can not elegant solution. (Programmers often a perfectionist, and when to solve a problem is not elegant, it means not perfect.) following a simple example will illustrate how different they are in the end.
Using OOP for many years as a people, when I heard AOP can solve some OOP has not been able to solve the problem gracefully, I think we should tackling the relay them. Comparison of the two technologies give us the most practical applications provide insights. here I designed an example: a OOP applications, suitable for use in certain aspects of AOP.
This paper presents a simple example. Outset describes the problem domain, and then were given OOP and AOP solutions. Which uses JDK5.0, JUnit, and AspectWerkz. Finally, we illustrate how to write code. After reading this article, I hope you know what AOP in the end, what kind of problems to solve. (because of the examples in the back of AOP used Java5.0 endorsement (Annotation), the reader first understand. - Translator Note).
Problem domain description
A software company hire a programmer, a business unit assigned to him and asked him to keep the manager. When the team members accomplish their goals, the manager will give them the corresponding bonus. Companies need the program must be able to add a new employees and current employees to increase the prize money. For convenience, we use the CSV file to store data.
Figure 1 Solution Model
Category Manager (Manager) inherited from the class Employee, contains an additional attribute, Managing Project. A sector may contain a lot of employees. Constitute the company's various departments. Without consideration of the company such a class, because it is outside the problem domain.
The following diagram describes the solution design.
Figure 2, the interaction between objects (add a new employee, assigned to his department and manager)
For simple, this article concerns only the necessary details. Of course you can get what you want in-depth code and other information.
[Link] http://www.devx.com/assets/sourcecode/13172.zip [/ link]
EmployeeServiceTestCase, a JUnit test case to simulate an end user, create new employee records, assigned departments and managers. It gets all of the available data on departments and managers and shows the graphic interface. BusinessUnit domain object to instantiate and Manager, access to records will be passed to the factory class. After passing through a reference to EmployeeService to create an Employee object. EmployeeFactory use this service to create an object class, and pass this object to be persistent EmployeeRepository operation.
jsp PRECOMPILATION issues
Zhou Hongyi 1 billion investment is not money, is lonely
Easy to USE File Compression
DV TO AVI
Premier Kids Education
Hong Kong dollar 76 million a formal decision to auction 3G Licenses
Super woman thoroughly exposed the tail
MPEG to MOV
set in the excel cell Diagonal
Great FRIENDS with the compatriots in Taiwan noted connected with the download tool
Fireworks produced way back in effect
Symantec said the new storm worm detected
YUV to AVI
Genuine Guide Help Daoxiang Frog Rapid Expansion!