Incompleted instanced

2 views
Skip to first unread message

lukspa

unread,
Jan 16, 2012, 9:15:22 AM1/16/12
to jsclass-users
Hi,

I have created mvc framework with JS.Class for rapid creating thick
client applications. Currently I have nearly two hundred js files and
use package manager. My problem is that sometimes(non determistic) my
instances are not completed(there are missing methods from parent
class or from mixins). I tried to figure it out but without success.
Can you give me some advice?

thanks, Lukspa

James Coglan

unread,
Jan 16, 2012, 2:32:29 PM1/16/12
to jsclas...@googlegroups.com
This sounds like race conditions when downloading, which probably means your dependency information that you've set up in JS.Packages is not complete enough for JS.Packages to make sure they arrive in the right order. Make sure each package lists everything it needs in the requires() list, and check that your files aren't defining objects that could confused the package manager into thinking it doesn't need to download other files.

If you can recreate the issue with a small subset of your application and share it with us, that would be helpful.

lukspa

unread,
Jan 17, 2012, 3:22:54 AM1/17/12
to jsclass-users
Thank you for quick reply. You are right, i have been using
autoloading for my files and few of them didn't have their
dependencies.
When I checked in ancestor loading method there was lots of nulls and
undefined values. Shouldn't there be some exception throw when
dependency is missing?

Once more thank for help.

btw. Is there a way to define dependencies for autoloaded files?

On Jan 16, 8:32 pm, James Coglan <jcog...@gmail.com> wrote:

Javier Peletier

unread,
Jan 17, 2012, 5:52:19 AM1/17/12
to jsclas...@googlegroups.com
I have had a very much similar use today when my JS.Packages was wrong, but had lots of exceptions everywhere else. Bottom line, when instantiating a JS.Class, I was passing the base class, but the base class was undefined (due to wrong JS.Packages), and this caused problems in odd places in my code.

Shouldn't JS.Class throw an exception if I am trying to create a new class but pass undefined as base? or is "undefined" as base a valid use case? Example:

var myBase = undefined;

var myClass = new JS.Class(myBase, {}); // should throw exception since myBase is undefined?

James Coglan

unread,
Jan 17, 2012, 3:18:01 PM1/17/12
to jsclas...@googlegroups.com
On 17 January 2012 08:22, lukspa <lukasz....@gmail.com> wrote:
Thank you for quick reply. You are right, i have been using
autoloading for my files and few of them didn't have their
dependencies.
When I checked in ancestor loading method there was lots of nulls and
undefined values. Shouldn't there be some exception throw when
dependency is missing?

I'm pretty sure the include: and extend: fields are treated as missing if their values are undefined. Maybe we should change this, but I'm not sure what the impact would be.

btw. Is there a way to define dependencies for autoloaded files?

You can pass require: to include bits of the regex match. For example, when writing specs I do this:

    autoload(/^(.*)Spec$/, {from: './spec', require: '$1'});
    // e.g. FooSpec depends on Foo 

James Coglan

unread,
Jan 17, 2012, 3:19:14 PM1/17/12
to jsclas...@googlegroups.com
On 17 January 2012 10:52, Javier Peletier <j...@peletier.com> wrote:
I have had a very much similar use today when my JS.Packages was wrong, but had lots of exceptions everywhere else. Bottom line, when instantiating a JS.Class, I was passing the base class, but the base class was undefined (due to wrong JS.Packages), and this caused problems in odd places in my code.

Shouldn't JS.Class throw an exception if I am trying to create a new class but pass undefined as base? or is "undefined" as base a valid use case?

Possibly. I think there may be a bunch of code I have that takes advantage of the current behaviour, but I'll check it out. It's certainly a hard error to find the cause of when it happens. 

James Coglan

unread,
Jan 29, 2012, 7:40:52 AM1/29/12
to jsclas...@googlegroups.com
I've implemented several changes on this branch: https://github.com/jcoglan/js.class/compare/3.0.x...no-undefined-parents

The effect of these is that all the following are errors:

* Instantiating JS.Class or JS.Module with any undefined arguments
* Calling Module#include(undefined) 
* Calling Kernel#extend(undefined) 
* Passing undefined values for include: or extend:

Note you can still call `new JS.Module()` or `new JS.Class()` with no arguments. It's only if you give arguments but they are undefined that you can an error. Similarly for the include: and extend: fields; you can omit them but you cannot give them undefined values.
Reply all
Reply to author
Forward
0 new messages