UA CS 520 - Study on Object-Oriented Language Eiffel

Unformatted text preview:

Forth Stack Programming LanguageSlide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Study on Object-Oriented Language EiffelAnurag Katiyar Jie YaoInstructor: Dr. Christian CollbergApril 30th, 2008IntroductionHistoryBertrand MeyerCase StudySpecial PropertiesMultiple inheritance and RenamingSpecial PropertiesTyping (Static)GenericityUnconstrained STACK[G]constrainedBINARY_TREE[G->COMPARABLE]Assignment attemptX ?= YAnchored declarationsX: like YNo type castSpecial Properties Exception Handling No Main and GlobalsRoot classRoot procedureDesign Principles Design by Contract Command Query Separation Uniform Access Principlea.balance (attribute? function?)Internals Compilation process Garbage CollectionMark and SweepGeneration ScavengingOO languages ComparisonSummaryObjective-CIntroduction[Karthik Ravichandra][Bhavin Mankad]CS520: Introduction to Objective-C2History Designed by Brad Cox and Tom Love at their company StepStone Steve Jobs’ NeXT licensed Objective C from StepStoneand released their own version of Objective-C compiler, libraries (NeXTstep) NeXT partnered with Sun Microsystems to develop OpenStep based on NeXTstep GNUstep - Glatting, Stallman Apple acquired NeXT and used OpenStep in Mac OS-X1984198819921996* Timeline not to scaleCS520: Introduction to Objective-C3Goals of Design Object Oriented Design and Development Strict Super-set of C Simple Syntax Extensions to C, influenced by SmallTalk Convenient Mixing of Structured and Object Oriented Programming Dynamic BehaviorCS520: Introduction to Objective-C4Sample Code Square.h - Interface#import “Shape.h”@interface Square: Shape {float side;}+ (void) countRectangles;- (id ) initWithSide: (float) side;@end; Square.m - Implementation#import “Square.h”@Implementation Square-(void) initWithSide: (float) side{//method body}@endCS520: Introduction to Objective-C5Objects, Classes and Inheritance Basic Building Blocks of OO programming Only Single Inheritance allowed NSObject is the root for all classes Dynamic or Static Typing for Objectsid square =[ [Square alloc] init];orSquare *square = [[Square alloc] init];CS520: Introduction to Objective-C6Messaging Syntax: Method calls via message passing Preprocessor translates a message into objc_msgSend(..) function Class template lookup for method calls on objects at runtime (Similar to Luca!)[ rectangle init];[ rectangle setLength:100 andWIdth:60]; Message without arguments  Message with two argumentsCS520: Introduction to Objective-C7Dynamic Behavior Dynamic Typing Deciding the class of an object at runtime. Dynamic Binding Deciding which method to invoke at runtime.id Obj = getReceiverObj(bool flag); // True – Rectangle, False – SquareSEL msg = getMessage(bool flag); // True – SetWidth, False - Setsize[ Obj performSelector: msg];CS520: Introduction to Objective-C8Categories Extends the functionality of a class. A good alternative to sub-classing. Sub-classes inherit the new methods. Merits Can split implementation of a huge class. Simplifies code management. Base class code is not recompiled.CS520: Introduction to Objective-C9Properties. Allows for easier ways to access variables. Can associate attributes. readwrite, readonly etc. Can synthesize getter and setter methods.@interface Rectange{…@property (readwrite) int size;…}@implementation Rectangle{…@synthesize size;…}Rectangle *rect = [[Rectangle alloc] int];rect.size = 10; // [Rectangle setSize: 10]CS520: Introduction to Objective-C10Memory Management Manual Memory Management in 1.0 Uses reference counting technique. Keywords - retain, release, autorelease. Example:Rectange *rect = [[Rectangle alloc] init]; // retainCount is 1.Rectangle *tmprect = rect; // Another reference to rect.[tmprect retain]; // So we increment the retainCount.….[tmprect release]; // Decrement retainCount.….[rect release];CS520: Introduction to Objective-C11Summary One of the early Object Oriented Languages. Popularized by Apple. Based on C, influenced by Smalltalk. Significant Dynamic Behavior. Some cool features like Categories, Properties etc. Generation based Garbage Collection.MODULA-3Swaminathan Sankararaman Bojan DurickovicMODULA-3 ExampleMODULE Main;Main.m3:BEGINn := 3;END Main.ImportsExportsLinkedList.i3:INTERFACE LinkedList;PROCEDURE Add(VAR I : INTEGER);BEGINLinkedList.m3END LinkedList.MODULE LinkedList;PROCEDURE Add(VAR I : INTEGER) = ...END LinkedList.IMPORTS LinkedListVAR n : INTEGER;LinkedList.Add(n);HistoryYear Event1986 Proposal1988-1989 Language Definition1990s DEC SRC-M 3, CM3 a nd PM3 released1990s Popular as a teaching language1994 SPIN OS developed1996-1997 CVSup developed2000 Critical Mass Inc. ceases operations2000-2002 Elegosoft takes over CM3 a n d PM3Goals and Target Audience◮Structuring of Large Programs◮Safety and Robustness◮Machine-level programming◮SimplicityTARGET AUDIENCEIntendedActualProgrammers oflarge, sophisticated systemsand applicationsProgramming Language InstructorsResearchersObjects and GenericsOBJECT◮Record paired with Method SuiteTYPE T = OBJECTa: INTEGER;METHODS a() := AEND;PROCEDURE A(self: T) = ... ;GENERICS◮Parametric Polymorphism◮Entire Modules and Interfacesare GenericGENERIC MODULE LinkedList(Elem);REVEAL T = BRANDED OBJECT val: Elem.T ;INTERFACE Integer; TYPE T = INTEGER END Integer.END m1.METHODS set(v: Elem.T) := P; END;PROCEDURE P(self:T; v:Elem.T) = ... ;MODULE IntList = LinkedList(Integer) END IntList.INTERFACE IntList = LinkedList(Integer) END IntList.GENERIC INTERFACE LinkedList(Elem); TYPE T <: REFANY;Type SystemNO Ambiguous Types or Target-TypingVAR x : REAL; y : INTEGER ; z : REAL ;x := y∗ z ;(∗ Type o f y ∗ z de pe nd s on y and zand not x ∗ )NO Auto-ConversionsVAR x : REAL; y : INTEGER ;y := x ;(∗ No Auto mati c f l o o r ( ) .S t a t i c E r r o r ∗)Type Compatibility S <: T =⇒ S ⊆ TStructural Equivalence T ≡ U =⇒Expanded Definitions of T and U are the sameProcedures Global→First-Class,Local→ Second-ClassInformation Hiding - Revelations◮At an implementation level, reveal only features of t he typerelevant to that levelREVEAL T <: U◮Revelations are linearly ordered with final revelation definingthe concrete type of the object2nd1stImplementor knows only


View Full Document

UA CS 520 - Study on Object-Oriented Language Eiffel

Download Study on Object-Oriented Language Eiffel
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study on Object-Oriented Language Eiffel and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study on Object-Oriented Language Eiffel 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?