Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Class-Based Inheritance (1 point)
A class is a template definition of the data and behavior of an object. An instance is an implementable version of a class. Every object in Smalltalk is an instance of some class. The class determines the data and behavior of its instances. Instance variables have their own copy for every instance for that class. Class variables have only one copy and inherit that copy from the class which the object belongs to. Instance methods are methods which are handled by the instance of the class itself. Class methods are methods handled within the class itself.
Message Passing (1 point)
Everything in Smalltalk is an object All communication and calculation in Smalltalk is done through a chain of messages. Message passing is the sending and receiving of messages as a way of having methods and objects communicate with each other to perform actions. The advantages to message passing is that it is a true object-oriented design, thus forces the programmer to program accordingly. It allows Smalltalk programs to be very flexible, thus easy to customize to your own preferences. The code is also easy to maintain due to its object-oriented nature, allow users to make changes or addition to code easier. The disadvantages lie mainly in performance. Since all computation and communication is done via message passing, in Smalltalk there are no primitives. Thus, Smalltalk programs are less portable, consume more memory, and run slower compared to other languages. Also, smaller programs in which an object-oriented approach is not the optimal way to solve a problem, the message passing system could be more difficult to implement as well run less efficiently than other languages.
Assignment 2 - Monticello
Monticello is an excellent tool for storing and managing group code. To open Monticello, open a Monticello browser in the World menu. This browser image should pop up.
The Monticello browser is divided into 2 sections as shown above. The left side is your package list, the right side is the list of the available repositories you can access.
To setup Monticello, first upload a package into your browser using the +Package button. The image below should pop up. Enter the package name here.
After that select the repository you want to work with and select Open. If the repository is not listed you can add a repository to the list by pressing the +Repository button. A window like this will then pop up.
After you have opened the repository you want to work with another browser that looks like this will pop up.
From here you can load/save/merge your working copy with the versions in your repository. Load will load your selected version onto your image. If the package already exists in your Squeak image, it will overwrite it. Save will save a version of your package (working copy) onto the repository. Merge merges a the selected version from the repository to your working copy. This is very useful since Monticello actually allows you to select which changes you want to merge and which ones you want to leave out.
Monticello also has some other useful features such as Browse, History, and Changes. Browse allows you to view a snapshot browser of the package you selected. History allows you to view the version information and the notes made by the person who loaded that version onto the repository. Changes allows you to see what changes the selected version would make to you existing copy.
Coweb Assignment 3
History of Object-Oriented Programming (1 Point)
Pick two of the following four people and briefly describe one of their main contributions to object-oriented programming and design: Kent Beck, Ward Cunningham, Alan Kay, and Ivan Sutherland.
Ivan Sutherland - There were two pieces of software whose ideas influenced the birth of object-oriented programming, Sketchpad and Simula. Ivan Sutherland created Sketchpad in 1963 at MIT. Sketchpad was the first object-oriented graphics editor, in the sense that we know it today. What made Sketchpad unique was that you could create objects and place them on a canvas that could be manipulated as distinct from other objects. Also, Sketchpad could allow the user to create a "master drawing" from which the user could define a set of "instance drawings". Each instance drawing would be just like the master drawing, and changing the master drawing would change all of the instance drawing. This idea was the start of inheritance, where structure and behavior are passed on from some objects to others.
Alan Kay - Alan Kay is one of the early pioneers in object-oriented programming. Kay, influenced by Sketchpad and Simula, believed that the best way to use a computer was as if it had thousands of little computers inside it - each independant, but interacting in clearly defined way. His first attempt at an object-oriented programming system called FLEX. In 1970, he joined Xerox PARC and led the team which created Smalltalk. Intended for children, Smalltalk was the first object-oriented programming language, in the way we think of object-oriented languages today. Smalltalk systems were also the first to have bit-mapped displays, overlapping windows, menus, icons, and a mouse pointing device.
Collection Classes (1 Point)
Answer the following questions on the different collection classes available in Squeak.
1.) How do OrderedCollection and Set differ?
A Set only remembers the element, Ordered Collection are indexed, therefore a Set cannot have duplicate elements whereas an Ordered Collection can.
2.) How do OrderedCollection and Array differ? Why would you use one over the other?
Arrays store their elements in instance variables of the Collection object, thus must be a fixed size. An OrderedCollection store their elements in an Array that is referenced by an instance variable of the Collection, thus it can grow in size. An Array would be preferable in situations in which speed was a factor and in which the size of the Collection would not need to grow or if memory space was not a factor (ie. make the array so large that it probably would not go out of bounds). An OrderedCollection would be preferred if the user put more of a premium on memory space and was willing to trade off speed, since an OrderedCollection can grow based on need.
3.) How do you use a Dictionary? Why is accessing a Dictionary so fast?
A Dictionary is used by taking in a key and a value just like a hashtable. For example, aDictionary at: 'Greeting' put: 'hello'. Accessing a Dictionary is fast because it uses hashing, which is much faster for finding than an array.
Object-Oriented Language Design (2 Points)
OO programming languages differ quite a bit in their philosophy, purpose, and implementation. The following five questions ask you to examine some design choices for creating an OO language. Answer only two of the following:
2.) C++ and Java are statically typed. Objective-C and Smalltalk are dynamically typed. What are the trade-offs of static and dynamic typing?
Static typing forces explicit declaration of all variables and is type checked at compile time. Dynamic typing does not require explicit declaration of variables before they are used. Dynamic typing is great because you do not have to initialize variables. You can simply just use a variable whenever you need it. Simply put, you write less lines of code. However, the tradeoff to that comes in error checking. If the programmer were to accidentally misspell a variable name, a statically typed language such as Java would catch this error at compile time since this variable was never explicitly declared or initialized. However, in dynamically typed language such as Smalltalk, this error would not be caught. It would simply treat the misspelled variable as a new and valid variable declaration and run the code. This could potentially cost the programmer more time in debugging because sometimes logical errors like that can take time to find.
3.) Most OO languages run on a virtual machine. Java and Smalltalk do. C++ does not. What are the advantages and disadvantages of using a virtual machine for OO programming?
The three main advantages of a virtual machine are in its portability, memory, and security. Virtual machines allow for binary compatibility between platforms. For example, if a C++ program is compiled on Windows, then it is only executable on Windows. With Java or Squeak, it can be compiled once and run on any platform with a virtual machine. In a virtual machine, the user does not have to explicitly allocate or deallocate memory...no pointers and they have their own garbage collection. Also, since the code is not being run on the bare machine, a virtual machine is more secure.
The disadvantages of a virtual machine lie mainly in execution and overhead. A language with no virtual machine like C++ typically executes faster than a language with a virtual machine like Squeak. Also, since a language like C++ does not require the user to download a virtual machine to run the code, it consumes less memory.
Links to this Page