"What you may say is 'Hey, the syntax is too complicated! Writing those syntaxes will frustrate me ...'
Actually, JavaScript is not an Object Oriented Programming language. But we create context so we can do OOP. And once the syntax is too complicated, we can simplify them. But I consider borrowing the existed mature Java language would be a better choice. That is, we can write in the style of Java, which is sure an OOP style language, and then we converts the Java codes into JavaScript codes, which is somewhat syntactic complicated. And then we have a great thing."
Fortunately, there are more simpler articles that demonstrates ways of creating Javascript objects, howtocreate, mozilla and mckoss still use the newly created class' prototype object. The only benefit I see, it gives you a chance to define functions and attributes for later and also can separate functions and attributes leaving the main class constructor. However, if you are comparing against natural OOP language like Java, C++ and C#, you usually do not have to define these functions and objects explicitly and you can incorporate methods and attributes into your classes (that you would normally see in naural OOP languages) as demonstrated in these even simpler articles from daaq and asp-ajax.
Also stumbled some interesting article on using JSON objects from hunlock and some useful javascript inheritance techniques in prototypejs.
No comments:
Post a Comment