Hello everyone, my name is Arkady, I am a student at the Higher School of Economics, and in this article we will talk about PeerReview task # 6 NotePad ++, namely about architectures that are suitable for this task and some patterns.
The task
In this task, the main task is to implement a GUI application. I propose not to deviate far from the topic and immediately look at what architecture is and how they can help us in this case.
The information from this post does not cover all existing architectures and patterns, but is quite sufficient for the implementation of task # 6
Application architectures
By architecture, we mean an architectural design pattern that covers the entire application or some part of it. This part is often referred to as a module. The application is built from these modules. Modules in this case are not C # modules, but architectural modules. This can be, for example, a single application screen or several related screens.
The topic of architectures is controversial. First, every developer has a different idea of what a good architecture should be. Secondly, even if you take some specific architecture, you can find several different implementations. And the third reason is that there are no perfect architectures. Each of them has advantages and disadvantages. Therefore, when discussing architectural approaches, there is always something to scold any of the solutions for.
I will tell you only about three architectural solutions that I consider the most suitable for this project, moreover, they have a fairly low defect of entry
1. Apple MVC
, – MVC. , . Apple MVC, Classic MVC
, – . . .
M – Model. , , . UI (user interface). , . ,
V – View. – . , . – , Controller. #- Form . .
C – Controller. . , View, , . .. , , .
. , . , TabBarController . .
MVC – . ( ). MVC Apple. ViewController View. - . , .
ViewController . , View. . «Massive View Controller»
, – . - , ViewController, .
2. MVP
MVC MVP. ViewController – , - , View, Presenter.
MVC Apple. , , , ViewController Presenter.
, , MVC, . Presenter , , . , , .
3. MVVM
MVVM MVP. , ViewModel. . , . MVP, . , data binding ( ). , . .. , ViewModel, .
MVVM MVP . ,
, . MVVM , .. View ViewModel. , .
. MVVM, .
. – .
– . , . , .
, . :
(Singleton)
Target-Action
(Observer)
(Command)
, .. , , .
Swift, .. - , - **** C#, **** *** *** ***** *** **** , . .
1. (Singleton)
- . , , .
, - .
. , .
– GPS-. , . GPS, . , , . -. LocationManager, GPS-.
class NetworkManager {
private(set) static var sharedInstance: NetworkManager = {
let manager = NetworkManager()
// additional setup code
return manager
}()
private init () {
}
func sendRequest() {
print("sending request")
}
}
// main program
let networkManager = NetworkManager.sharedInstance
networkManager.sendRequest() // sending request
2. Target-Action
, , Target-Action. , .. . , , . : - . , , Target-Action. Target-Action – , , , , . : , (action), , (target). , .
, – , , . . - .
WindowsForm ,
3.
«» . , , – ( , ) . , «» - . «» .
, - .
– , , - . «—». , «» (publisher) (subscribers). .
interface IObservable {
void AddObserver(IObserver o);
void RemoveObserver(IObserver o);
void NotifyObservers();
}
class ConcreteObservable : IObservable {
private List<IObserver> observers;
public ConcreteObservable(){
observers = new List<IObserver>();
}
public void AddObserver(IObserver o){
observers.Add(o);
}
public void RemoveObserver(IObserver o){
observers.Remove(o);
}
public void NotifyObservers(){
foreach (IObserver observer in observers)
observer.Update();
}
}
interface IObserver {
void Update();
}
class ConcreteObserver :IObserver {
public void Update() {
// Some Action
}
}
( c#, .. ):
IObservable: . :
AddObserver()
( ()),RemoveObserver()
( )NotifyObservers()
( )
ConcreteObservable: IObservable. .
IObserver: , .
Update()
, .
ConcreteObserver: IObserver
, Update()
. . .
. - .
— , , , , , ......
.. WindowsForms , ,
https://refactoring.guru/ru/design-patterns/command
:
https://refactoring.guru/ru/design-patterns/
, , , .
. -, .
, !