kamagra how much to take

Protected Constructors For Abstract Classes

One code modification Resharper 4.0 will suggest is that if a public constructor is located in an abstract class, it should be adjusted to use the protected access modifier if currently public:

So, from this:

  1. public abstract class AbstractClass
  2. {
  3. public AbstractClass()
  4. {
  5. }
  6. }

To this:

  1. public abstract class AbstractClass
  2. {
  3. protected AbstractClass()
  4. {
  5. }
  6. }

So, why is this a good code edit?

Well, having a public constructor on an abstract class in the terms of code architecture is irrational since the abstract class can’t be instantiated directly; it is instead created by instantiating the deriving type. Thus only derived types have access to the abstract class constructor. Protected more adequately describes a germane access modifier for the constructor as well as ensuring requisite inheritor types have constructor access.

More noticeably, appropriate access modifier decoration will in turn not populate Intellisence with a bunch of useless crap :)



  1. James Fortner says:

    Did not know about this, great tip
    (even though it’s categorized under SharePoint Development. You need a C# category or something :) )!

  2. Kirk Kerr says:

    Indeed, I did have some abstract classes that were doing this. Fixing em up right now!

  3. James Tyson says:

    I just don’t see why this is important. What are the relevant arguments for an implementation across a whole product for this…improvement.

  4. Adam Buenz says:


    What? The justifications you are asking about are located in the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>