Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is cross cutting in AOP
What is cross cutting in AOP ?
✍: Guest
When one or many concerns span across module it is called as cross cutting. Example in our audit trail example we will probably need to audit trail for customer as well as supplier. So Audit trail can span across other objects also that is termed as cross cutting. Below are both the classes actually implemented as per class diagram 8.7. If you see the “Update” method of the customer class, its doing both of the concerns that is checking for customer code length and also maintaining the audit trail using the audit trail class.
Public Class ClsCustomer Private pstrCustcode As String Private pstrCustName As String Public Property Code() As String Get Return pstrCustcode End Get Set(ByVal Value As String) pstrCustcode = Value End Set End Property Public Property CustomerName() As String Get Return pstrCustName End Get Set(ByVal Value As String) pstrCustName = Value End Set End Property Public Function Update() As Boolean ‘ first / core concern If pstrCustcode.Length() > 10 Then Throw New Exception("Value can not be greater than 10") End If ' usingthe customer audit trail to do auditing ‘ second concern / system concern Dim pobjClsAuditTrail As New ClsAuditTrail With pobjClsAuditTrail .NewValue = "1001" .OldValue = "1003" .UserName = "shiv" .Update() End With ' then inserting the customer in database End Function End Class Public Class ClsAuditTrail Private pstrUserName As String Private pstrOldValue As String Private pstrNewValue As String Private pdblLogTime As Double Public Property UserName() As String Get Return pstrUserName End Get Set(ByVal Value As String) pstrUserName = Value End Set End Property Public Property OldValue() As String Get Return pstrOldValue End Get Set(ByVal Value As String) pstrOldValue = Value End Set End Property Public Property NewValue() As String Get Return pstrNewValue End Get Set(ByVal Value As String) pstrNewValue = Value End Set End Property Public Property LogTime() As Double Get Return pdblLogTime End Get Set(ByVal Value As Double) pdblLogTime = Value End Set End Property Public Sub Update() ' do the logging activity here End Sub End Class
This is achieved at this moment in .NET using attribute programming. Here is the change to the customer class
Imports System.Reflection Public Class ClsCustomer Private pstrCustcode As String Private pstrCustName As String Public Property Code() As String Get Return pstrCustcode End Get Set(ByVal Value As String) pstrCustcode = Value End Set End Property Public Property CustomerName() As String Get Return pstrCustName End Get Set(ByVal Value As String) pstrCustName = Value End Set End Property <ClsAuditTrail("Shiv", "1001", "1003", 12)> _ Public Function Update() As Boolean If pstrCustcode.Length() > 10 Then Throw New Exception("Value can not be greater than 10") End If ' usingthe customer audit trail to do auditing ' then inserting the customer in database End Function End Class And here is the change to the audit trail class Imports System.Reflection_ Public Class ClsAuditTrail Inherits Attribute Private pstrUserName As String Private pstrOldValue As String Private pstrNewValue As String Private pdblLogTime As Double Public Property UserName() As String Get Return pstrUserName End Get Set(ByVal Value As String) pstrUserName = Value End Set End Property Public Property OldValue() As String Get Return pstrOldValue End Get Set(ByVal Value As String) pstrOldValue = Value End Set End Property Public Property NewValue() As String Get Return pstrNewValue End Get Set(ByVal Value As String) pstrNewValue = Value End Set End Property Public Property LogTime() As Double Get Return pdblLogTime End Get Set(ByVal Value As Double) pdblLogTime = Value End Set End Property Public Sub New(ByVal pstrUserName As String, _ ByVal pstrOldValue As String, _ ByVal pstrnewValue As String, _ ByVal plng As Long) Update()
2007-10-24, 5502👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - How to prevent my .NET DLL to be decompiled? By design .NET embeds rich M...
Describe in detail Basic of SAO architecture of Remoting? For these types of questions interviewer e...
What are the different storage classes in C? C has three types of storage: automatic, static and all...
What is Concern in AOP? gA concern is a particular goal, concept, or area of interesth There are m...
How To Delete a User Account? - Oracle DBA FAQ - Managing Oracle User Accounts, Schema and Privilege...