FrankKair / polyglot-euler

📜 Project Euler solutions in various programming languages
MIT License
74 stars 14 forks source link

CONTRIBUTING.md #50

Closed FrankKair closed 6 years ago

FrankKair commented 6 years ago

This pull request tries to come up with a framework and guideline for contributions, as discussed in #14.

What do you guys think?

caiangums commented 6 years ago

I agree with this kind of doc and think it's very relevant!

My only concern is with the naming pattern adopted on the functions, specifically in C/C++, Java and Python as these are the languages that I know different naming conventions. The problem with these languages is the capability of naming functions in different ways. We can pick a pattern, like:

This kind of stuff can be documented on a single line on each part of CONTRIBUTING.md but can maintain the pattern. And sure that was just an example of how the naming should be done. I'm open to discussing this stuff on #14.

I think @caiopo can give a good contribution in Haskell (and other languages too) naming functions too as I saw the code on his PRs.

FrankKair commented 6 years ago

@caian-gums Regarding naming conventions, yes, each language have their own "case". Swift, Java, Scala all use camelCase, whereas Python, Ruby, Lua, Elixir all use snake_case. We even have the odd man out Clojure with kebab-case 😅.

FrankKair commented 6 years ago

@caiopo pointed out that only calling a solve function gives no context whatsoever to the reader, and he's right.

This is an issue for simple problems, I guess, because when we have a somewhat more complicated challenge, we always abstract away some pieces of computation. Maybe we should keep the same idea for smaller problems as well, like this. Even if the computation is done in one loop, we could still provide meaningful information, and afterwards call the general function in an enclosing solve function.

Any thoughts?

FrankKair commented 6 years ago

@fredericojordan I know very little about these languages, maybe you could take care of Clojure? 😆 @caiopo Could describe the best approach for Haskell and @lucaspbordignon gets Scala.

lucaspbordignon commented 6 years ago

@FrankKair for sure, I will take a look on the docs and patterns for Scala tonight! 😄

fredericojordan commented 6 years ago

I'll give Clojure a shot then 😄

caiopo commented 6 years ago

I'd suggest the following style for Haskell files:


Haskell

function1 :: a -> b
function1 x = -- Body

function2 :: b -> c
function2 y = -- Body

main :: IO
main = print $ -- Call other functions

Note: type signatures are mandatory to all top-level functions.


Markdown:

### Haskell

```haskell
function1 :: a -> b
function1 x = -- Body

function2 :: b -> c
function2 y = -- Body

main :: IO
main = print $ -- Call other functions
```
Note: type signatures are mandatory to all top-level functions.
caiopo commented 6 years ago

Someone accidentally deleted @lucaspbordignon's commit. Let's be careful when force-pushing, please.

FrankKair commented 6 years ago

Oh no, it was me! Sorry @lucaspbordignon 😕 Can you add it again?

fredericojordan commented 6 years ago

Clojure is pretty straight-forward:


Clojure

(defn function1 [x]
  ; function body
)

(defn solve [] (function1 a))

(prn (solve))

Markdown:

### Clojure

```clojure
(defn function1 [x]
  ; function body
)

(defn solve [] (function1 a))

(prn (solve))
```