Skip to content

Instantly share code, notes, and snippets.

@bferreirainfo
Created January 5, 2017 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bferreirainfo/c1f7819ce43ce53f5bd36bc3a2d33855 to your computer and use it in GitHub Desktop.
Save bferreirainfo/c1f7819ce43ce53f5bd36bc3a2d33855 to your computer and use it in GitHub Desktop.
Response Inloco
We could abstract our solution in 5 steps
step 1: receive a goal and starts respective report
step 2: Read log line and identify event type(kill event, suicide event ,etc)
step 3: parse line based on event type
step 4: call respective computing behaviour from report(addKill(killer,killed),etc) passing parsed data.
step 5: parse reports data to output format and output result
Step 1: To package everything we can create a class "QuakeReportApp" that has the "main method" and is the front door of our app, it receives a goal like "game summary, ranking, web ranking " validate it comparing with constants - and as we are going to use these constants after we should put them in class QuakeReportGoals - if that goal is invalid, show error at console, if oks them starts a report X (X = is an implementation of report) determined by the goal.
Steps 2 to - yeah that happened - 5 : is the flux of read/process/output and is common to ours reports so we could abstract it with "ReportBuilderAbstract" and define all (2-5) steps behaviors. Steps 2,3 are common to game summary,ranking, so we can implement they at "ReportBuilderAbstract", other important
Step 2,3: this steps are all ready implement by ReportBuilderAbstract is common to all reports so no need to override it.
Step 4: Class GameSummaryReportBuilder is responsable for "Game Summary" goal and it should implements add Kill behaviour to count a kill to a player for each game , and to total kills. As ranking local and web has this step in common we can create Class RankingReportBuilderAbstract and it will implement add Kill count a kill to a player.
Step 5: Here all the data are stored in correct format by previous step, now we should take care that individually for each report. First we should implement GameSummaryReportBuilder to parse each player per game to a row and print on console.
after print all, print totalKills. Now RankingReportBuilder should extend RankingReportBuilderAbstract and implement step 5, with, first ordering by kills, then parse to a list of rows, this part could be placed atrankingReportBuilderAbstract, because is common to webRanking, we can call oderByKills, now our implementation of step 5 could use it, them parse to a list of text and output on console all item of the list, and print on console. WebRankingReportBuilder should extend RankingReportBuilderAbstract aswell use our oderByKills, but now parse our data to html format with data table and output to a folder (of a webapp, as our admin desire), we could use angular or other client side, but if think would be a little overkill for the problem in hand.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment