The Pain Points of C#

14
Object Oriented Programming Pain Points

description

 

Transcript of The Pain Points of C#

Page 1: The Pain Points of C#

Object Oriented Programming Pain Points

Page 2: The Pain Points of C#

General Architecture(Simplified)Database

Data Access (O/R)

Domain Model

Business Logics Service layer

User Interface Logics

User Interface Data Model

User Interface

Debug

Page 3: The Pain Points of C#

Needed Changes in Maintenance

New Business-need• Domain changes

Bug• Surprising side effects

Page 4: The Pain Points of C#

The shape of objects have to be specified before the functionality

Natural?• “I and the bird, in the field, run and fly away”• “I run in the field and the bird fly away”

Mandatory “bottom-up” design

Page 5: The Pain Points of C#

Object

Page 6: The Pain Points of C#

vs. function-parameter

Page 7: The Pain Points of C#

“Generic/common” objects

Base class cause problems

Leads to reflection• Runtime exceptions to the user• Performance hit

Page 8: The Pain Points of C#

The pain points of C#

Page 9: The Pain Points of C#

Immutable propertypublic class MyObject{    private readonly string myproperty;    public string MyProperty {         get{            return myproperty;        }    }    public MyObject(string prop)    {        myproperty = prop;    }} 19 words + 10 brackets!

Page 10: The Pain Points of C#

Type Definitionsvar list = new List<List<int>>{                new List<int>{1,2,3},                new List<int>{4,5,6},};

Ok!Noise!

Func<Func<int, List<int>, string>, Func<int, List<int>>, int, string> S = (x, y, z)=> x(z, y(z)); 

Page 11: The Pain Points of C#

F# Syntaxtype MyObject(prop:string) =     member x.MyProperty = prop

7 words + 2 brackets!

let list = [[1;2;3];[4;5;6]]

let S x y z = x z (y z) Ok!

Page 12: The Pain Points of C#

Generics Parameter Constructor

Page 13: The Pain Points of C#

void is not a type

Func and Action are separate classes

Page 14: The Pain Points of C#

There is no “either-or”-type

Not without interface• Switch takes const parameter?

Leads to Reflection or casting• Performance• Runtime exceptions