-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Principles of project architecture design
- All service interfaces must implement the
IDisposableinterface - The call to
Disposemethods of services must explicitly occur inApp.xaml.cs - Service errors should be handled in the services themselves
General remarks
- The use of
varis 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
Delegateregion - 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
Raiseadded at the beginning. From theEventHandlerprefix from the delegate name, onlyEventshould remain. For an example, see the section "IExampleInterface" - Events must be located in the
Eventsregion and follow immediately after the interface is declared - Specifying the scope of any interface entity is mandatory
- Must be located in
- Events in class
- They must be located in the
Eventsregion 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:
Such methods should be located in thepublic class ExampleClass : IExampleInterface { public event ExampleDelegateEventHandler RaiseExampleDelegateEvent; .... protected virtual void OnRaiseExampleDelegateEvent() { ExampleDelegateEventHandler raiseEvent = RaiseExampleDelegateEvent; raiseEvent.Invoke(this); } }
OnRaise eventsregion at the bottom of the class.- Event handler methods must be located in the
Events methodregion below the private methods of the class
- They must be located in the
- Subscribing and unsubscribing from events
- Subscribing and unsubscribing from events must occur in the private
SubscribeandUnsubscribemethods and be located in theSubscriptionregion - The
Subscriptionregion must be below the private methods of the class
- Subscribing and unsubscribing from events must occur in the private
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
Constregion 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:
All methods must be located in the
OpenWindowDelegateCommand = new(OpenWindow, OpenWindowCanExecute)Delegatecommand methodsregion
Services
- All services must be private class variables, assigned a value in constructor, i.e. readonly
- All services variables must be located in the
Servicesregion, which should be below regions with public fields or methods
Public and private fields
- All public fields must be located in the
Public fieldsregion, 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 fieldsregion - 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 methodsandPrivate methodsregions
vertigra
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation