Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Development CSU 670 Fall 2007 Karl Lieberherr.

Similar presentations


Presentation on theme: "Software Development CSU 670 Fall 2007 Karl Lieberherr."— Presentation transcript:

1 Software Development CSU 670 Fall 2007 Karl Lieberherr

2 Textbook Booch: OOAD(3) –Concepts partially a review from OOD but much new material, e.g. –Law of Demeter (pages 116, 117) –Method partially a review from OOD but much new material, e.g., –software development lifecycle –project management –Applications useful examples

3 Project: Algorithmic Trading of Derivatives Derivatives are financial instruments whose value derives from the value of assets underlying them"financial instruments Examples of the financial instruments used in derivatives transactions, which reference these underlying assets include: options …options Options are financial instruments that convey the right, but not the obligation, to engage in a future transaction on some underlying security.underlying

4 Website for selling and buying derivatives derivatives can be created on the fly Derivative: –Kind: G –creator name (has to provide raw material of kind G, has to pay for finished product) price offered –buyer name (has to work to produce finished product) price paid –outcome raw material provided price to be paid by creator

5 possibility for re-selling a derivative that was bought is this different than offering the derivative with a higher price are prices public?

6 Special kinds of derivatives Derivatives are often used to control risks: weather, foreign currency fluctuations, interest rates. Evergreen derivatives don’t control risks that depend on unknown time-dependent factors. They depend on G = set of relations. This is a time-independent known object.

7 Abstract problem: Pricing of derivative Pricing of following derivative D(G): option to get for free one batch of raw material of type G (details of batch unknown) and the option to sell the finished product made of the raw material within one day of receipt of the raw material at a price proportional to the quality of the finished product. all prices are in [0,1] (million dollars).

8 Concrete Problem batch of raw material of type G –G-formula F finished product –assignment J for G-formula F plus F quality of finished product –satisfaction ratio of assignment J for F

9 Questions How much is D(G) worth for a given G?

10 CNF: a simple language Program = Expression. Expression : LetExp | CNF. LetExp = Literal Expression. CNF = List(Clause). Clause = Weight Body. Body : Literals | Sat | Unsat. Sat = “sat”. Unsat = “unsat”. Literals = List(Literal). Literal : Pos | Neg common Variable. Variable = Ident. Pos =. Neg =. List(S) ~{S}.

11 Values expressed values –possible values of expressions CNF (results of reductions) denoted values –values bound to variables Literal (assignment)

12 Environments store values associated with each variable

13 Let expression (value-of (LetExp lit body) s) = (value-of body [lit] s)

14 CNF (value-of (CNF clauses sat unsat) [l] s) = (CNF clauses1 sat1 unsat1) (value-of (Clause weight literals)[l] s) = (Clause weight1 body)

15 Exercise 1.17 (down lst) wraps parentheses around each top-level element of lst. solution: –from list:List to r:topLevel(list) replace r by (list r)

16 Exercise 1.27 (flatten slist) solution: from Root to p:Primitive collect p into list notice generalization: flatten other structures than lists

17 Help with project 2 Understanding code: find the data abstractions Data abstraction: separate interface from implementation

18 Interface for a class dictionary Constructors: LetExp(Literal,Expression) –Clause_PList(Nonempty_Clause_PList) Accessors: LetExp: –Literal get_assignment(), –Expression get_body() Parser: static LetExp.parse() Printer (needs a bit of code because PrintVisitor is provided) similar for other visitors

19 For phases 3 and 4: List Structure List(X) X_ListNonEmpty_X_List first next X it

20 Iterating through a DemeterJ list Have an X_List xlist; java.util.Enumeration en = xlist.elements(); while (en.hasMoreElements()) { if (e.equals((X) en.nextElement())) { found = true; } found = false; } Enumeration Interface boolean hasMoreElements(); Object nextElement();

21 Iterating through a DemeterJ list: in class X_List public java.util.Enumeration elements() { return new X_List(first); } public Object nextElement() { X car = first.get_it(); first = first.get_next(); return (Object) car; }

22 Iterating through a DemeterJ list: in class X_List public boolean hasMoreElements() { return (first != null); }

23 Enumeration interface is old fashioned Use Iterator interface instead –boolean hasNext(); –Object next(); –void remove(); (optional operation) Compare to Enumeration Interface boolean hasMoreElements(); Object nextElement();

24 Enumeration interface is old fashioned ListIterator is a subinterface of Iterator –boolean hasNext(); –Object next(); –void remove(); (optional operation) –add, hasPrevious, previousIndex, nextIndex, previous, set

25 Java documentation The functionality of the Enumeration interface is duplicated by the Iterator interface. … shorter method names... New implementations should consider using Iterator in preference to Enumeration.

26 Traversal with a ListIterator void traverse_maxSize(IntegerRef m){ for (ListIterator i=this.listIterator(); i.hasNext();) { DirectoryEntry de = (DirectoryEntry) i.next(); de.traverse_maxSize(m); }

27 How can you get an Iterator? Interface Collection: –Iterator iterator(); Example: –class Vector implements interface List –interface List extends interface Collection –Therefore: Use the Iterator interface to go through a vector

28 Context switch: Keep it simple with XML

29 XML Elements have Content Elements can have different content types. An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can have element content, mixed content, simple content, or empty content. An element can also have attributes. We use only: element content and simple content.

30 Others, including the official XML authors Are for simplification.

31 From w3schools An expanded date element is used in the third: (THIS IS MY FAVORITE): 12 11 2002 Tove Jani Reminder Don't forget me this weekend!

32 From the w3schools website Avoid using attributes? Should you avoid using attributes? Some of the problems with using attributes are: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data.

33 Don't end up like this (this is not how XML should be used): <note day="12" month="11" year="2002" to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!">

34 From the official XML tutorial http://www.w3schools.com/xml/xml _attributes.asp There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data.

35 Based on the w3schools recommendation We decide to use only a subset of XML We use elements and no attributes. The elements either have element content or simple content. The simple content is either an Ident, a String or a Text or any of the primitive types of Java (int, float, etc.) and their corresponding wrapper classes (Integer, Float, etc.)


Download ppt "Software Development CSU 670 Fall 2007 Karl Lieberherr."

Similar presentations


Ads by Google