-
Notifications
You must be signed in to change notification settings - Fork 64
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
Livvy H Airport Challenge #171
base: main
Are you sure you want to change the base?
Conversation
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.
Code self review
@@ -0,0 +1,12 @@ | |||
class Plane { |
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.
WWW - glad I managed to implement classes and use a plane class which I think is fairly decoupled from the airport class.
getId() { | ||
return this.id; | ||
} | ||
|
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.
EBI - I ran out of time to complete the final user story, but I considered that I could add a property to the plane class that indicates if a plane instance is landed or in flight. Also considered adding a property to indicate which airport a plane is landed at (if landed) or headed towards, but wasn't sure how to do this without more tightly coupling the plane and airport classes. I'd like to look into how I could do this.
this.hangar = plane; | ||
this.#maxCapacity = capacity; | ||
this.weather = weather; | ||
} |
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.
www - implemented at least one private property.
EBI - wasn't able to make certain functions work when all properties were private, especially when trying to access properties from the plane class through the airport.
Goals - to learn more about private properties and when to implement them, in addition to how it can work between classes.
this.weather = weather; | ||
} | ||
|
||
getWeather() { |
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.
EBI - Think the getWeather() function is unnecessary as it is not directly used. Could be removed for cleaner code
} | ||
|
||
changeWeather(weather) { | ||
weather === 'Stormy' ? this.weather = 'Stormy' : weather === 'Clear' ? this.weather = 'Clear' : console.log(`Please enter valid weather conditions. Valid conditions are 'Clear' or 'Stormy'.`); |
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.
This ternary statement might be too complicated, may have been clearer to just use if... else to make code easier to read.
} | ||
|
||
landNewPlane(plane) { | ||
this.hangar.includes(plane) ? console.log(`${plane.id} has already landed and is on standby for departure.`) : this.getWeather() === 'Stormy' ? console.log("Landing denied due to adverse weather conditions, please divert.") : |
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.
EBI - this should be cleaner, if..else might be clearer code or at least each statement should be separate eg:
question? option a
: option b
: option c
const Airport = require(`./Airport`); | ||
const Plane = require(`./Plane`); | ||
|
||
const Voyager = new Plane('Voyager'); |
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.
Instead of defining plane instances in the index, perhaps could have had a class/object with an array of 'active planes' which defines and holds plane objects independently of airport instances. This would simplify the test code as well as the index as no need to define plane instances for each new airport or plane landing.
@@ -0,0 +1,10 @@ | |||
console.log(`RUNNING ALL TESTS`); |
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.
Goals - Make use of third party testing programs eg Jasmine
console.log(`RUNNING ALL TESTS`); | ||
console.log(`------------------------------------------------------`); | ||
console.log(``); | ||
|
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.
EBI - consider naming conventions at the start, as I decided to redistribute my tests into new files half way through for clarity as my original naming convention became confusing as more tests were added.
console.log(`USER STORY 1 TESTS`); | ||
console.log(`----------------`); | ||
console.log(``); | ||
|
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.
EBI/Goals - more testing for outliers and erroneous inputs. I improved at this in later user stories but earlier ones testing was limited, if I had more time I would have gone back and added more tests to the earlier user stories - eg in user story one additional tests could include:
- Ensure plane landed in airport is a plane object, throw error if not a plane object
- Does plane have valid plane Id
- Testing new instance of airport with default values, does this produce an airport object as expected
No description provided.