Cs51 introduction to computer science ii spring 2018 cs51 ocaml style guide

CS Introduction to Computer Science II Spring CS OCAML STYLE GUIDE STUART M SHIEBER Contents Formatting No tab characters column limit No needless blank lines Use parentheses sparely Spacing for operators and delimiters Indentation Indenting if expressions Indenting let expressions Indenting match expressions Documentation Comments before code Comment length should match abstraction level Multi-line commenting Naming and declarations Naming conventions Use meaningful names Function declarations and type annotations Avoid global mutable variables When to rename variables Order of declarations in a structure Pattern matching No incomplete pattern matches Pattern match in the function arguments when possible Pattern match with as few match expressions as necessary Misusing match expressions Avoid using too many projection functions Don ? t use List hd or List tl at all Date January This style guide is reworked from a long line of style guides for courses at Princeton University of Pennsylvania and Cornell including Cornell CS U Penn CIS and CIS and Princeton COS All this shows the great power of recursion Also the joke about recursion was stolen from COS CCS OCaml Style Guide Verbosity Reuse code where possible Do not abuse if expressions Don ? t rewrap functions Avoid computing values twice Other common infelicities This guide provides some simple rules of good programming style both general and OCaml-speci ?c developed for the Harvard course CS The rules presented here tend to follow from a small set of underlying principles Consistency Similar decisions should be made within similar contexts Brevity ??Everything should be made as simple as possible but no simpler ? attr Albert Einstein Clarity Code should be chosen so as to communicate clearly to the human reader Transparency Appearance should summarize and re ect structure Like all rules those below are not to be followed slavishly but seen as instances of these underlying principles These principles may sometimes be in con ict in which case judgment is required in ?nding the best way to write the code This is one of the many ways in which programming is an art not just a science This guide is not complete For more recommendations from the OCaml developers themselves see the o ?cial OCaml guidelines Formatting Formatting concerns the layout of the text of a program on the screen or page such issues as vertical alignments and indentation line breaks and whitespace To allow for repeatable formatting code is typically presented with a ?xed-width font in which all characters including spaces take up the same horizontal pitch No tab characters You may feel inclined to use tab characters ascii x to align text Do not do so use spaces instead The width of a tab is not uniform across all renderings and what looks good on your machine may look terrible on another ? s especially if you have mixed spaces and tabs Some text editors map the tab key to a sequence of spaces rather than a tab character in this case it ? s ?ne to use the tab key column

Documents similaires
Ling court de gebelin grammaire universelle 1 0 0
Brochure ddb 16 ok 1 C Ce ne sont pas les ressemblances mais les di ?érences qui se ressemblent ? Claude Lévi-Strauss ÉDITO ALTER EGO ? Les musiques de l ? autre Les questions de l ? autre de soi de l ? identité de la di ?érence s ? imposent de façon de p 0 0
aappo1 BACCALAURÉAT GÉNÉRAL ÉPREUVE D ? ENSEIGNEMENT DE SPÉCIALITÉ SESSION ARTS Arts plastiques Durée de l ? épreuve h Matériels autorisés feuilles de papier machine blanc A Papier brouillon Seuls les supports fournis sont autorisés Le matériel graphique 0 0
Rapport atelier de douala RAPPORT DE L ? ATELIER Date Lieu Organisé Atelier de formation sur L ? échange d ? informations au Portail Phytosanitaire International Atelier Régional Afrique Francophone - Janvier Douala- Cameroun - Janvier Hôtel Résidence la 0 0
Texto origen 3 Tourisme à Paris Paris ? cette seule évocation est déjà un prélude au plaisir et à la fascination Cette ville qui se targue d ? être la plus belle ville du monde la capitale du romantisme ou le c ?ur de la culture et de la mode européenne e 0 0
Cours stylisme couture Cours de Stylisme Couture Introduction Française j ? ai grandi à Paris ma mère était créative son goût du dessin de la couture des belles matières et du travail bien fait sont devenues une évidence pour moi J'ai naturellement intégr 0 0
04sta00225 1 IUFM DE BOURGOGNE Isabelle GREGORI Professeur des écoles Centre IUFM de Dijon Année Mémoire professionnel Comment améliorer la compréhension des consignes Directeur de mémoire Mme Denise Rum N STA CSOMMAIRE Introduction p I La consigne mode d 0 0
Muzeul luvru Le musée du Louvre est un musée d'art et d'antiquités situé au centre de Paris dans le palais du Louvre C'est l'un des plus grands musées du monde et le plus grand de Paris par sa surface d'exposition de m et ses collections qui comprennent e 0 0
Devoir de controle n01 8 E P Dahmani A S ?? Prof Chelbi Abdelmonom Devoir de contrôle n Français Niveau ème b Durée heure Nom ? ? ? ? ? ? ? ? Prénom ? ? ? ? ? ? ? ? ? Classe ? ? ? ? ? N ? ? Texte Mon grand-père décide de m ? inscrire au collège Montaigne 0 0
Les differents systemes educatifs 0 0
  • 82
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager