Skip to content

Commit

Permalink
add outline of why/what we are building #95
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Sep 30, 2019
1 parent 7c3056d commit 8b65a11
Showing 1 changed file with 87 additions and 4 deletions.
91 changes: 87 additions & 4 deletions code-reuse-publishing-to-hexpm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ you may be wondering how to re-use
both your own code across projects
and other people's code in your projects.

# Why?

> "Good programmers
know what to write.
Great ones know what
to rewrite (and reuse).". <br />
~ Eric S. Raymond - "The Cathedral and the Bazaar"

> "_Code reuse is the Holy Grail of Software Engineering._"
~

The biggest advantages of code reuse are:
+ Independently tested small pieces of code
that do only one thing.
([Curly's Law](https://blog.codinghorror.com/curlys-law-do-one-thing))
+ Work can be subdivided into teams with clear responsibilities.
Or if you are solo developer,
having small chunks of code helps you bitesize your work
so you can check things off a bigger list faster.
+ You can use other people's code to reduce your own efforts and ship faster.


# What?

Expand All @@ -21,20 +42,70 @@ Along the way we will demonstrate how to:

A quotation or quote
is the repetition of someone else's statement or thoughts.
Quotes are usually an expression of wisdom in a concise form.



In our example we will be focussing on
a subset of quotes; the motivational kind. e.g:

![inspirational-quote-tony-robbins](https://user-images.githubusercontent.com/194400/65891570-a68a5e00-e39c-11e9-8cfd-d6fcaeea242f.png)


If you are sceptical of motivational quotes,
or "self-help" in general,
remember that words have motivated many masses.

> _I am not young enough to know everything_.”
~ [Oscar Wilde]()

You might not think that motivational quotes _work_ on _you_
in the same way that _most_ people
feel they aren't _influenced_ to advertising.





Examples of popular quotes
(_as upvoted or "liked" by the users of goodreads.com_):
[goodreads.com/quotes](https://www.goodreads.com/quotes)


![inspirational-quotes-motivating-helpful](https://user-images.githubusercontent.com/194400/65878472-0f1a1080-e386-11e9-92b5-8337c581d825.png)



Our objective with this code is
to create an Elixir module that returns
a random quote when `Quotes.random()` is invoked.

# How?

> “First, solve the problem. Then, write the code.” ~ John Johnson
Imagine you have a personal home defined for your web browser
that displays a different inspiring/motivating/uplifting quote
each time you visit it to remind you



The problem we are solving in this example
is creating a module,
that when invoked
returns a random
quote (_e.g a "quote of the day"_).
For example




## 1. Write Useable Code

> "_Before software can be reusable,
it first has to be usable._"
~ Ralph Johnson

## 1. Write Reuseable Code

Our _first step_ is always to write reuseable code.
If you are rewriting the same code
Expand All @@ -44,9 +115,10 @@ you have not understood a
basic principal of software engineering:
reuse code.

> "Good programmers know what to write.
Great ones know what to reuse". <br />
~ Eric S. Raymond - "The Cathedral and the Bazaar"

The more code you are able to reuse,
the more creative and interesting work you can do.



### Documentation: Doctest
Expand All @@ -59,19 +131,28 @@ https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html

### Testing

Given that our principal


## 2. Reuse Code _Without_ Publishing to Hex.pm




## 3. Publish Package to Hex.pm



### What is Hex.pm?



![hex.pm-home-page](https://user-images.githubusercontent.com/194400/65838440-f4e72080-e2fa-11e9-82d4-821187461804.png)


![hex.pm-no-owned-packages](https://user-images.githubusercontent.com/194400/65838879-8c4e7280-e2ff-11e9-8357-c939e3fde78a.png)


## 4. Use the Package in a New Project


Expand Down Expand Up @@ -103,3 +184,5 @@ http://quotes.rest


## References and Further Reading

+ Good background on code reuse: https://en.wikipedia.org/wiki/Code_reuse

0 comments on commit 8b65a11

Please sign in to comment.