Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

V2 #3

wants to merge 11 commits into from

Conversation

qhwa
Copy link
Owner

@qhwa qhwa commented Jul 6, 2020

This is the second attempt at doing the code challenge. It has been half a year since my last try, and I'm really happy to find that I have along the way harvest some new ideas on developing Elixir applications.

In this PR, I represent the lean technologies I think to satisfy such a requirement:

Small business core models

  • lib/core/product.ex represents the Product model
  • lib/core/store.ex represents the Store model

Both models are tiny. Upon them, states are maintained by a process, lib/hoover/store_state.ex.
The boundary comes the most outside, providing a web interface, supported by Plug, communicating with the state process.

It's layered but tiny.

Baseline for code quality

  • credo for linting
  • dialyxir for static type checking
  • excoveralls for test coverage reporting
  • git_hooks for doing all the above checking in developer's machine before checking in

This is a basic boilerplate structure according to my experiences so far.
I'm pretty sure it can be improved. Please share what you think~

@qhwa
Copy link
Owner Author

qhwa commented Jul 6, 2020

Some additional ideas:

On testing

I wrote none unit test but some integrating tests and make the test coverage at 100%. I used to write more unit tests than interesting tests. I found this approach to add little value to the maintenance.

  • Bugs occurred frequently without integrating tests.
  • Unit testing mostly repeat what has been tested in the integrating test
  • Unit testing force me to expose private functions so that I can test the public functions
  • TDD with unit testing is not a thing, for the designs keep changing during writing code

In a word, integrating tests are preferred. I can be confident enough with 100% coverage of integrating tests.

@qhwa
Copy link
Owner Author

qhwa commented Jul 6, 2020

Plug or Phoenix

Eventually, in most cases, your application will grow and you will use Phoenix. But for this fixed requirement here, it won't. So Plug is employed instead of Phoenix to make the structure look more clear.

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