CIS705a Assignment 1

It's possible to write "script style" in Scala; it's possible to write "functional style" in Scala; it's possible to write "object style" in Scala. But what is "Scala style"?

I have written in C# and in Python implementations of a simple tree-based file-and-folder system. The system is a simple example of the "composite design pattern" that I teach my CIS501 students. Here is the background material: http://people.cis.ksu.edu/~schmidt/501s14/Lectures/DP4S.html. You can find my implementations in the same folder as this assignment sheet.

Your job is to study the two implementations and write one in Scala that makes best use of Scala's features. To do this, you must first study my implementations, then Odersky's Scala text, and then decide what "Scala style" should be. Write your implementation accordingly.

You should definitely use packages (they help organize your code base) and also objects and classes (because Scala is intended to be "next generation Java"). Think about how to use types and the Scala type checker to speed your work rather than slow you down. The rest is up to you.

Odersky believes that the most attractive code is small, simple, and easy to read. (Compare the Python implementation of the file system to the C# one, and you are likely to agree with him!) Can we code "small and simple" but also "secure" in Scala style? Give it a try.

Once you write your implementation, test it with at least the sample file system that is included in the C# and Python programs. Run the same tests that are stated in the C# demo. Include the test code in your code base. (You might also try using Scala's Unit Test support: see Odersky's text, Section 14.2.)

Submission

Submit to K-State Online a zipped folder, A1.zip, that contains your implementation and tests.