Skip to content

Onboarding finished#31

Open
YuveerMaharaj wants to merge 2 commits into
IMQS:masterfrom
YuveerMaharaj:master
Open

Onboarding finished#31
YuveerMaharaj wants to merge 2 commits into
IMQS:masterfrom
YuveerMaharaj:master

Conversation

@YuveerMaharaj

Copy link
Copy Markdown

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
Comment thread app.ts Outdated
window.onload = () => GetColumnNames();

//Variable declarations
let totalRecordCount;

Copy link
Copy Markdown

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.

Comment thread app.ts
$.ajax({
url: "/recordCount",
type: "GET",
timeout: 12000,

@jasonkofo jasonkofo Nov 14, 2019

Copy link
Copy Markdown

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.

Comment thread app.ts Outdated
}

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

Copy link
Copy Markdown

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?

Comment thread app.ts Outdated
}

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

Copy link
Copy Markdown

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?

Comment thread app.ts
}

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

Copy link
Copy Markdown

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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

replace with arrow function

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

replace with arrow function

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

replace with arrow function

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

Copy link
Copy Markdown

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'.

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

Copy link
Copy Markdown

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"

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

arrow function

Comment thread app.ts

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

Copy link
Copy Markdown

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

Comment thread app.ts
}

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

Copy link
Copy Markdown

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

Comment thread app.ts
}

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

Copy link
Copy Markdown

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) { ... }

Comment thread app.ts

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

Copy link
Copy Markdown

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