Should I separate properties and methods in partial classes?

I am writing fundamental classes for an application and want to build them correctly for long-term support. To this end, I will explore which design patterns to implement, use interfaces, abstract classes, and separate persistence from activity. My head swims with patterns, paradigms and principles.

I have a class Productfor which I created an interface IProduct. I believe that I need to make an Productabstract class, because any instance of it should be one of half a dozen values ​​for the property Category. So my first question is: the next way to do this?

abstract class Product : IProduct
{
    // Fields
    // Properties
    // Methods
}

interface IProduct
{
    // Properties
}

public class Model : IProduct
{
    public Model()
    {
        Category = "Model";
    }

    // Model-specific fields
    // Model-specific properties
    // Model-specific methods
}

, , , , , ( ). , ?

abstract class Product : IProduct
{
    // Fields
    // Properties
    // Methods
}

interface IProduct
{
    // Properties
}

public partial class Model : IProduct
{
    public Model()
    {
        Category = "Model";
    }

    // Model-specific fields
    // Model-specific properties
}

public partial class Model : IProduct
{
    // Model-specific methods
}

, , , , , , -.

, - , Product , , , ?

abstract class Product : IProduct
{
    // Fields
    // Properties
}
abstract class Product : IProduct
{
    // Methods
}
+4
2

, partial, - , . , , Visual Studio (, Windows Forms), . . , .

partial, . #region .

+5

. , - "" (.. , ..). .

#region . , (------…---), .

:

public class SomeClass : ParentClass, ISomeInterface
{
    #region ------ Large feature 1 ----------------------------// any non-private members related to 'Large feature 1' go here
    #endregion

    #region ------ Large feature 2 ----------------------------// any non-private members related to 'Large feature 2' go here
    #endregion

    #region ------ Implementation of ISomeInterface -----------// ISomeInterface implementation goes here, comments are *not* repeated
    #endregion

    #region ------ ParentClass overrides ----------------------// parent class members' overrides go here, comments are *not* repeated
    #endregion

    #region ------ Internals ----------------------------------// any private members, i.e. the actual implementation
    #endregion
}

, . , . , .

, ( , ). :

public int SomeProperty
{
    get { … return someProperty; }
    set { someProperty = value; … }
}
private int someProperty;
+1

All Articles