Aspect oriented programming, DOT NET Programming

Assignment Help:

What is aspect oriented programming?

The Aspect-oriented software development is the latest technology for the separation of the concerns (SOC) in the software development. These techniques of AOSD make it possible to modularize crosscutting aspects of the system.

When we look at the times of COBOL where we used to break the modules in small functionalities and use reusability to its maximum.

Then came the time interval when we talked in terms of Objects where things were clearer as software was modeled in the terms of real life examples. It worked fine and till date is the most accepted way of implementing and organizing the project. So the question is why AOP?

The Aspect oriented programming does not oppose the OOP's but rather supports it and make it more maintainable. So to remove the logic from head the AOP is the replacement of the OOP.

When we describe in terms of objects it is an entity which maps to the real world domain. The Object has attributes which represent the state of the object and also define its behavior. By the rule of object oriented programming object must  be stand alone and communicate with each other objects using messages or defined interface.

One object must not communicate with the other object directly rather communicate through the defined interfaces. Each object satisfies some "Concern" in relation to the system.

There are primarily 2 types of concern from an object perspective:-

1) The Main /Core concerns which it must satisfy and is his work.

2) The System concerns that are not related to the business functionalities but software related concerns e.g. Error handling, audit trail, Security etc.

2229_customer and audit trail relationship.png

Figure :-Customer and Audit trail relationships

The class diagram above shows the relationship between the  two classes "ClsCustomer" and "ClsAuditTrail". The "ClsCustomer" class does inserting of the new customers into the database and the "ClsAuditTrail" does the auditing of what is modified in the customer class.

 There are two main concerns in this project :-

1)The Customer code should not more  than 10 lengths (Business level concern) greater

2)All the customer data which is updated must  be audited. (System level concern)

Below are s the class codes. If you view the ClsCustomer implementation in the update method I have called the Audit trail implementation. If you really look from the object oriented point of view we are doing something in the customer class which is supposed to be not his implementation: - Audit Trail logging. Thus we have also split  down the rule of  the encapsulation. In brief the class not only handles his work but also some another work which is not his concern.

When one or many than one  concerns span across module it is known  as cross cutting. For e.g. in the  audit trail  we will probably require  to audit trail for customer as well as the supplier. Hence the  Audit trail can span across other objects also that is known  as cross cutting.

Both the classes actually implemented as per class diagram is shown below . If you see the "Update" method of the customer class, its doing both of the concerns that is checking for the customer code length and also maintaining the audit trail by 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

In brief the customer class is doing much activity. There is a lot of tangling of code. So how do we get over this problem...? Simple, split the System level concern (Audit Trail) from the core level concern (Customer code check). This is achieved at this moment in the .NET using the attribute programming.

Here are some of the changes 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

_ 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

Targets.All)> _ 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() End Sub

Public Sub Update()

' do the logging activity here

End  sub

End class


Related Discussions:- Aspect oriented programming

Core functionalities in xml .net framework, What are the core functionaliti...

What are the core functionalities in XML .NET framework? The XML API for the .NET Framework includes the following set of functionalities: XML readers With XML readers

Define the tooltip control, Define the ToolTip control. How can you associa...

Define the ToolTip control. How can you associate it with other controls? The ToolTip control produces a small pop-up window with explanatory text for an element it is displaye

Develop a project using microsoft active directory, Net project Project ...

Net project Project Description: We want to make .net project Microsoft Active Directory, PMS Lync 2010 - 2013 databases creating a license key for their SW generati

Multi-tasking, What is Multi-tasking? It is a feature of the modern ope...

What is Multi-tasking? It is a feature of the modern operating system with which we can run multiple programs at the same time for example Word, Excel etc.

Mention the execution process for managed code, Mention the execution proce...

Mention the execution process for managed code. A piece of managed code is executed as follows:     Choosing a language compiler     Compiling the code to MSIL     Com

I need auto trading software for nse, Project Description: I am seeking ...

Project Description: I am seeking some automated trading software for the given strategy, I am using Omnesys Nest trader Step 1: Buy one share at current market price (ex:

Custom mql4 code - fxdreema block, Custom Mql4 Code/Fxdreema block Proje...

Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: check pro

Describe the three levels of data abstraction, Describe the three levels of...

Describe the three levels of data abstraction? The are three levels of abstraction: Physical level: The lowest level of abstraction explains how data are stored.  Logical

Difference between asp and asp.net, The ASP.NET new feature supports are sh...

The ASP.NET new feature supports are shown below :- Better Language Support 1) The New ADO.NET Concepts have been implemented. 2) The ASP.NET supports complete  language

Explain the dataadapter.update, Explain the DataAdapter.Update() and DataSe...

Explain the DataAdapter.Update() and DataSetAcceptChanges() methods. The DataAdapter.Update() method calls any of the DML statements, like UPDATE, INSERT, or DELETE statements,

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd