Skip to content

Meurig's tech-test solution (1 hour refactoring) - #7

Open
meurig wants to merge 3 commits into
seanogt:masterfrom
meurig:master
Open

Meurig's tech-test solution (1 hour refactoring)#7
meurig wants to merge 3 commits into
seanogt:masterfrom
meurig:master

Conversation

@meurig

@meurig meurig commented Aug 8, 2019

Copy link
Copy Markdown

Please note, this change depends on a breaking database schema change. A non-null integer field CustomerId must be added to the Orders table, with a foreign key to the Customers.CustomerId field before this code is deployed. Existing orders will need to be archived or updated. Any classes depending on this library will also need to be updated to reflect changes to the Services.

Given the time constraints (1 hour!) I have focused my efforts on the following areas:

  • Added stylecop (a linter) to enforce consistent coding style
  • Added documentation
  • Added interfaces for the repositories to allow them to be mocked (to enable testing)
  • Services take instances of repositories in their constructors (to enable testing)
  • Added the requested Load Customers with their Orders functionality in a new customers service
  • Added unit tests for the orders service and customers service

If I had more time, and now that unit tests are in place for the services, I would:

  • Remove the existing SqlClient code and use Entity Framework (or similar)
  • Add tests around the repository implementations (using an in memory database?)
  • Seek to further understand the CustomerRepository static class requirement (it doesn't make sense to me at the moment)
  • Add interfaces for the Services (allowing clients that use this library to code to the interface, not the implementation) or implement existing interfaces if they exist (i.e. if this library is designed to replace existing functionality)
  • Consider migrating to .NET core (or .NET Standard?)
  • Ensure the unit tests are run as part of a CI/CD pipeline
  • Consider adding a dependency injection framework (Unity?)
  • Consider how/where this will be deployed (Docker/Kubernetes?) and then how best to inject the database config (username/password in Kubernetes secrets? dataserver dependent on environment)

Naturally I would seek to understand existing practices and strategy/direction within the company/team before adopting new technologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant