Mapa mental
2.1 Create Types
Conteúdo do mapa
2.1 Create Types
3 categories
- Value Type
- Contain value directly
- Criteria -
- Inheritance
- Must use STRUCTS (cannot Inherit directly)
- STRUCT eg => public struct Point { definition of Struct}
- Must use STRUCTS (cannot Inherit directly)
- Reference Type
- Reference specific value (e.g. URL)
- Pointer Type
- Generics R Good (unlike medication)
- Value Type
Extensions and Overrides
- Extensions
- Called like a regular method
- e.g. Method (this ExtMethod methodname)
- BEst use case - LINQ
- Overrides
- If sealed = no extension/override
- Extensions
Classes
- Functions vs Methods
- Functions - RETURN VALUE
- Methods - Just do work. C# Preferred
- Preferred - Split into Smaller Methods
- SOLID Design Principles
- S = Single Responsibility
- Class should only be responsible for ONE THING
- O = Open/Closed
- Open for Extension, but Closed for Modification
- L = Liskov Substitution
- I =Interface Segregation
- D = Dependency Inversion
- S = Single Responsibility
- Functions vs Methods
Generics
- Parameter = Type (NOT SPECIFIC
- Allows Nullables (usaally a coding nightmare - value types e.g. bool)
- Constraints
- Where T : Struct
- Only Nullable nots allowed
- Where T : Class
- REFERENCE ONLY
- where T : new
- Must have default constructor
- Where T : <base class> (i.e. T: <string>
- T must be a string or derive from a string
- Where T : <interface>
- T must be interface or implement it
- Where T : Struct
Informações
- Descrição
- Microsoft C# Mapa Mental sobre 2.1 Create Types, criado por Darren Olivier em 25-09-2018.
- Criado por
- Darren Olivier
- Visualizações
- 1
- Avaliação