Skip to content

Code of Conduct Template #17

@vertigra

Description

@vertigra

Principles of project architecture design

  • All service interfaces must implement the IDisposable interface
  • The call to Dispose methods of services must explicitly occur in App.xaml.cs
  • Service errors should be handled in the services themselves

General remarks

  • The use of var is allowed, but should not be preferred
  • Writing style: camelCase with nuances :)
  • The use of regions in the interfaces is not necessary, but it is welcome

Delegate and event

  • In interfaces:
    • Must be located in Delegate region
    • They should not be declared inside the interface, only in the same namespace with the interface. Example:
    namespace ExampleNamespace
    {
        public delegate void ExampleDelegateEventHandler(object sender);
    
        public interface IExampleInterface
        {
            public event ExampleDelegate RaiseExampleDelegateEvent ;
        }
    }
    • the delegate must always have a sender parameter containing a reference to the object that triggered the event
    • The name of the delegate must end with the prefix EventHandler
    • The name of the event associated with the delegate must repeat the name of the delegate with the prefix Raise added at the beginning. From the EventHandler prefix from the delegate name, only Event should remain. For an example, see the section "IExampleInterface"
    • Events must be located in the Events region and follow immediately after the interface is declared
    • Specifying the scope of any interface entity is mandatory
  • Events in class
    • They must be located in the Events region and located above the constructor and the closed entities of the class
    • Before calling the event, it should be copied and then called from the copy. The event call follows from methods marked as protected and virtual. The naming order of such methods is: the name of the event with the addition of the prefix On.
      Example:
    public class ExampleClass : IExampleInterface
    {
        public event ExampleDelegateEventHandler RaiseExampleDelegateEvent;
        ....
        protected virtual void OnRaiseExampleDelegateEvent()
        { 
            ExampleDelegateEventHandler raiseEvent = RaiseExampleDelegateEvent;
            raiseEvent.Invoke(this);
        }
    }
    Such methods should be located in the OnRaise events region at the bottom of the class.
    • Event handler methods must be located in the Events method region below the private methods of the class
  • Subscribing and unsubscribing from events
    • Subscribing and unsubscribing from events must occur in the private Subscribe and Unsubscribe methods and be located in the Subscription region
    • The Subscription region must be below the private methods of the class

Constructors

  • The constructors of the class must be located in the region ~
  • The order of assigning values to variables and fields of a class:
    1. private service variables assigning
    2. public delegate command new instance assigning
    3. event handler assigning
    

Constans

  • All constant must be located in the Const region and it is located above the public constructor of the class, below the regions with public entities of the class
  • Constant names must begin with the prefix c
  • An example of the designation of string values of private class fields related to a public property should be assigned using constants:
    private const string cAppLogStatusBar = "App log";
    private string appLogStatusBar = cAppLogStatusBar;
    ...

Delegate Command

  • The DelegateCommand declaration must be above the class constructor and located in region DelegateCommands
  • DelegateCommand must be public to read only fields, with implementation in the class constructor
  • The DelegateCommand name must contain the DelegateCommand at the end. For example: OpenWindowDelegateCommand
  • All new DelegateCommand instances must implement two methods: the one executed when the command is invoked and whether the command can be executed. The name of the methods is based on the following principle:
    OpenWindowDelegateCommand = new(OpenWindow, OpenWindowCanExecute) 
    
    All methods must be located in the Delegatecommand methods region

Services

  • All services must be private class variables, assigned a value in constructor, i.e. readonly
  • All services variables must be located in the Services region, which should be below regions with public fields or methods

Public and private fields

  • All public fields must be located in the Public fields region, which should be located immediately after the public constructor
  • The private fields of the class must be located directly after the area of the open fields of the class or the constructor of the class, if there are no open fields in the Private fields region
  • It is allowed to place a private class field related to a public property above this property. The name of such a field should repeat the name of the public property, with a small letter. Example:
    private bool progressRingStart;
    public bool ProgressRingStart
    {
        get { return progressRingStart; }
        set { progressRingStart = value; }
    }
  • String values of class private fields related to a public property must be assigned using constants. For an example of the name assignment, see Constant

Public and private methods

  • Must be located in the Public methods and Private methods regions

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions