If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Programming JavaScript with a classical object-oriented approach.

Lately I've started to think that it might be a good thing to program JavaScript with a classical object-oriented approach because then it is possible to take advantage of things like design patterns. JavaScript does not have things like abstract classes, interfaces, implementing interfaces so I found a JavaScript framework that offers this functionality, easejs.

Question #1: Do you think that it's a good idea to program JavaScript with a classical object-oriented approach?
Question #2: If yes, how would you organize the files? For example, in Java they have a class in it's own file.

Much as I don't think MVC works properly in PHP because it's not how the language works, trying to use 'classical object' methods in JS is a bad idea because JavaScript's object model is a JOKE. It's like it was tossed on the language as an afterthought and really few of the programming paradigms that work in a real OOP language (Smalltalk, Modula, Object Pascal) translate well -- if at all -- to it.

There's also the simple fact that if you are using enough JS for something like true OOP design patterns to pay benefits, you're probably doing something wrong that likely has no business being done in JS in the first place.

But then, not counting social media plugins I get squirrelly if I have more than 32k of scripting on a website. You need more than that it's likely you're just doing something wrong. Hence why I have in the back of my mind at all times the "Unwritten rule of JavaScript"

If you can't make a fully functional page without JavaScript FIRST, you likely have no business adding scripting to it!

Which of course is why 90%+ of websites take a minute first-load thanks to the MEGABYTES of JS for nothing; and why all these idiotic halfwit frameworks are pissing all over the functionality of websites with their "Gee ain't it neat" but ultimately useless BS.

JS for nothing and your scripts for free. That ain't workin', that's not how you do it. Lemme tell ya, these guys ARE dumb.