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

Fixes #163; Created new windowMaid.js #168

Merged

Conversation

codecounselor
Copy link
Collaborator

No description provided.

codecounselor added 2 commits February 9, 2017 17:45
… more robust window destruction. Destroyed windows can remain in memory, so that needs to be inspected. Also allow clients to remove windows from the cache explicitly fraserxu#163
@@ -18,11 +18,11 @@ class WindowMaid {
* When a job creates a window it invokes this method so any memory leaks
* due to hung windows are prevented. This can happen if an uncaught
* exception occurs and job.destroy() is never invoked.
* @param job
* @param exportJob the ExportJob instance, it must have a window reference set

Choose a reason for hiding this comment

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

Much clearer name. Nice

@mattsgarlata
Copy link

+1

// them
const windowCache = {}

class WindowMaid {

Choose a reason for hiding this comment

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

Great abstraction and name

Choose a reason for hiding this comment

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

It looks like everything in this class is accessed statically, so you could also set this up as just a simple object. Since the object isn't intended to be instantiated, it may be a bit more self-documenting that way.

var windowMaid = {
    registerOpenWindow: function() {}, //etc
}
module.exports = windowMaid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've been using Classes in this module. Is there a real benefit to using an object literal instead of the class? Or you just think its a bit more concise?

Choose a reason for hiding this comment

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

I think there are a couple benefits to using an object literal:

  • It's more concise, and follows the KISS principle
  • It makes the code more self-documenting by clearly indicating the intent. Usually classes are intended to be instantiated. If it's just a simple object, there's no chance anyone can try to instantiate it because that would be impossible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see how the static keywords make it any more complex, but I don't mind changing it either so I'll do what you suggest.
And if it was part of a public API I think the argument about instantiation makes great sense. Since it's not in this case I'm not super concerned about that.

@mattsgarlata
Copy link

+1

@codecounselor codecounselor merged commit ee9fab5 into fraserxu:master Feb 10, 2017
@codecounselor codecounselor deleted the issue-163-fix-window-cleanup branch February 10, 2017 14:29
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.

None yet

2 participants