Skip to content
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

feature/ATC-181 #236

Merged
merged 34 commits into from
Jan 23, 2017
Merged

feature/ATC-181 #236

merged 34 commits into from
Jan 23, 2017

Conversation

n8rzz
Copy link
Owner

@n8rzz n8rzz commented Dec 22, 2016

completes #181

Creates AircraftCommander class to run commands on an AircraftInstance

resolves both #254 and zlsa#777

…an AircraftInstance

* Removes commands section in AircraftInstanceModel
* Adds AircraftCommander instance to App that gets passed into
* InputController
* Removes no-undef rule from .eslintrc
@n8rzz n8rzz added this to the v3.3.0 milestone Dec 22, 2016
@n8rzz n8rzz requested a review from erikquinn December 22, 2016 02:59
@n8rzz n8rzz added refactor and removed feature labels Dec 23, 2016
Copy link
Collaborator

@erikquinn erikquinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. You're sure you like this abstraction? Everything makes sense, it just seems strange to me. If you like it this way, it definitely works for me... just curious. 😄

@n8rzz
Copy link
Owner Author

n8rzz commented Dec 30, 2016

@erikquinn as I'm sure you've gathered already, I'm a big fan of small classes with a single concern. The current AircraftInstanceModel is a behemoth, this is a step in the right direction toward slimming that down.

I have many thoughts on this abstraction that we can talk about at a later date. TL;DR this is a step in the direction of centralizing command of an aircraft, reducing the scope of the AircraftInstanceModel and making things more testable. Though we're not there yet with this abstraction, its a step in that direction.

note: this won't be merging for a while, I just wanted to get it in front of your eyes sooner rather than later because of the scope of the change here.

@erikquinn
Copy link
Collaborator

@n8rzz Right, and I'm all for all of that. Why not plug it in soon? At least it would chop the aircraft monstrosity into slightly more bite-size pieces, and a later and better reorganization could always be done. This works though, I'd be fine with the change-- any reason you actively want to hold off on it?

@erikquinn erikquinn added the WIP label Dec 31, 2016
@n8rzz
Copy link
Owner Author

n8rzz commented Dec 31, 2016

@erikquinn I'd like to hold off because I had planned on @Dabea doing some method clean up and simplifications. Buuuut, I think that would probably be better accomplished under a new issue.

At the very least I'll hold off merging until we're done with #243 so as to avoid any conflicts.

* @method aircraftTurnPhysics
* This turns the aircraft if it is not on the ground and has not arived at its destenation
*/
aircraftTurnPhysics() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are updating aircraft properties, be sure to stay consistent with your naming. This method should likely be called updateAircraftTurnPhysics

/**
* @for AircraftInstanceModel
* @method aircraftTurnPhysics
* This turns the aircraft if it is not on the ground and has not arived at its destenation
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure descriptions are at the top of your doc blocks


if (abs(offset) < turn_amount) {
this.heading = this.target.heading;
} else if ((offset < 0 && this.target.turn === null) || this.target.turn === 'left') {
Copy link
Owner Author

@n8rzz n8rzz Jan 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is null a valid value for this.target.turn? It could be, there are nulls all over the place when there really shouldn't be (but that is a different issue).

In javascript, null is actually an object. when doing comparisons like this.target.turn === null you are actually checking to see if that property equals the null object. That may be different that what you are expecting. If this.target.turn is initialized as '' that comparison won't work as expected here because an empty string is not equal to null.

This is likely correct, but I wanted to call that out just in case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to look further in to it. That was the original logic, I will need to trace it back a little to see if it needs a null or ' '.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly certain it is set to either 'left', 'right' or null whenever a turn is assigned. So the comparison should be okay, provided that the logic used within the fms during runHeading hasn't been changed in this regard. If in doubt, maybe a lodash _isNil() would do the trick?

@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 15, 2017 04:56 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 15, 2017 07:52 Inactive
@Dabea Dabea removed the WIP label Jan 15, 2017
@Dabea
Copy link
Collaborator

Dabea commented Jan 15, 2017

I fixed the merge conflicts and tested and everything looks good, and should not break anything once it is merged with develop.

Copy link
Owner Author

@n8rzz n8rzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of little changes for you with docblocks.

One thing you'll notice, I'm a big fan of early returns. Try hard to avoid else if or else statements whenever possible. Often times there is a way to structure the logic so you don't ever need either of the elses. It also makes the code easier to read and way easier to test.

I like the length of your comments, not too long and right to the point. I think, though, that in some cases you are missing the meat of the methods you are trying to describe. This is something I struggle with constantly, what makes a good comment?

I setup a review app, though I haven't tested this yet. I will try to do that tonight. If I run into any issues, I'll add those here.

Other than the changes I called out, this is coming along nicely. You've made some good abstractions and some nice simplifications. I like where this is heading!

const runway = window.airportController.airport_get().getRunway(this.rwy_arr);
if (this.fms.currentWaypoint.navmode !== WAYPOINT_NAV_MODE.RWY) {
this.fms.setCurrent({ runway: null });
return false;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure to include an empty line above a return statement

@@ -2254,6 +1196,51 @@ export default class Aircraft {
}
}

/**
* This will display a waring and record an illegal approach event
* @for AircraftInstanceModel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure to include an empty line between comments and docblock parameters


/**
* This will display update the fix for the aircraft
* @for AircraftInstanceModel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line

}

/**
* This will display update the fix for the aircraft
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the wording here is confusing, what is this doing exactly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I really had a had time with giving this one a correct name and as well for the comment especially because it is for the FIX command where you change the target heading,

As writing this comment to you I think I found the answer to the strugle

*/
updateFixTarget() {
const fix = this.fms.currentWaypoint.location;
if (!fix) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be sure to include an empty line above if blocks

let difference = null;

if (this.target.speed < this.speed - 0.01) {
difference = -this.model.rate.decelerate * window.gameController.game_delta() / 2;

if (this.isOnGround()) {
// What is 3.5 is this restiance/breaking power?
difference *= 3.5;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erikquinn what is 3.5 here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't the foggiest. I'll see if I can figure it out...


/**
* This calculates the ground speed
* @for AircraftInstanceModel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line

const isInsideAirspace = this.isInsideAirspace(window.airportController.airport_get());
/**
* This calculates the simplify ground speed
* @for AircraftInstanceModel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing empty line

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added line


const isInsideAirspace = this.isInsideAirspace(window.airportController.airport_get());
/**
* This calculates the simplify ground speed
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is confusing. what exactly are we doing with this method?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to
"This uses the current speed information to update the ground speed and position"

That is more clear, Any recommendations for improvement?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that, that is a little more descriptive





Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these empty lines

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 18, 2017 09:57 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 18, 2017 10:15 Inactive
@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 18, 2017 10:19 Inactive
aircraft.taxi_start = this._gameController.game_time();
const runway = this._airportController.airport_get().getRunway(aircraft.rwy_dep);

runway.addQueue(this);
Copy link
Owner Author

@n8rzz n8rzz Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dabea This one is my fault :-(

This line prevents the aircraft info box from appearing when an aircraft has finished taxiing and is first in line to takeoff.

Having abstracted these commands away from the AircraftInstanceModel, why is this line now incorrect? What should be done to fix it?

@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 22, 2017 07:09 Inactive
n8rzz added 2 commits January 22, 2017 22:48
…TC-181

Conflicts:
- src/assets/scripts/client/aircraft/AircraftInstanceModel.js
@n8rzz n8rzz temporarily deployed to atc-dev-pr-236 January 23, 2017 04:50 Inactive
@n8rzz n8rzz changed the title [WIP] feature/ATC-181 feature/ATC-181 Jan 23, 2017
@n8rzz n8rzz merged commit 64a565a into develop Jan 23, 2017
@n8rzz n8rzz deleted the feature/ATC-181 branch January 23, 2017 05:31
@n8rzz n8rzz mentioned this pull request Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants