caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Yang Shouxun <yangsx@fltrp.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] automatic extraction of mli file?
Date: Sun, 13 Oct 2002 12:20:40 +0200	[thread overview]
Message-ID: <20021013122040.A20071@pauillac.inria.fr> (raw)
In-Reply-To: <3DA8021B.3050102@fltrp.com>; from yangsx@fltrp.com on Sat, Oct 12, 2002 at 07:06:03PM +0800

> I'm quite new in OCaml and I want to know what is the practice of the 
> OCaml programmers. Will you first write the interface files, then 
> implement, or vice versa?

Here is my recipe: you write an interface file when the interface of
your module becomes clearly defined, and you feel ready to document
the interface.

For some modules, typically data structures, this means the interface
is written first: you know that you'll need, say, doubly-linked
circular lists, and you have a fairly clear idea of what operations
you'll need.  Then, you can write the interface and some comments on
the behavior of the functions, and go ahead with writing the remainder
of the program.  Later, you'll implement the data structure.

For other modules, you'd typically start with the implementation and
no interface file, as the external interface to your module isn't
clear yet.  When it stabilizes and needs to be documented, now is the
time to write an interface file.

Think of it this way: the interface file is where you document (via
comments) the external, behavioral specification of your code.
Comments in implementation file should just be comments on how the
implementation works (e.g. "this is Kildall's worklist algorithm, as
documented in <blah> section 11.4.2").  If you ever feel like
writing a behavioral comment in an implementation file ("this function
computes this and that"), don't: create the interface file instead.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      parent reply	other threads:[~2002-10-13 10:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-12 11:06 Yang Shouxun
2002-10-12 11:33 ` Nicolas Cannasse
2002-10-12 11:50   ` Yang Shouxun
2002-10-12 12:52     ` Sven LUTHER
2002-10-16 13:03     ` Claude Marche
2002-10-12 11:55 ` Remi VANICAT
2002-10-13 10:20 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021013122040.A20071@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=yangsx@fltrp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).