Você está na página 1de 6

Contents

Class ................................................................................................................................. 2 Constructor ...................................................................................................................... 2 Destructor ........................................................................................................................ 2 Abstract class ................................................................................................................... 3 Abstraction ...................................................................................................................... 3 Instantiation..................................................................................................................... 3 Inheritance ....................................................................................................................... 3 Encapsulation ................................................................................................................... 3 Polymorphism .................................................................................................................. 3 Overloading ..................................................................................................................... 4 Overriding ........................................................................................................................ 4 Hierarchy ......................................................................................................................... 4 Interfaces ......................................................................................................................... 5 Aggregation...................................................................................................................... 5 Composition ..................................................................................................................... 5 Composite objects ............................................................................................................ 5 Exceptions ........................................................................................................................ 6 Coupling ........................................................................................................................... 6 Cohesion .......................................................................................................................... 6 Deadlock .......................................................................................................................... 6 Servlet.............................................................................................................................. 6 Why use Object-Oriented programming? .......................................................................... 6

Class
A class is a pattern, template, or blueprint for a category of structurally identical items. The items created using the class are called instances. This is often referred to as the "class as a `cookie cutter'" view. As you might guess, the instances are the "cookies." A metaclass is a class whose instances themselves are classes. A parameterized class is a template for a class wherein specific items have been identified as being required to create non-parameterized classes based on the template. A non-class instance is an instance of a class, but is itself not a class. An instance of a metaclass, for example, would not be a non-class instance. A selector is an operation that tells us something about the state of an object, but cannot, by definition, change the state of the object. An operation that tells us the current balance of a bank account is an example of a selector operation. A constructor is an operation that has the ability to change the state of an object. For example, an operation in the public interface to a mailbox object that added a message to the mailbox would be a constructor operation. (Please note that some people restrict the definition of the term "constructor" to those operations that cause instances of a class to come into existence.) An iterator is an operation that allows its users to visit (access) each of the component objects that make up the homogeneous composite object. If we have a list of addresses, for example, and we wish to print the entire list, an iterator would allow us to visit each address object within the list and then, in turn, to print each address.

Constructor
The constructor of a class is a special operation that is run upon instantiation when an object is created. They are often distinguished by having the same name as the class itself. Its main purpose is to set-up the attributes of a class and to establish the class invariant to basically make sure that the attributes of the class conform to the class interface. It cannot have a return type. A properly written constructor should never contain any functionality that could fail, thus leaving the object in an invalid state.

Destructor
The destructor of a class is the opposite of the constructor in that it is run when an object is destroyed. Its function is to clean up and to free the resources which were used by the object during run-time and unlink it from other objects or resources. This should result in the invalidation of any references in the process.

Abstract class
Abstract classes are classes that embody coherent and cohesive, but incomplete, concepts, and in turn, make these characteristics available to their specializations via inheritance. People sometimes use the terms "partial type" and "abstract superclass" as synonyms for abstract class. While we would never create instances of abstract classes, we most certainly would make their individual characteristics available to more specialized classes via inheritance. Abstract classes are used to declare common characteristics of subclasses. An abstract class cannot be instantiated. It can only be used as a superclass for other classes that extend the abstract class. A big Disadvantage of using abstract classes is not able to use multiple inheritances. In the sense, when a class extends an abstract class, it cant extend any other class.

Abstraction
Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.

Instantiation
Instantiation has two common meanings:

as a verb, instantiation is the process of creating an instance of a class, and As a noun, an instantiation is an instance of a class.

Inheritance
The term inheritance refers to the fact that one class can inherit part or all of its structure and behaviour from another class. Inheritance refers to the process where one object acquires (gets, receives) characteristics from one or more other objects. Inheritance allows a subclass to inherit all the attributes and methods of a parent class in effect, extending the parent.

Encapsulation
The term encapsulation refers to protecting the internal implementation of an object from direct manipulation by the client.

Polymorphism
The term polymorphism refers to the fact that different objects can respond to the same message in different ways.

Polymorphism meaning different classes can have different behaviours for the same attribute or method. Polymorphism, at its most basic, describes the fact that a given function may have different specifications, depending on the object to which it is applied.

Overloading
Method overloading means having two or more methods with the same name but different signatures in the same scope. These two methods may exist in the same class or another one in base class and another in derived class. When to use Method Overloading? Generally, you should consider overloading a method when you have required same reason that take different signatures, but conceptually do the same thing.

Overriding
Method overriding means having a different implementation of the same method in the inherited class. These two methods would have the same signature, but different implementation. One of these would exist in the base class and another in the derived class. These cannot exist in the same class. Overriding methods Overriding method definitions In a derived class, if you include a method definition that has the same name and exactly the same number and types of parameters as a method already defined in the base class, this new definition replaces the old definition of the method. Explanation A subclass inherits methods from a superclass. Sometimes, it is necessary for the subclass to modify the methods defined in the superclass. This is referred to as method overriding. The following example demonstrates method overriding.

Hierarchy
The hierarchy helps add logic to a collection of classes. It also enables similar classes to share properties through inheritance below. A hierarchy is useful if there are several classes which are fundamentally similar to each other.

Interfaces
Interfaces just specify the method declaration (implicitly public and abstract) and can only contain fields (which are implicitly public static final). Interface definition begins with a keyword interface. An interface like that of an abstract class cannot be instantiated. Multiple Inheritance is allowed when extending interfaces i.e. one interface can extend none, one or more interfaces. Java does not support multiple inheritances, but it allows you to extend one class and implement many interfaces.

Aggregation
It is, of course, possible for objects to be composed of other objects. Aggregation is either:

the process of creating a new object from two or more other objects, or An object that is composed of two or more other objects.

For example, a date object could be fashioned from a month object, a day object, and a year object. A list of names object, for example, can be thought of as containing many name objects.

Composition
Composition is a slightly different sort of relationship this is where it could be said that a class was composed of other classes.

Composite objects
Composite objects are objects that have an externally-discernible structure, and the structure can be addressed via the public interface of the composite object. The objects that comprise a composite object are referred to as component objects. Composite objects meet one or both of the following criteria:

The state of a composite object is directly affected by the presence or absence of one or more of its component objects, and/or The component objects can be directly referenced via the public interface of their corresponding composite object.

It is useful to divide composite objects into two subcategories: heterogeneous composite objects and homogeneous composite objects:

A heterogeneous composite object is a composite object that is conceptually composed of component objects that are not all conceptually the same. For example, a date (made up of a month object, a day object, and a year object) is a heterogeneous composite object. A homogeneous composite object is a composite object that is conceptually composed of component objects that are all conceptually the same. For example, a list of addresses is a homogeneous composite object.

Exceptions
A third category of items that can be found in the public interface of objects is exceptions. Exceptions have two different definitions:

An event that causes suspension of normal application execution, and A set of information directly relating to the event that caused suspension of normal application execution.

Coupling
Coupling is a measure of the strength of the connection between any two system components. The more any one component knows about another component, the tighter (worse) the coupling is between those two components.

Cohesion
Cohesion is a measure of how logically related the parts of an individual component are to each other, and to the overall component. The more logically related the parts of a component are to each other the higher (better) the cohesion of that component.

Deadlock
A special type of error that you need to avoid that relates specifically to multitasking is deadlock, which occurs when two threads have a circular dependency on a pair of synchronized objects. In general, it occurs only rarely, when the two threads time-slice in just the right way. It may involve more than two threads and two synchronized objects. (That is, deadlock can occur through a more convoluted sequence of events than just described.)

Servlet
A Servlet is a Java class in Java EE that conforms to the Java Servlet API, a protocol by which a Java class may respond to HTTP requests. Thus, a software developer may use a servlet to add dynamic content to a Web server using the Java platform.

Why use Object-Oriented programming?


Object-orientation can help keep projects simple by breaking them down in to manageable chunks. Those chunks can then be re-used in other projects, thus saving time in the long-run. In fact, adopting an object-oriented approach can be the foundation of a truly successful team environment; through promoting modularity, an object-oriented environment breeds improved code reusability and maintainability.

Você também pode gostar