Click here to Skip to main content
15,914,070 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: do you use extension methods intensively in your projects? Pin
#realJSOP14-Oct-16 20:45
professional#realJSOP14-Oct-16 20:45 
GeneralRe: do you use extension methods intensively in your projects? Pin
OriginalGriff14-Oct-16 21:32
mveOriginalGriff14-Oct-16 21:32 
GeneralRe: do you use extension methods intensively in your projects? Pin
Sander Rossel15-Oct-16 0:04
professionalSander Rossel15-Oct-16 0:04 
GeneralRe: do you use extension methods intensively in your projects? Pin
BillWoodruff15-Oct-16 3:52
professionalBillWoodruff15-Oct-16 3:52 
GeneralRe: do you use extension methods intensively in your projects? Pin
Sander Rossel15-Oct-16 4:11
professionalSander Rossel15-Oct-16 4:11 
GeneralRe: do you use extension methods intensively in your projects? Pin
Southmountain15-Oct-16 8:33
Southmountain15-Oct-16 8:33 
GeneralRe: do you use extension methods intensively in your projects? Pin
Fabio Franco17-Oct-16 0:15
professionalFabio Franco17-Oct-16 0:15 
GeneralRe: do you use extension methods intensively in your projects? Pin
Sander Rossel17-Oct-16 1:15
professionalSander Rossel17-Oct-16 1:15 
I wholeheartedly disagree Big Grin | :-D

Extension methods are nothing more than static helper methods that are treated as instance methods by the editor (and the compiler?).

I don't think there is a principle against creating static helper methods and it's certainly not creating spaghetti, especially since the methods read as instance methods (editor trick or not).

An abstract class is heavy weaponry, every implementor must now inherit the abstract class and since you can only inherit once this puts a serious limitation on implementors.
If you can't inherit you don't get the functionality. You could create a wrapper, but that's just a lot of boilerplate code.
Besides, inheritance is added complexity/spaghetti too!
C#
public interface ISomething
{
    IEnumerable<object> Stuff { get; }
}

public static class SomethingExtensions
{
    public static bool HasStuff(this ISomething something)
    {
        return something.Stuff.Any();
    }
}
How is this not awesome? Every implementor now gets HasStuff for free without the need for inheritance!

You agree that extension methods are clean for LINQ and when dealing with third party code, but for your own code it's suddenly spaghetti? Sounds like double standards to me Wink | ;)
Read my (free) ebook Object-Oriented Programming in C# Succinctly.
Visit my blog at Sander's bits - Writing the code you need.
Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability.
— Edsger W. Dijkstra
Regards,
Sander


modified 18-Oct-16 3:38am.

GeneralRe: do you use extension methods intensively in your projects? Pin
Wendelius14-Oct-16 23:10
mentorWendelius14-Oct-16 23:10 
GeneralRe: do you use extension methods intensively in your projects? Pin
#realJSOP14-Oct-16 23:13
professional#realJSOP14-Oct-16 23:13 
GeneralRe: do you use extension methods intensively in your projects? Pin
Wendelius14-Oct-16 23:18
mentorWendelius14-Oct-16 23:18 
GeneralRe: do you use extension methods intensively in your projects? Pin
Duncan Edwards Jones14-Oct-16 23:15
professionalDuncan Edwards Jones14-Oct-16 23:15 
GeneralRe: do you use extension methods intensively in your projects? Pin
#realJSOP14-Oct-16 23:57
professional#realJSOP14-Oct-16 23:57 
GeneralRe: do you use extension methods intensively in your projects? Pin
Southmountain15-Oct-16 8:31
Southmountain15-Oct-16 8:31 
GeneralRe: do you use extension methods intensively in your projects? Pin
Sander Rossel15-Oct-16 0:06
professionalSander Rossel15-Oct-16 0:06 
GeneralRe: do you use extension methods intensively in your projects? Pin
harold aptroot15-Oct-16 1:18
harold aptroot15-Oct-16 1:18 
GeneralRe: do you use extension methods intensively in your projects? Pin
Cameron Oltmann17-Oct-16 4:01
Cameron Oltmann17-Oct-16 4:01 
GeneralRe: do you use extension methods intensively in your projects? Pin
harold aptroot17-Oct-16 5:57
harold aptroot17-Oct-16 5:57 
GeneralRe: do you use extension methods intensively in your projects? Pin
Cameron Oltmann17-Oct-16 13:47
Cameron Oltmann17-Oct-16 13:47 
GeneralRe: do you use extension methods intensively in your projects? Pin
Marc Clifton15-Oct-16 3:08
mvaMarc Clifton15-Oct-16 3:08 
GeneralRe: do you use extension methods intensively in your projects? Pin
BillWoodruff15-Oct-16 3:16
professionalBillWoodruff15-Oct-16 3:16 
GeneralRe: do you use extension methods intensively in your projects? Pin
Southmountain15-Oct-16 8:30
Southmountain15-Oct-16 8:30 
GeneralRe: do you use extension methods intensively in your projects? Pin
Mark_Wallace15-Oct-16 21:48
Mark_Wallace15-Oct-16 21:48 
GeneralRe: do you use extension methods intensively in your projects? Pin
pt140115-Oct-16 3:15
pt140115-Oct-16 3:15 
GeneralRe: do you use extension methods intensively in your projects? Pin
  Forogar  16-Oct-16 3:26
professional  Forogar  16-Oct-16 3:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.