473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

AOP

Hi all

You know what I'd like to see? I'd like to see compiler support for AOP.
Take PostSharp as an example, it hooks into the build process and modifies
your binary output
[Log]
public void DoSomething()
{
}

adds logging to the DoSomething method. It is also possible to add
interface support

[Bindable]
public class Person
{
}

adds INotifyPropertyChanged etc.
I would love to see AOP support in the compiler because when adding
interface support you cannot do something like this
someObject.Method_Expecting_IContact(person);

because IContact is added to Person after compilation, so this would fail.
With proper IDE support I'd be able to do stuff like this

[BusinessObject]
public class Person
{
public string Name { get; set; }
}

and then also be able to write code like this

Person p = new Person();
string name = (string)
p.GetPropByIndex(Person.PropertyIndices.Name);

It's not the best example in the world, but the point is that code-insight
could complete code as if I had written it, and I'd be able to write code
that assumed I had manually written it out rather than merely using an
attribute etc. I think this would be great. Not having compile time
support for AOP decorated stuff is one of the weak points of AOP in my
opinion, it's not a spoiler or anything but it certainly would be great if
it were there!

Pete

Aug 11 '08 #1
3 1417
Obviously I am in a minority here.

Aug 12 '08 #2
is dangerous in that it makes a fundamental change to the API.
Adding supprt for interfaces (such as notification) I can probably
forgive if it uses explicit implementation
Of course, even this would break an implicit cast... even more reason
(perhaps) to not support it at compile time.

Marc
Aug 12 '08 #3
just... why? what is wrong with string name = p.Name?

Nothing at all. My example was fictitious. My post was about development
time support for AOP. As another example look at this...
public interface ISomeInterface
{
........
}
[SomeInterface]
public class Person
{
}
the SomeInterfaceAttribute could not only declare ISomeInterface against the
Person class but also add a common implementation too. Then when I have a
method elsewhere expecting ISomeInterface I can do this
Person person1 = new Person();
SomeObject.DoSomething(person1);
At the moment VS would tell me that I cannot cast Person to ISomeInterface,
this is because I have not implemented it during development and it is woven
in by PostSharp afterwards. I am saying it would be nice if we could add
functionality to classes in such a way *and* to be able to see code-insight
for those added features and also have the compiler recognise them, all as
if I had written them in manually.

At the moment I can implement common behaviour using aggregation.....

public interface ISomeInterface
{
void DoSomething();
}

public class SomeInterfaceImpl : ISomeInterface
{
void ISomeInterface.DoSomething()
{
}
}

public class Person : ISomeInterface
{
private SomeInterfaceImpl SomeInterfaceImplementor =
new SomeInterfaceImpl();

void ISomeInterface.DoSomething()
{
SomeInterfaceImplementor.DoSomething();
}
}

but this is a lot more code. But don't just think of it for saving writing,
think of how useful IDE + Compiler support for AOP would be. I think it
would be great, especially for frameworks. Take EntityFramework as an
example
http://www.sitechno.com/Blog/Introdu...tationV01.aspx

Pete

Pete

Aug 12 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.