-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classes and Types for EventStream Puzzler #128
base: kameron-eventstream-puzzler
Are you sure you want to change the base?
Conversation
src/models/eventstream.ts
Outdated
import { AppEvent } from "./appevent"; | ||
|
||
export class EventStream { | ||
events: AppEvent[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious if this is an appropriate way to assign a type to a variable. AppEvent is a class - would it be better to define an interface or type that defines the type that events should be?
src/types.ts
Outdated
@@ -0,0 +1,10 @@ | |||
export interface AppEventInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between interface and type?
why would you use one versus another, in typescript? based on this, does it make sense to define these as types, or interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to types, primarily because interfaces can be "merged" together which could be unexpected
…files, and tests no longer needed
src/models/highestregionlocator.ts
Outdated
import { Region } from './region' | ||
import { EventStream } from '../types' | ||
|
||
export class HighestRegionLocator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed filename to camel case
src/index.test.ts
Outdated
@@ -1,7 +1,91 @@ | |||
//write tests here | |||
// import { AppEvent } from './models/appevent' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code removed
src/index.test.ts
Outdated
const eventStream: EventStream = sampleData | ||
|
||
it ('instantiates a HighestRegionLocator object', () => { | ||
const highestRegionLocator = new HighestRegionLocator(eventStream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to test instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unneeded instance test
src/models/region.ts
Outdated
|
||
export class Region { | ||
regionEvents: AppEvent[] = [] | ||
score: number = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed score member variable as it was not being used and won't be needed
What this is:
models/highestregionlocator.ts
defines a class that receives an event stream and will have a method that can locate the highest region in the datasetlocateHighestRegion()
function exists as a placeholder and will throw an error if calledmodels/region.ts
defines a class that can add up the scores of the app events that are added to itindex.ts
now has a main function and a console.log as a placeholder to verify it is being called when the program is being runtypes.ts
defines types for AppEvents, EventStream data, and the dictionary for the Scores classindex.test.ts
defines high-level tests for validating that the classes created above successfully interface with each otherIssue:
N/A
Media:
EventStreamPuzzler.mov
Steps to Verify:
yarn install
yarn test