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, 5247👍, 0💬
Popular Posts:
Describe different elements in Static Chart diagrams ? Package: - It logically groups element of a U...
How Can we change priority & what levels of priority are provided by Dot Net? Thread Priority ca...
1. What is normalization. 2. Difference between procedure and functions. 3. Oracle 9i Vs 10g. 4. how...
What is the FP per day in your current company?
Can an anonymous class be declared as implementing an interface and extending a class? An anonymous ...