summaryrefslogtreecommitdiff
path: root/diagrams/assignment_3/mmd/decorator_pattern.mmd
blob: 5bf05a5f56166ab4536ebdd78abcd5377a669fab (plain) (blame)
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
classDiagram
    class Reader {
        <<abstract>>
        +ReadLine() string*
        +EndOfStream bool
        +Close()
    }
    
    class FileReader {
        -StreamReader _streamReader
        +ReadLine() string*
    }
    
    class ReaderDecorator {
        <<abstract>>
        #Reader _reader
        +ReadLine() string*
    }
    
    class CSVReader {
        +ReadLine() string*
        +ReadCSVLine() string[]*
    }
    
    class EntityReader~T~ {
        <<abstract>>
        #IEntityFactory~T~ _factory
        +ReadEntity(id: int) T*
    }
    
    class MorgReader {
        +ReadEntity(id: int) Morg*
    }
    
    Reader <|-- FileReader : concrete
    Reader <|-- ReaderDecorator : abstract decorator
    ReaderDecorator <|-- CSVReader : decorates with CSV parsing
    ReaderDecorator <|-- EntityReader~T~ : decorates with entity creation
    EntityReader~T~ <|-- MorgReader : Morg specialisation
    ReaderDecorator *-- Reader : wraps
    
    note for ReaderDecorator "Decorator wraps Reader component"
    note for CSVReader "Adds CSV parsing functionality"
    note for EntityReader~T~ "Adds entity creation using Factory"
    note for MorgReader "Morg-specific entity creation"