Docsity

Final Project in Software Design - Software Design and Implementation | COMP 723, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Final project in Software Design, COMP723
Fall 2007; Megha Pandey and Jens Rantil
Table of Contents
Final project in Software Design, COMP723............................................................................................1
Design Goals......................................................................................................................................... 3
Use cases/Workflow..............................................................................................................................3
UML diagram........................................................................................................................................7
Design Patterns......................................................................................................................................8
Timeout Proxy for the login sessions............................................................................................... 9
Facade for Election Statistics............................................................................................................9
Mediator for answers to questions....................................................................................................9
Prototype for Ballot and underlying data structures.........................................................................9
Memento in Ballot..........................................................................................................................10
Factory for Authentication of users and voters...............................................................................10
Chain of Responsibility to handle privileges for elections.............................................................10
Composite to handle region specific elections............................................................................... 11
Factory for candidacy to check creation authentication................................................................. 11
Factory for election officer authentication......................................................................................11
Factory for administrator authentication.........................................................................................11
CRC cards / Description of major classes...........................................................................................12
UserLoginSession...........................................................................................................................12
Responsibilities..........................................................................................................................12
Collaborators..............................................................................................................................12
VoterLoginSession..........................................................................................................................12
Responsibilities..........................................................................................................................12
Collaborators..............................................................................................................................12
Users...............................................................................................................................................12
Responsibilities..........................................................................................................................12
Collaborators..............................................................................................................................12
Voters..............................................................................................................................................12
Responsibilities..........................................................................................................................12
Collaborators..............................................................................................................................12
File..................................................................................................................................................12
Responsibilities..........................................................................................................................12
Collaborators..............................................................................................................................12
ElectionStats................................................................................................................................... 13
Responsibilities..........................................................................................................................13
Collaborators..............................................................................................................................13
ElectionList.....................................................................................................................................13
Responsibilities..........................................................................................................................13
Collaborators..............................................................................................................................13
QuestionField..................................................................................................................................13
1 of 19
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Final Project in Software Design - Software Design and Implementation | COMP 723 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Fall 2007; Megha Pandey and Jens Rantil

  • Final project in Software Design, COMP
  • Final project in Software Design, COMP723............................................................................................ Table of Contents
    • Design Goals.........................................................................................................................................
    • Use cases/Workflow..............................................................................................................................
    • UML diagram........................................................................................................................................
    • Design Patterns......................................................................................................................................
      • Timeout Proxy for the login sessions...............................................................................................
      • Facade for Election Statistics............................................................................................................
      • Mediator for answers to questions....................................................................................................
      • Prototype for Ballot and underlying data structures.........................................................................
      • Memento in Ballot..........................................................................................................................
      • Factory for Authentication of users and voters...............................................................................
      • Chain of Responsibility to handle privileges for elections.............................................................
      • Composite to handle region specific elections...............................................................................
      • Factory for candidacy to check creation authentication.................................................................
      • Factory for election officer authentication......................................................................................
      • Factory for administrator authentication.........................................................................................
    • CRC cards / Description of major classes...........................................................................................
      • UserLoginSession...........................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • VoterLoginSession..........................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • Users...............................................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • Voters..............................................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • File..................................................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • ElectionStats...................................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • ElectionList.....................................................................................................................................
        • Responsibilities..........................................................................................................................
        • Collaborators..............................................................................................................................
      • QuestionField..................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • User.................................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Voter................................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Authentication.................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • DocumentHolder.............................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Ballot..............................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • VoterVote........................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • UserAnswers...................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • ElectorateInfoRule..........................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Question..........................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Election...........................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Candidacy.......................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • ElectionOfficer...............................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
    • Administrator..................................................................................................................................
      • Responsibilities..........................................................................................................................
      • Collaborators..............................................................................................................................
  • Discussion...........................................................................................................................................
    • Voter vs. user..................................................................................................................................
    • Flexible answers.............................................................................................................................
    • Design Pattern for User..................................................................................................................
    • Design Trade-offs and other notes..................................................................................................
  1. User selects one of the ongoing elections and is presented with a ballot for that particular election. User can access relevant documents anytime during the session. User makes his/her choices and presses final to submit the vote. If the vote is invalid it is not accepted by the system and user is asked to cast his vote again. Once the vote has been submitted, the user is given the option to print or save the list of choices he/she made. This list won’t contain any information concerning the voter’s identity.
  2. A voter who has already submitted his/het vote logs on to the system and votes again. The vote will be accepted by the system and earlier choices will be replaced by the ones made most recently.
  3. A registered admin logs on to the system and is presented with a list of recently made changes to the system(possibly by other administrators in the election body). a. Add election: Create a new ballot, upload relevant documents (ballot and informa- tion about each of the options), set up an expiry date for the election, make ballot ac- cessible to the ones allowed to participate on the day election opens. b. Modify/remove election: remove a cancelled election, make changes to forthcoming elections if any are required. No one is allowed to make any changes to an ongoing election.
  4. Candidate A registered user logs in to the system and chooses one of the elections for which application for candidacy is open and applies for candidacy. If found eligible, he/she is registered as a candidate and asked to upload required information and a manifesto.
  5. A registered candidate is allowed to withdraw from the elections until some deadline.
    1. An administrator logs in, verifies the eligibility of candidacy applicants, registers the eligible candidates and updates CandidateLis t for corresponding election.
    2. An administrator logs on to the system and adds/removes a new election officer.
    3. An administrator logs onto the system and add/removes a new administrator.

Start VoterLogin Authentication Not Registered Stop VoterLoginSession Voter GetBallot Election BrowseDocuments DocumentHolder SubmitVote VoterVote VoteList ChangeVote ViewResult ElectionStats Logout Stop SaveAs Update

UML diagram

+AuthenticateIdentity() +CreateAdminLoginSession() +CreateEOLoginSession() +CreateCandidateLoginSession() +CreateVoterLoginSession() Authentication +AddUser() +DeleteUser() +UpdateUserInfo()

  • User UserList +AddVoter() +DeleteVoter() +UpdateVoterInfo() - Voter VoterList +Login() «interface» VoterLogin +BrowseDocuments() +GetElectionList () +GetBallot() +SubmitVote() +ChangeVote() +GetReceipt() +ViewResults() +SessionTimeout()
  • ProxyVoter VoterLoginSession +BrowseDocuments() +GetElectionList () +GetBallot() +SubmitVote() +ChangeVote() +ViewResults() +GetReceipt()
  • VoterID
  • GeographicalInfo
  • Timestamp Voter +AddUser() +DeleteUser() +UpdateUserInfo()
  • User UserList +AddVoter() +DeleteVoter() +UpdateVoterInfo()
  • Voter VoterList +Login() «interface» UserLogin UserLoginSession +UploadDocuments() +Withdraw()
  • ElectionName Candidate +RegisterEO/Admin() +Delete EO/Admin() +RegisterCandidate() +DeleteCandidate() +AddElection() +ModifyElection() Administrator +RegisterVoter() +DeleteVoter()
  • Region ElectionOfficer +BrowseDocuments() +RunForElections()
  • Name
  • UserID
  • Password
  • Address
  • DateOfBirth RegisteredVoter +AuthenticateIdentity() +CreateAdminLoginSession() +CreateEOLoginSession() +CreateCandidateLoginSession() +CreateVoterLoginSession() Authentication User User can be either a registered voter, a candidate, an election officer or an administrator

+GetElectorate()

  • ElectionName
  • Region
  • Ballot
  • Dates
  • Electorate
  • Documents Election
  • Election ElectionList +isEligible (in user)
  • NextRule ElectorateRule +CreateMemento() +SetMemento()
  • QuestionMediator
  • Documents Ballot +SetField() +ChangeField()
  • Description
  • Answer QuestionMediator
  • Description QuestionField 1 1 ..* 1 1 ..* 1 1 1 1 ..* 1 +GetState() +SetState() UserAnswers 1 1 +SetAnswers() +ChangeAnswers() -VoterID -Timestamp -Receipt VoterVote +GetStats() -ElectionName ElectionStats «subsystem» StatGatherer 1 0..* -ElectionName -VoterVote VoteList +AddVoter() +DeleteVoter() +UpdateVoterInfo() -Voter VoterList 1 0..* File -File DocumentHolder Facade to different types of StatGatherers Composite Structure -Description Question 1 -Rule ConcreteRule +RegisterCandidate() +DeleteCandidate() -ElectionName -CandidateList CandidateList

The client making the copying/cloning of the ballots is Election, and this is done when a Ballot is requested from an Election instance. Prototype: Prototype ConcretePrototype: Ballot, Question,QuestionField Client: Election Memento in Ballot While working with a ballot requires having a working copy in memory it is only the values of the answers that are of interest when the voter is finished voting, the rest (like the Questions) are not relevant. To solve this problem every Ballot is a Memento where the current state can be extracted and saved separately. This way the program is much more memory efficient which is necessary as there are a lot of votes. The memento contains the answers but also a pointer to the election that the memento is extracted from. Originator: Ballot Memento: UserAnswers Caretaker: VoteList through VoterVote Factory for Authentication of users and voters A user have a handle (UserLoginSession or VoterLoginSession, depending on what login) that is the base handle used to perform all the requests when logged in. But the creation of these handles goes through the process of authentication (user name and password, or a voter id). This process of authentication is centralized in two factories (depending on what login type). If login fails the Factories return null or throws an error. Because authentication to log into the two systems might be quite similar they are placed in the same (static) class, Authentication. ConcreteProduct: UserLoginSession ConcreteCreator: (static) Authentication.userLogin(user, pass) Table 1 : UserLoginSession factory. ConcreteProduct: VotedLoginSession ConcreteCreator: (static) Authentication.voterLogin(voterId) Table 2 : VoterLoginSession factory.

Chain of Responsibility to handle privileges for elections Every Election instance holds a chain of rules of who is eligible to vote. Every such rule implements the interface ElectorateRule, that is a node in that chain. To see if a User instance is eligible to vote in the election a function isEligible() is called down the chain of electorate rules. If anyone of them returns true the user is eligible, else not. Handler: ElectorateRule ConcreteHandler: Ex: ElectorateRuleAge, ElectorateRuleGeo Client: Election Composite to handle region specific elections Elections are most of the time made in different regions, in US for example national election, state election and county elections. An easy way of represent this is through the composite design pattern. As every election basically does the same thing except in different regions, every election is a Component in the Election tree. The top-most (root) Election in the tree is the national election. The bottom ones could be counties. Composite: Election Client: undefined Comment: While Design Patterns: Elements of Reusable Code refers to Leaf and Composite our Composite Design pattern does not distinguish between the two. A leaf is simply a Composite without any children. Factory for candidacy to check creation authentication In our design everyone that are elligible to vote are allowed to suggest themselves as candidates. If a more complex rule system than this would be required it would have been implemented in the similar fashion as the ElectorateRule Chain of Responsibility. A factory (static function in candidacy) takes a user and returns a Candidacy object if the user is elligible to go up for candidacy. Factory for election officer authentication A factory that takes a username and password and returns an ElectionOfficer instance if the user has election officer privileges. ConcreteProduct: ElectionOfficer ConcreteCreator: (static) ElectionOfficer.get(user, pass) Factory for administrator authentication A factory that takes a username and password and returns an ElectionOfficer instance if the user has

File Responsibilities  Holds MIME/filetype and file Collaborators ElectionStats Responsibilities  Facade to different classes gathering statistics. Collaborators  Classes that contain statistics  Election ElectionList Responsibilities  Holds, removes, retrieves and adds elections Collaborators  Election QuestionField Responsibilities  Decorator, prototype  Holds an answer and controls how this specific answer interacts with the other answers.  Holds information about the different possible answers via DocumentHolder Collaborators  QuestionField  DocumentHolder  File

User Responsibilities  Holds username and password  Keeps track of registered or not  Methods for authentication (add/check/drop privileges (strings)) Collaborators Voter Responsibilities  An anonymous voter  Created when a user registers as a voter  Holds a voter ID number  Holds geographic information about the voter  Implements a method that that returns a list of the ongoing elections that the user is eligible to vote in. Collaborators  ElectionList Authentication Responsibilities  Factory returning a UserLoginSession on successful login  ...or...  Factory returning a VoterLoginSession on successful login Collaborators  UserLoginSession  VoterLoginSession

UserAnswers Responsibilities  Memento in the Memento Design Pattern (holds all the answers for a ballot) Collaborators  Ballot ElectorateInfoRule Responsibilities  Handler (in Chain of Responsibility) specifying rules for who is allowed to vote. Collaborators  ElectorateInfoRule  Voter Question Responsibilities  Prototype  Return answer data Collaborators  QuestionField  DocumentHolder  File Election Responsibilities  Composite (region)  Holds a ballot  Holds electorate information (who's allowed to vote)  Holds dates  Holds the votes  Holds a list of candidates Collaborators  Ballot  ElectorateInfoRule  DocumentHolder  File  Election  Candidate

Candidacy Responsibilities  (Static) Factory to create a Candidacy object from a User object if sufficient privileges and not exist  Holds documents relevant for candidacy Collaborators  User  DocumentHolder ElectionOfficer Responsibilities  (Static) Factory to create an ElectionOfficer object from a User object if sufficient privileges  Registers voters  Register candidates  Delete voters Collaborators  User Administrator Responsibilities  (Static) Factory to create an Administrator object from a User object if sufficient privileges  Delete Candidates  Add Election  Modify Election  (Static) Factory to create an Administrator object  Register election officer or administrator  Remove an election or administrator Collaborators  User

could have added a specific list of administrators and had an own login for them individually. This would have been a lot more code, but maybe a more simple system.  Statistics are not gathered in real time, which will make the statistics gathering more computational exhaustive. This decision has been made because of the possibility to change the votes. Two solutions to this problem are:  Compute the final statistics when the election is over.  Implement a caching Proxy design pattern for the ElectionStats class.  The prototype of a Ballot might require a lot of memory usage until the vote it sent and because the questions  There are a lot of Mementos of votes. These could be FlyWeight:ed if they take up a lot of space.