Skip to main content

Posts

Showing posts from November, 2015

Abstraction

Abstraction means ignoring irrelevant features, properties, or functions and emphasizing the relevant ones...relevant to the given project (with an eye to future reuse in similar projects).

Encapsulation

You can take two views of an object: internal - the structure of its data, the algorithms used by its methods external - the interaction of the object with other objects in the program From the external view, an object is an encapsulated entity, providing services These services define the interface to the object An object should be self-governing Any changes to the object's state (its variables) should be accomplished by that object's methods We should make it difficult, if not impossible, for one object to "reach in" and alter another object's state The user, or client, of an object can request its services, but it should not have to be aware of how those services are accomplished (abstraction - hide details).

Polymorphism

Polymorphism Enables “programming in the general” The same invocation can produce “many forms” of results Interfaces Implemented by classes to assign common functionality to possibly unrelated classes  Polymorphism When a program invokes a method through a superclass variable, the correct subclass version of the method is called, based on the type of the reference stored in the superclass variable The same method name and signature can cause different actions to occur,  depending on the type of object on which the method is invoked Polymorphism enables programmers to deal in generalities and let the execution-time environment handle the specifics. Programmers can command objects to behave in manners appropriate to those objects, without knowing the types of the objects (as long as the objects belong to the same inheritance hierarchy).  Promotes extensibility New objects types can respond to existing method calls Can be incorporated into a system ...

inheritance in java

Inheritance allows a software developer to derive a new class from an existing one The existing class is called the parent class, or super class, or base class The derived class is called the child class or subclass. As the name implies, the child inherits characteristics of the parent That is, the child class inherits the methods and data defined for the parent class To tailor a derived class, the programmer can add new variables or methods, or can modify the inherited ones Software reuse is at the heart of inheritance By using existing software components to create new ones, we capitalize on all the effort that went into the design, implementation, and testing of the existing software Inheritance relationships often are shown graphically in a UML class diagram, with an arrow with an open arrowhead pointing to the parent class Examples  ex 1  ex 2