Coder Social home page Coder Social logo

style-guides's Introduction

Hammer Lab Style Guides

Guidelines for programming languages, git workflows, etc.

style-guides's People

Contributors

smondet avatar hammer avatar

Stargazers

Charles avatar Girish Sastry avatar Nikolaos avatar Stéphane Legrand avatar Kevin Cantú avatar Uri Laserson avatar Leonid Rozenberg avatar  avatar

Watchers

Alex Rubinsteyn avatar Dan Vanderkam avatar Maxim Zaslavsky avatar Arun Ahuja avatar Ryan Williams avatar Tim O'Donnell avatar  avatar James Cloos avatar Jacki Buros Novik avatar Anh-Dung Phan avatar Rohan Pai avatar Leonid Rozenberg avatar giancarlok avatar Jamie Reilly avatar  avatar

style-guides's Issues

Use if-then-else in OCaml

I find

match force_reload with
| false -> Target_cache.get explorer.target_cache ~id
| true -> return None

more confusing than

if force_reload then
  return None
else
  Target_cache.get explorer.target_cache ~id

or

if force_reload
then return None
else Target_cache.get explorer.target_cache ~id

which is my preferred version.

Vertical alignment

I've become a big fan of vertically aligning data-structure definitions and let bindings. So I strong prefer:

type exploration_state = {
  build_process_details : bool;
  target_filter         : (Target.t -> bool) * Log.t;
  current_target        : Target.id option;
  condition_details     : bool;
}

let create_state () = { 
  build_process_details = false;
  condition_details     = false;
  target_filter         = (fun _ -> true), Log.(s "No-filter, see them all");
  current_target        = None
}

to

type exploration_state = {
  build_process_details: bool;
  target_filter: (Target.t -> bool) * Log.t;
  current_target: Target.id option;
  condition_details: bool;
}

let create_state () =
  {build_process_details = false;
    condition_details = false;
    target_filter = (fun _ -> true), Log.(s "No-filter, see them all");
    current_target = None}

similarly, I like

let foo a b c =
    let x   = a () in
    let xx  = b x in
    let y   = c xx in
    ...

as opposed to

let foo a b c =
    let x = a () in
    let xx = b x in
    let y = c xx in

I find it easier to read code as performing a function this way. I know that I resisted this style for quiet some time in my own code, but now find it very helpful. Let me know what you guys think!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.