-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInterfaceSegregation.cs
47 lines (43 loc) · 1.2 KB
/
InterfaceSegregation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using UnityEngine;
namespace SPACE.ISP
{
public class InterfaceSegregation : MonoBehaviour
{
/// <summary>
/// Helps for initialization.
/// </summary>
private void Awake()
{
Debug.Log("Interface Segregation Principle example started.");
Debug.Log("Please review 'InterfaceSegregation.cs' for more information.");
}
}
/*
* If we consolidate all inputs into one interface, we would violate the principle we are using.
* For example, if we implement this interface in a class where we only need the click method,
* we would still be forced to inherit the drag method.
* Therefore, breaking down these interfaces into 'IMouseClick' and 'IMouseDrag' will allow us to adhere to this principle.
*/
/// <summary>
/// Mouse Input Interface.
/// </summary>
public interface IMouseInput
{
void Click();
void Drag();
}
/// <summary>
/// Mouse Click Interface.
/// </summary>
public interface IMouseClick
{
void Click();
}
/// <summary>
/// Mouse Drag Interface.
/// </summary>
public interface IMouseDrag
{
void Drag();
}
}