The Module pattern is based in part on object literals and so it makes sense to refresh our knowledge of them first.
Introduction Quite often I see a question in a newsgroup or forum along the lines of: What is this thing called 'OOP'? What is so special about it? Why should I use it? How do I use it? The person asking this type of question usually has experience of non-OO programming and wants to know the benefits of making the switch.
Unfortunately most of the replies I have seen have been long on words but short on substance, full of airy-fairy, wishy-washy, meaningless phrases which are absolutely no use at all to man or beast.
According to some OO 'purists' I am not qualified at all as I was not taught to do things 'their' way and I refuse to follow 'their' methods.
My response to that accusation is that there is no such thing as 'only one true way' with OOP just as there is no such thing as 'only one true way' with religion.
People tell me that my methods are wrong, but they are making a classic mistake. My methods cannot be wrong for the simple reason that they workand anybody with more than two brain cells to rub together will tell you that something that works cannot be wrong just as something that does not work cannot be right.
My methods are not wrongthey are simply differentand sometimes it is a willingness to adopt a different approach that separates the code monkeys from the engineers.
One reason why some people give totally useless answers is that it was what they were taught, and they do not have the intelligence to look beyond what they were taught.
Another reason is that some of the explanations about OO are rather vague and can be interpreted in several ways, and if something is open to interpretation it is also open to a great deal of mis -interpretation.
Even some of the basic terminology can mean different things to different people, as explained in Abstraction, Encapsulation, and Information Hiding. If these people cannot agree on the basic concepts of OOP, then how can they possibly agree on how those concepts may be implemented. In compiling the following list I picked out those descriptions which are not actually unique to OOP as those features which already exist in non-OO languages cannot be used to differentiate between the two.
OOP is about modeling the 'real world' OOP is a programming paradigm that uses abstraction to create models based on the real world. It provides for better modeling of the real world by providing a much needed improvement in domain analysis and then integration with system design.
OOP is no better at modeling the real world than any other method.
Every computer program which seeks to replace a manual process is based on a conceptual software model of that process, and if the model is wrong then the software will also be wrong. The conceptual model is created as an analyst's view of the real world, and the computer software is based solely on this conceptual model.
OOP does not provide the ability to model objects which could not be modelled in previous paradigms, it simply provides the ability to produce different types of models where both the data and the operations which act upon that data can be defined encapsulated in the same unit class.
OOP does not guarantee that the model will be better, just that the implementation of that model will be different.Write an abstract superclass encapsulating a vehicle: A vehicle has two attributes: its owner's name and its number of wheels.
This class has two non-abstract subclasses: one encapsulating a bicycle, ant the other encapsulating a motorized vehicle. Abstract Superclass Factor Common Code Up An abstract method defines the method name and arguments, but there's no method code. Subclasses must provide an implementation.
Abstract Class The "abstract" keyword can be applied to a class Vehicle: Watercraft: Kayak. Inheritance, Polymorphism, and Abstract Classes. As an example, suppose you want to write a program that plays the card game, Blackjack.
You can use the Card, Hand, If class B is a subclass of class A, we also say that class A is a superclass of class B. Most of the answers here aren't quite right. It doesn't mean or even imply "use the interface keyword" at all.
An interface is a spec of how to use something--synonymous with the contract (look it up). The superclass constructor can be called explicitly using the super keyword, but it should be first statement in a constructor. The super keyword refers to the superclass, immediately above of the calling class in the hierarchy.
write an abstract superclass encapsulating a vehicle in java: A vehicle has two attributes: its owner's name and its number of wheels. This class has two non-abstract subclasses: one encapsulating a bicycle, and the other encapsulating a motorized vehicle.