Skip to content

Simple scenario written in an anti-pattern + written in quality way

License

Notifications You must be signed in to change notification settings

kdchamil/qualitycode-csvimport-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qualitycode

Simple scenario written in an anti-pattern is re-written in quality way.

This program exposes a simple REST API to upload a csv file containing user information in the following pattern.

"Chamil", "83, Quality Road, Sri Lanka",36

The program will then validate the file, each record and convert them into User objects. The user objects will be stored in a database.

The code contains many packages named as com.chamil.qualitycode.v0 and com.chamil.qualitycode.v1

V0 Package

The package "v0" contains the traditional code and the v1 and above are steps towards the final quality code.

V1 Package

the package v1 contains a decoupled code with unit tests covering each class separately. The classes are SOLID by the design.

The ImportCommand class can be used to import any other data type into another destination storage as well. The only thing to do is writing the right mapper, validator and the store classes.

Just implement a new DataSource class if you want to change from CSV to excel or any other data type.

Disclaimer

This code is purely a demonstration of clean code. It is not well tested. You are invited to test it for all possible unhappy paths.

About

Simple scenario written in an anti-pattern + written in quality way

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages