1 / 13

Assignment 1 - Requirements Elicitation and Documentation

Assignment 1 - Requirements Elicitation and Documentation. Shuai Wang shuai.wang@inf.ethz.ch. Schedule. Three hours session (tentatively decide in this way): Some tutorial and Q&A on the first assignment Q&A (if needed) for the second assignment Q&A (if needed) for the group project.

nfernando
Download Presentation

Assignment 1 - Requirements Elicitation and Documentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 1 - Requirements Elicitation andDocumentation ShuaiWang shuai.wang@inf.ethz.ch

  2. Schedule • Threehourssession(tentativelydecideinthisway): • SometutorialandQ&Aonthefirstassignment • Q&A(ifneeded)forthesecondassignment • Q&A(ifneeded)forthegroupproject. • Canweputalltheteammembersintooneexercisesession? • Notpossibleforthewholeclass,sorry. • ContactTAsincaseyouhaveanyquestionsorwanttomakeanychangestothegroupingandexercisesessionASAP. • Wearecollectingandmaintaininganinternallistofallthegroupinginfo.Andwillupdateonlinelatethisweek,afterfinishingalltheexercisesessions. • Anyoneknowsthefollowingstudents? • Manuela Fischer • HaoWu

  3. Exercise 1 - Design and Documentation publicclass Node{ public Node () {...} ... } publicclassEdge{ ... } publicclassSTGraph{ List <Edge> edges; Node source;Node target; publicSTGraph(Node source, Node target){ this.source = source; this.target = target; this.edges = newArrayList <Edge>(); } publicvoidsetST(Node source , Node target){ this.source = source; this.target = target; } publicvoidaddEdge(Edge e){ edges.add(e); } publicList <Node> shortestPath () {...} } Passing the sourceand the target as arguments Question:whythisdesigndecisionmakessense? Using a settermethod for modifying them afterwards • Butnofreelunch! • Isthisthread-safe? Answer:onlyifwewould rarely modifysource and the target

  4. Exercise 1 - Design and Documentation publicclass Node{ public Node () {...} ... } publicclassEdge{ ... } publicclassSTGraph{ List <Edge> edges; Node source;Node target; publicSTGraph(Node source, Node target){ this.source = source; this.target = target; this.edges = newArrayList <Edge>(); } publicvoidsetST(Node source , Node target){ this.source = source; this.target = target; } publicvoidaddEdge(Edge e){ edges.add(e); } publicList <Node> shortestPath () {...} } Answer:ofcourseno;onlyifthesourceandtargetareconnected. Question:doestheshortest path always exist? • Answer:specifyreturnvaluesregardingdifferentcases. • Whatiftheyarenotconnected? • Whatifsourceisidenticaltotarget? • Exceptionornull? • Algorithm? • ... Question:whatinformationshouldbedocumentedforthisfunction?

  5. Exercise 1 - Design and Documentation publicclass Node{ public Node () {...} ... } publicclassEdge{ ... } publicclassSTGraph{ List <Edge> edges; Node source;Node target; publicSTGraph(Node source, Node target){ this.source = source; this.target = target; this.edges = newArrayList <Edge>(); } publicvoidsetST(Node source , Node target){ this.source = source; this.target = target; } publicvoidaddEdge(Edge e){ edges.add(e); } publicList <Node> shortestPath () {...} } Question:howtomakethisfunctionmoreefficient? Answer:cachetheresults. List <Node> shortestPath (){ if(sp == null && areConnectedST()){ sp = computeShortestPath(); } returnsp; } areConnectedST:BFS shortestPath:muchmorecomplicated?Dijkstraalgo.?

  6. Exercise 1 - Design and Documentation publicclass Node{ public Node () {...} ... } publicclassEdge{ ... } publicclassSTGraph{ List <Edge> edges; Node source;Node target; publicSTGraph(Node source, Node target){ this.source = source; this.target = target; this.edges = newArrayList <Edge>(); } publicvoidsetST(Node source , Node target){ this.source = source; this.target = target; } publicvoidaddEdge(Edge e){ edges.add(e); } publicList <Node> shortestPath () {...} } Question:How does this design influence the client-visible documentation? Answer:no,OOdesignusuallytreatsmethodsasblackboxs. • Answer:amore“eager”wayofdoingso. • Anyfundamentaldifference? Question:Are there alternative designs that achieve comparable results? Extension:cachetheintermediatecomputationresults?

  7. Exercise 2 - Design classList <E>{ E[] elems; intlen; boolean shared; List(int l){ elems = (E[]) new Object[l]; len = l; shared = false; } void set(int index , E e){ if(shared){ elems = elems.clone(); shared = false; } elems[index] = e; } List <E> take (){ shared = true; List<E>t=newList <E>(elems, len-1); t.shared=true; returnt; } } Question:a scenario in which this implementation performs unnecessary cloning operations, when the set method is called. Answer: List <Integer > A = new List <Integer>(3); List <Integer > B = A.take(); b.set(0,-5); a.set(1, 40); AandBarenot“synchronized”.

  8. Exercise 2 - Design classList <E>{ E[] elems; intlen; boolean shared; List(int l){ elems = (E[]) new Object[l]; len = l; shared = false; } void set(int index , E e){ if(shared){ elems = elems.clone(); shared = false; } elems[index] = e; } List <E> take (){ shared = true; List<E>t=newList <E>(elems, len-1); t.shared=true; returnt; } } Question:How could you modify the implementation to eliminate this inefficiency? Answer:syncAandBwithanobjectonheap. Extension:learnhow“smart-pointer”worksinC++11g.

  9. Exercise 2 - Design Question:Is your proposed solution efficient in the case in which unused objectsareremoved by the garbage collector? Answer:thepreviousimplementationcannot“decrease”thecounter.

  10. Exercise 2 – Design:ASimpleImplementationofModernC++SmartPointers https://codereview.stackexchange.com/questions/159804/c-smart-pointer-implementation

  11. Exercise 3 - Requirements Elicitation No authoritative solution to this exercise,buthopeithelpsforyoutogetsomesensesandthinkfurtheronhowtoeffectivelygatherrequirements.  role playing Scenarios

  12. Exercise 3 - Requirements Elicitation:CornerCases • Q:is an online customer logged out from the system automatically wheninactive? If so, after what time? • A:Yes. When the customer is inactive for 5 minutes, he/she is logged outautomatically. • Q:When a new customer creates an online account, can he place his firstorder to a different address than to which the credit card he is payingwith is registered? • A:No. This is a security measure placed in order to prevent frauds. • A:However,after the first order was placed and the flowers were delivered, the customercan change the delivery address in subsequent orders. • Q:Is there any limit on the number of orders that can be taken per day? • A:Yes. This number depends on the number of messengers the owner currently has. • Q:Is it possible to cancel an order once it has been placed? • What’syouridea?

  13. Letusknowifyouhaveanyquestionsorwouldliketodiscuss • ContactTAsincaseyouhaveanyquestionsorwanttomakeanychangestothegroupingandexercisesessionASAP. • Wearecollectingandmaintaininganinternallistofallthegroupinginfo.Andwillupdateonlinelatethisweek,afterfinishingalltheexercisesessions.

More Related