Giter Club home page Giter Club logo

jsontoxml's Introduction

tomasforsman

Welcome to your new Jekyll theme! In this directory, you'll find the files you need to be able to package up your theme into a gem. Put your layouts in _layouts, your includes in _includes, your sass files in _sass and any other assets in assets.

To experiment with this code, add some sample content and run bundle exec jekyll serve โ€“ this directory is setup just like a Jekyll site!

TODO: Delete this and the text above, and describe your gem

Installation

Add this line to your Jekyll site's Gemfile:

gem "tomasforsman"

And add this line to your Jekyll site's _config.yml:

theme: tomasforsman

And then execute:

$ bundle

Or install it yourself as:

$ gem install tomasforsman

Usage

TODO: Write usage instructions here. Describe your available layouts, includes, sass and/or assets.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hello. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Development

To set up your environment to develop this theme, run bundle install.

Your theme is setup just like a normal Jekyll site! To test your theme, run bundle exec jekyll serve and open your browser at http://localhost:4000. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.

When your theme is released, only the files in _layouts, _includes, _sass and assets tracked with Git will be bundled. To add a custom directory to your theme-gem, please edit the regexp in tomasforsman.gemspec accordingly.

License

The theme is available as open source under the terms of the MIT License.

jsontoxml's People

Contributors

tomasforsman avatar

Watchers

 avatar

jsontoxml's Issues

Code review as requested

This is a code-review according to request on Kodapor; https://www.facebook.com/groups/utvecklare.stockholm/permalink/1692522717463460/

The opinions below are mine alone and any action is at the discretion of the reader. The review is what you could expect as a professional developer in a team I mentor.

Project structure

I would consider moving sample files to a separate folder to keep the root folder as possible.

Git

It is common practice to call the default branch master in git, not dev. By following accepted standards it is easier for new developers to find and understand your code.

Code review

Command line tools are expected to have parameters for input and output file names, or read from stdin and write to stdout directly. To require the user to execute the program from the same folder as the input files, and require specific filenames makes the program less useful.

Command line tools are expected to end without the user pressing a key. That way one output can easily be piped to the next tools input.

It is good practice not to let applications end with a crash. After successfully logging in the outer catch-block you should end the program with an exit-code != 0, i.e. Environment.Exit(1); instead of throw ex;.

In case you actually need to throw an exception from inside a catch-block, you should never rethrow with throw ex;, since that effectively throws away the original stackframes. Rather, throw the existing exception with just throw;, or throw a new exception with something like throw new ApplicationException('oops!', ex);. See https://exceptionalcode.wordpress.com/2010/04/13/net-exceptions-throw-ex-is-evil-but-throw-is-not-that-innocent/

There is really no need to cast strings to string by adding .ToString() at the end. This notion makes the code harder to read and me as a reader to think there is something going on that I don't understand.

Modularize yor logic a lot more. You may want to read up on the Single Responsibility Principle, which is the first part of SOLID; https://en.wikipedia.org/wiki/Single_responsibility_principle

  • Move reading of json-objects into its own class. Use filename as a method parameter. Consider creating one generic method for reading both files.

  • Create a new class for writing objects to xml. Both filename and actual object to serialize should be method paratmers - unless writing to stdout instead...

You should avoid manually serializing xml with XmlWriter. XmlWriter is fast but very verbose to write; it becomes error prone, hard to read and complicated to extend in the future. It is great for writing large amounts of data to a stream without keeping the entire source in memory though.

Instead of XmlWriter, consider assembling all data to be serialized in an outer object and use XmlSerializer (System.Xml.Serialization.XmlSerializer) to write to xml. The file format is then declared like how you already declared how the json files are deserialized.

Final thoughts

I think it is better to leave out fields like clearingNumber from the xml output instead of writing artificial strings like N/A. Those artificial strings makes it harder to deserialize correctly and will likely come back and bite you one day...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.