Skip to content

Code Review: FileManager  #1

@Thorarin

Description

@Thorarin

A couple of things about the FileManager class:

  • The class is public, but all methods are internal, so the class might as well be internal.
  • All methods in the class are static. Make the class static
  • The File.Exists ? ... : ... pattern leads to unneeded repetition. Use File.Open instead.
  • Make use of the using statement to ensure streams/files are being closed under exceptional circumstances.
  • Last but not least: the file format is binary, but the files have an .xml extension and the methods are named as if XML is being used.

Those are the most important issues, I would say. There are a few less important ones I'd still like to mention:

  • Use constants for file names to avoid inconsistencies between loading and saving
  • The method names feel 'asymmetrical'. If there is a SaveFoo method, I expect a LoadFoo method, not GetFoo or GetAllFoo.
  • Some Lists are being created unnecessarily while loading data (if the file has any contents).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions