Go ahead, try googling "javascript oop". Or you you can just take it from me: you'll get a thousand ways to do object oriented programming in javascript.
Don't get me wrong, javascript a very powerful language. And I really mean very powerful. Most people working with it, though do not know its full power. For example, javascript lets you write curried functions - the syntax will be strange, but you will have curried functions, meaning you can actually go and use javascript as a functional programming language (oh, it will look horrible, but the point is that you can).
As I said, there are a lot of ways to do object oriented programming in javascript, and it appears there are few people who use the exact same way. There is a way that s default in javascript, but it has its limitations, which - as powerful as javascript is - you can work around. I picked up a style in this that turns out not too be all that common, used some more common elements in it and even added a little that is completely my own.
So that is why I decided that I am going to document this stye of object oriented programming and all its powers. For example, the model supports private data and functions, has its own (but really solid) way to define inheritance. I will document not only how to do something, but also why it is done in this way and not in some other way.
First and foremost, this will be a reference for me, so I can write consistent OOP code in javascript and so I can use powerful features - such as static functions - without first having to dig through old work to see how I did that again. However, I will make it available for others to use, as it can be a useful guide how to achieve some standard OOP features in javascript - and one might even consider using the style as a whole in order to be consistent in one's own work while having a number of powerful features at your disposal.
I do not know how I will exactly provide this documentation, right now I am just typing out the text that documents it. However, I will get back to you on that point.
No comments:
Post a Comment