Skip to content

Conversation

@YuveerMaharaj
Copy link

No description provided.

@nkosimarz nkosimarz requested review from FritzOnFire, Winston-Guess, bmharper, jasonkofo and nkosimarz and removed request for bmharper November 14, 2019 10:22
app.ts Outdated
window.onload = () => GetColumnNames();

//Variable declarations
let totalRecordCount;

Choose a reason for hiding this comment

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

Just as a matter of design, I would rather you not use these methods to write to global variables. It's difficult to see the danger of using global variables in the scope of this onboarding project; but imagine if you had 100 different files or editing the same variable (if you had chosen to export this variable and make it truly global) - or even if the file was bigger and all the different sections of the code were all making changes to this one lonely variable. Imagine the bugs that would break out right through your system.

The issue is not even that you are using them in this space, because here I would suppose they are fine, but the issue is that your methods are making changes to the same variable. While in Typescript/Javascript, this may not necessarily be a problem because the language is single threaded (you will learn what that means as you grow in your career), in other languages this could prove very challenging to solve bugs.

$.ajax({
url: "/recordCount",
type: "GET",
timeout: 12000,
Copy link

@jasonkofo jasonkofo Nov 14, 2019

Choose a reason for hiding this comment

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

Quite a long timeout you've got there, considering the server runs on the same machine as your front-end code - but I must commend the awareness that you are demonstrating.

app.ts Outdated
}

//Function to sync API calls
function Sync() {

Choose a reason for hiding this comment

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

I don't understand why you're wrapping this single method in another single method? Why not just call getActualRecords directly?

app.ts Outdated
}

//Function to sync API calls
function NextSync() {

Choose a reason for hiding this comment

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

Same as above, why not just call BuildTable directly?

}

//Pages backwards through data in increments of 30
function PreviousPage() {

Choose a reason for hiding this comment

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

once again, these methods make calls to the global variables in this scope even though it isn't class based.

app.ts Outdated
columnNames = responseJSON;
Sync();
})
.fail(function() {

Choose a reason for hiding this comment

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

replace with arrow function

app.ts Outdated
timeout: 12000,
dataType: "JSON"
})
.done(function(responseRecords: any) {

Choose a reason for hiding this comment

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

replace with arrow function

app.ts Outdated
records = responseRecords;
NextSync();
})
.fail(function() {

Choose a reason for hiding this comment

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

replace with arrow function

app.ts Outdated
url: "/columns",
type: "GET",
timeout: 12000,
dataType: "JSON"

Choose a reason for hiding this comment

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

Let's use lower case 'json' rather than upper case 'JSON'.

$.ajax({
url: "/records?from=" + from + "&to=" + to,
timeout: 12000,
dataType: "JSON"

Choose a reason for hiding this comment

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

lower case "json" rather than upper case "JSON"

timeout: 12000,
dataType: "text"
})
.done(function(responseText: any) {

Choose a reason for hiding this comment

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

arrow function


//Pages backwards through data
function PreviousPage() {
let NumberOfRows = Math.floor((window.innerHeight - 50) / 24) - 1;

Choose a reason for hiding this comment

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

const same applies to quite a few other lets

For reference: https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75

}

function restrictAlphabets(e: any) {
var x = e.which || e.keycode;

Choose a reason for hiding this comment

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

var and x isn't a great name

}

//Cells are created and populated with data
for (let i = 0; i < records.length; i++) {

Choose a reason for hiding this comment

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

Use new for loop methods from style guide

i.e. for (const key in records) { ... }
or for (const record of records) { ... }


//Variable declarations
let totalRecordCount: number;
let columnNames: any[];

Choose a reason for hiding this comment

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

const see comment further down

@FritzOnFire FritzOnFire removed their request for review November 27, 2019 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants