Closed FrankKair closed 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:
Python
and C/C++
always name the not solve
functions as function_name()
Java
always name the not solve
functions as functionName()
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.
@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
😅.
@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?
@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.
@FrankKair for sure, I will take a look on the docs and patterns for Scala tonight! 😄
I'll give Clojure a shot then 😄
I'd suggest the following style for Haskell files:
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.
Someone accidentally deleted @lucaspbordignon's commit. Let's be careful when force-pushing, please.
Oh no, it was me! Sorry @lucaspbordignon 😕 Can you add it again?
Clojure is pretty straight-forward:
(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))
```
This pull request tries to come up with a framework and guideline for contributions, as discussed in #14.
What do you guys think?