best practice in software development
TRANSCRIPT
Best Practice in software development
Dipl. Inform.(FH) Jony Sugianto, M. Comp. Sc.WA:0812-13086659Email:[email protected]
Agenda
● Programming language features
– Dynamic typed language
– Static typed language
– Strong typing
– Weak typing● Design Database System
– Complexity
- Database model
– Volume
- Sharding
– Traffic read/write
- Replication
Dynamic Typing
● conceptually simpler and easier to understand than static typing.
● more flexible.
● results in more compact programs.
● faster development
/# python num=5num=”hello” #change type automatic
def predict(input): ret=0 # do something return ret
def bigfunction(predict, input): out=predict(input) return out
Static Typing
● Explicit declaration (or initialization) of variables before using
● Type checking is performed during compile-time as opposed to run-time
● One can refactor with greater confidence
● Types serve as documentation
● Run time efficiency
// scala var id:Int=1var number=2var alamat=”jakarta”
def predict(input:Int):Double={ var ret=0.0 // do something return ret}
def bigfunc(predict:(Int)=>Double, input:Int)={ var out=predict(input) return out}
Strong Typing
// scala var foo:String=”x”foo=foo+2 // error at compile time
/* Python code */ # error at runtime>>> foo = "x" >>> foo = foo + 2 Traceback (most recent call last): File "<pyshell#3>", line 1, in ? foo = foo + 2 TypeError: cannot concatenate 'str'and 'int' objects >>>
Weak Typing
// PHP code $str = 5 + "hello"; // equals 5 because "hello" is implicitly casted to 0 // PHP is weakly typed, thus is a very forgiving language.
Summary
● Strongly typed - many rules
● Weakly typed - few rules
● Dynamically typed - rules applied at run time
● Statically typed - rules applied at compile time
Programming Language Features
Design Database System
● Complexity
- Database model
● Volume
- Sharding
● Traffic read/write
- Replication
Database Model
● Key-values Stores
● Document Databases
● Relational Databases
● Graph Databases
Key-Value Example
Key-Values: Cons
● No complex query filters
● All joins must be done in code
● No foreign key constraints
● Poor for interconnected data
Document Databases
● Documents are the main concept
● Documents are:
-self-describing
-Hierarchical tree data structures(map. List, scalar-values)
{ name:ade, usia:20, alamat:depok}
{ name:wahyu, usia:30, pekerjaan:dosen}
Document Databases
Document Databases:Pros and Cons
● Pros:
- Simple model
- Built in Map-reduce ?
- Scalable
● Cons:
- Poor for interconnected data
Relational Model
Relational Database Pros/Cons
● Pros
- simple, well-establish, standard approach
- maps well to data with consistent structure
- has extensive join capabilities
● Cons
- hard to scale
- does not map well to semi-structured data
- knowledge of the database structure is required to create queries
Graph Database
Graph Model
Key Value to Graph
Document to Graph
Relational to Graph
Graph Database Pros/Cons
● Pros
- powerful data model
- easy to query(relation as pointer to object)
- map well to semi-structured data
- can easily evolve schema
● Cons
- hard to scale
- lacks of tool and framework support
- requires new art of problem solving
Sharding
Database Shard ShardShard
Aggregation
● Sharding is Splitting data across databases
● Splitted Data share nothing
● Important issues sharding key
Replication● Creating and maintaining multiple copies of the same
databases
Scalability, Complexity and Database Model
Scalability
Complexity
Key-Values Stores
Document Database
Relational Database
Graph Database
Questions?