On overloadz

Right, so it’s been a while since I’ve posted, and since I’ve thought about AI too much in general. The reason being my realisation of the fact that my school project can’t have much to do with AI, or with my personal theories in general. Or well, I don’t know why I haven’t posted, so I dicided to post about sth totally out of context, about one issue i realized in C# earlier today.

The thing has to do with overloads. Now one problem is of course absence of optional paramters in C#, but that aside, the only differnence that is the between overloads, is their return type, arguments, and generic constraints, so why must I rewrite the privacy properties and name of the function to overload??

Why can’t I just write the new arguments, and/or return type and/or the generic constraints? That would save quite a bit of code, just look at this wastage, and imagine if there was a way to skeep the declaration a hole new function, and just write the differing properties for the overload:

public static T[] get<T>() where T : class, INotifyPropertyChanging, INotifyPropertyChanged {..}

public static T get<T>(int id) where T : class, INotifyPropertyChanging, INotifyPropertyChanged {..}

public static T[] get<T>(string property, string value) where T : class, INotifyPropertyChanging, INotifyPropertyChanged{..}

Would be nice if instead I could write sth like:

public static T[] get<T>() where T : class, INotifyPropertyChanging, INotifyPropertyChanged {..}

-||-(string property, string value)-||- {..}

T -||-(int id) -||- {..}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s