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 team members accomplish their goals, the manager will give them the corresponding bonus. Companies need the program to 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.
Easy to use System Utilities
Overall bandwidth of Thunder Edge Broadcasting below to see new resolution
Flash5 ActionScript Advanced Programming Guide (6)
what are the best mini netbooks
Best Converters And Optimizers
Make a IPhunter
Review Search Or Lookup Tools
VOB to Zune
Adobe is Very fragile, then Photoshop it?
Top Registry Tools
Focus DreamWeaver MX 2004
VOB To MPG
The "job" into a "job Search" strategy
Knowledge of equality before the