[racket] [plt-edu-talk] Using separate files as modules with HtDP

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Nov 17 16:02:26 EST 2013

This is easily doable with a teachpack: 

1. how to create a teachpack
http://docs.racket-lang.org/htdp/index.html?q=teachpack

2. the key is to document the (a) structure type definition and (b) the data definition you export. 

Example: 

#lang racket 

(provide 
   ;; A DR is (make-dating-record String String Number Boolean String) 
   ;; interpretation: (make-dating-record f l dob b c) denotes a person with 
   ;; first name f, last name l, date of birth dob, gender b (true for female, false for male)
   ;; and a comment string c 

   ; DR -> String  
   ; extract first name from dr
   dating-record-first-name 
   
   ; DR -> String  
   ; extract last name from dr
   dating-record-last-name

   ; DR -> Number 
   ; extract dob from dr
   dating-record-dob 

   ; DR -> Boolean 
   ; extract sex from dr
   dating-record-sex 

   ; DR -> String  
   ; extract comment from dr
   dating-record-preference 

   ;; [List-of DR]
   the-dating-db 
   )

;; --------------------------------------------------------------------
;; IMPLEMENTATION 
...



On Nov 17, 2013, at 2:24 PM, john_burnette wrote:

> I hope this in the spirit of the question.  My students are working with structures, a list of several hundred randomly created members of a dating database.  They are happily working to test whether members of the database not only share common interests, but are also satisfying what the member is looking for in a dating match. 
> 
> It's a nice review exercise because they're doing a lot of list processing, automatically generating letters to members telling them the good news that they have matches, well lots of fun stuff like that.
> 
> Currently I have them just cut and paste in the database file I give them, but I do thing it would be more realistic if they accessed it with a "require".  It's working ok without doing this, but I'm thinking of taking that next step - offloading not just the database but the structure definitions as well.
> 
> So having said that I guess I'm obligated to give a reason why. I think doing so really drives home the point about data driven design. Far too many of my students have taken it upon themselves to rewrite the structures and of course as long as they were generating their own examples of "clients" everything worked fine. When they are given the larger database to work with (using the data structures they should have been using) this fall apart.
> 
> Now, yes, I know, if they were carefully following the design recipe is a non issue, and perhaps this serves as a good lesson.  Still, putting them in a place which forces them to use the data structures as written would probably be a good thing. 
> 
> 
> 
> Sent from my Verizon Wireless 4G LTE Smartphone
> 
> 
> 
> -------- Original message --------
> From: Norman Ramsey <nr at cs.tufts.edu> 
> Date: 11/17/2013 1:27 PM (GMT-05:00) 
> To: plt-edu-talk at lists.racket-lang.org 
> Cc: Racket mailing list <users at racket-lang.org> 
> Subject: [plt-edu-talk] Using separate files as modules with HtDP 
> 
> 
> [Shifting to plt-edu-talk]
> 
> > > At Sat, 16 Nov 2013 12:44:03 -0500, Norman Ramsey wrote:
> >
> > >> On their next assignment, my students will reuse code they have built
> > >> for binary search trees.  I would prefer that they place the old code in
> > >> a different source file than the new code.  I tried doing this using
> > >> "require", but I cannot figure out how to get "require" to load a file
> > >> that is written in Intermediate Student Language. Is there another
> > >> mechanism I should try?  Is the thing I want to do even possible?
> 
> Matthias Felleisen replied:
> 
> > Part of the HtDP philosophy is that I want students to ask for
> > concepts. For example, once you have written the same list template
> > over and over again, you want them to say "isn't there a way to
> > avoid writing this same schema repeatedly? and you're ready with "I
> > am glad you asked, here are loops defined in ISL and they are what
> > you want." In the same spirit, I want them to ask for modules and
> > components.
> 
> As teachers, how do we put students in situations where they are
> stimulated to ask for modules and components?  Your list example is
> apropos, and I have certainly written this data definition many times
> this semester.  But my students have not once written 'require', nor
> have they ever seen *me* write 'require'.  Over the course of the
> term, there few functions that they see two or more times (search in a
> binary tree might be one), and no functions that they see defined over
> and over to the point of tedium.
> 
> To put some numbers on it, students might get 40 hours of lecture in
> which to become bored and irritated by seeing the same data definition
> over and over.  But they might get only 11 programming assignments,
> and if repetition is the technique we use to get them to ask for
> things, that repetition is going to crowd out something else?
> 
> So again, what situations do you put students in that motivate them to
> ask for components and modules?
> 
> 
> > My personal preference is to (1) not have code from one assignment
> > be critical for the next one ... [this] is important for weaker
> > students.
> 
> I see merits both ways, and I tend to do some of each.  In real life,
> code from last week can be critical for next week.  And I want to
> militate against an experience that is too common among university
> students: code is built, used, then thrown away and never examined
> again.
> 
> But by having code from one assignment be critical to the next, I now
> place myself in a difficult position:
> 
>   - I want them to reuse their earlier code.
> 
>   - I have told them that programming by "clone and modify" is not
>     acceptable.  And I have asked N times in lab, "what part of the
>     design recipe says to copy the solution to a previous problem and
>     start editing it?"
> 
>   - I have given them no mechanism by which they can reuse a previous
>     solution. 
> 
> For this term, I think I can't work my way out of this one: I can use
> Matthew's workaround to get `provide`, but I have no infrastructure
> that would enable them to submit a solution spread across multiple
> source files...
> 
> I'd like to hear other teachers' thoughts on using modules in the
> first course.  It is considered an important part of our current first
> course, so if I want to get my colleagues to use the HtDP
> infrastructure, I will have to have a better story about it.
> 
> Are you using modules?  How do you motivate them?  If you allow your
> students to spread a program across multiple modules, what
> infrastructure do you use to manage submissions?
> 
> 
> Norman
> ________________________
> PLT Educators talk list:
>   http://lists.racket-lang.org/plt-edu-talk
> ________________________
> PLT Educators talk list:
>  http://lists.racket-lang.org/plt-edu-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131117/8fc0112a/attachment.html>

Posted on the users mailing list.