Attached, please find a console application which main purpose is to convert the formats.
Prepare:
-
Please find at least 5 potential code issues an be able to explain the reason behind it.
- Paths in code: If I want to change something, I need to rewrite the code and rebuild the app.
- Relative paths in code: It is debatable, but the app depends on a specific directory structure.
- File specific path: Every input file must have the same name.
- File specific path: Output file name/format only over code.
- Not closing files: In the case of an exception, the file will not be closed, potentially blocking the file for another process.
- Not closing files: Writing into a file without closing it will do nothing.
- Validation: Not sure about it, because it depends on the use case, requirements, and data type/structure. Do validation by using the schema to check if everything is OK with the output file.
- Element/tag/property/key as a part of a code: This could be a problem if some typo occurs in the code. Also, case sensitivity.
- Combination of
var(implicitly typed variables) and short (undescriptive) names at some places.
-
Refactor the app to allow:
- Work with documents of various storages eg. filesystem, cloud storage or HTTP (HTML read-only) etc. Implement just one of them but be sure that implementation is versatile for adding other storages.
- Be capable of reading/writing different formats. Implement XML and JSON format, but be sure that implementation is versatile for adding more formats (YAML, BSON, etc.).
- Build the app in the way to be able to test classes in isolation
- Be able to add new formats and storages in the future so it will have none or minimal impact on the existing code
- Be able to use any combination of input/output storages and formats (eg. read JSON from filesystem, convert to XML and upload to cloud storage)
We’re going to appraise the design of given code that should match the quality of production application. Thus imagine this application as a system ready for feature development (adding new storages or formats).
Tests should be written as demonstration of your skills, there is no need to cover everything.
Please version progress as usual, upload your homework to GitHub or other preferred git storage and send us link. Alternatively, use git archive and send us a ZIP archive.