Created
December 22, 2017 06:01
-
-
Save yuu341/f4eb4f07dd3044e7c5dfcffd5e679cfe to your computer and use it in GitHub Desktop.
集約サンプル(継承より強力)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using WindowSample.Sample1; | |
namespace WindowSample.Sample3 | |
{ | |
/// <summary> | |
/// これをやってはいけない | |
/// </summary> | |
public class PagerWindowBase : WindowBase | |
{ | |
public void First() | |
{ | |
} | |
public void Prev() | |
{ | |
} | |
public void Next() | |
{ | |
} | |
public void Last() | |
{ | |
} | |
} | |
/// <summary> | |
/// こっちのほうが強力 | |
/// </summary> | |
public class HogehogeWindow : WindowBase | |
{ | |
public IPager Pager { get; } | |
public HogehogeWindow() | |
{ | |
Pager = new Pager(); | |
} | |
} | |
/// <summary> | |
/// ページャはページャとして独立させること | |
/// </summary> | |
public class Pager : IPager | |
{ | |
public void First() | |
{ | |
} | |
public void Last() | |
{ | |
} | |
public void Next() | |
{ | |
} | |
public void Prev() | |
{ | |
} | |
} | |
/// <summary> | |
/// ついでに言うならインターフェイスにすること | |
/// 設計段階で考案するのがベスト | |
/// </summary> | |
public interface IPager | |
{ | |
void First(); | |
void Prev(); | |
void Next(); | |
void Last(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment