SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Class 1
                                 How to start programming in Java?

This part of the study material is not intended to address still concepts, but rather, you can
configure any computer window xp or Windows 7 32 or 64 bit and get it ready to start
programming.

First of all: Installing "jdk-7u7-nb-7_2-windows-i586-ml" JDK "Java Development Kit", will not
only
compile but run applications, available for a variety of operating systems:

http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html




METHOD 1: Use the Shell to run java code

This point is important for you to read and performers very well using the following commands:



• javac.exe, compiler generated files *. Apartir class source code (*. Java). The *. Java is text, you
can create and edit in a text editor, using the syntax of Java.

• Java.exe, systems interpreter for PC / Windows, executes bytecode files (files compiled class
extension). The *. Class have executable code, bytecode, platform independent, to be executed
on a "hypothetical or virtual machine" called Java Virtual Machine (JVM). Is this JVM neutral
who plays this code making a particular code on the CPU used. This avoids having to make a
different program for each CPU or plataforma.1



Shell enters the system and see what happens when Digitas commands: java or javac.

You will realize that the javac command is not enabled, therefore the following steps and then
try to use the command in question, the difference observed.



Remember watching the second image of this manual and look in the directory where it is
located
javac command.
To educate the system accepts this command indicating that we should add "environment
variables" as indicated in the graph.



Creating our first program in java

  Install then an editor to start coding (in this case Notepad + +)
  After that, create the following program and save it in the directory "c:  ProgramasJava"
Note that the file name must be named identical to the class, using case sensitive.



  Finally run the program, first compile the program with javac and then running the java
program.




METHOD 2: Using the Eclipse IDE ENTERNO

(Available at www.eclipse.org - Section "downloads" download the Eclipse Classic 4.2)

This method is much faster than before, it is a method of abstraction for programming while we
should not install the JDK, and load the necessary libraries to program without tread very rodeo.

STEP 1: Download and unzip the file indicated




STEP 2: After that opening the Eclipse IDE, the program requests a folder where you will save the
projects that we believe in java, proceed as indicated in the graph (you must create the folder
previously).




STEP 3: Follow the following sequence of actions to create a project in java.




Look what happens next.
Now insert a class as follows




With the IDE, the only line of code you write play, which was noted below




Run the program with the button, watch out.

Further notes what happened in "ProgramasJava2" you created.

REFERENCES

http://www.ajpdsoft.com/modules.php?name=news&file=print&sid=270




CLASS 2
Step by step creation of the first program in Java using Eclipse

1. Run the sequence of actions detailed in the chart.




2. Run after the sequence of actions detailed in the chart.




3. Insert a class called "PruebaAlbum" as follows.




4. Now insert a class called "Album", in the same way as the previous step.
5. The result after the above steps is a structure as follows.




6. Declare the following attributes within the class "Album"



7. Then set the SET and GET methods (methods are inserting, modifying and extracting the
values that variables may have happened before, "automatically generated"), this operation is
called to create getters and setters.




8. Notice how you generated the following code block without you had to write something.




9. Define the following constructor.

The constructor is a method that must have the same name as the class and is used to initialize
the attributes of an object, usually receives values have
past, a quick way is to develop a method using getters and setters
the previous step.




10. Now we instantiate an object of class "Album" in class "PruebaAlbum", this instance or
reference to create should be made in the main.




See how you created two instances, and the way in which you can send arguments.

11. In the previous step we created two instances, how can we show these values on screen?

We must develop a new method in the "Album", will be called
"ImprimirAlbum"




12. Then call the method created from the two instances declared in step 10.
13. And finally see the execution, after clicking on the button should appear something as
follows:




  Class 3
INTRODUCTION TO JAVA CONCEPTS

Java and all Java-based trademarks are trademarks of Sun Microsystems.1




What is Java JDK?

JDK stands de java Developers Kit is, toolset to develop (applications) in countless classes Java.
Existen accompanying the JDK that is installed in order to get started programming in JAVA.




What makes it different from the other JAVA programming languages?

What distinguishes Java from other programming languages is its conception of departure, in
which language is to create a road that can be used to program in all types of operating systems
and processors.

One of the most important features is that the programs "executable", created by the Java
compiler, are independent of the architecture. Run interchangeably in a variety of
microprocessors and computers with different operating systems.




Is the language is compiled or interpreted?

Java is compiled when the source code is translated into an object called machine code (binary,
bytecode) and is interpreted because the machine code can be run on any platform which
should be an interpreter executing it in real time.
To run it, you need an interpreter, the JVM (JavaVirtual Machine) Java virtual machine. Thus, it
is possible to compile the program on a UNIX workstation and run it on another Windows using
the Java virtual machine for Windows.

This JVM is responsible for reading the bytecodes and translate them into executable
instructions directly on a particular microprocessor.

The Java Virtual Machine (JVM).

The Java virtual machine is the revolutionary idea of language. It is the entity that provides
platform independence for Java programs compiled into byte-code.




Bibliography

http://es.scribd.com/doc/3258260/98/La InputStream class-

http://ingensis.blogspot.com/2010/06/java-is-a-language-compiled-e.html

http://www.alegsa.com.ar/Diccionario/C/4133.php

http://www.alegsa.com.ar/Diccionario/C/4133.php



Class 4



The programmer must establish the association between the machine model "solution space"
that is where to deploy the solution, such as a computer, and the problem is what you really
want to solve "problem space" that is where the problem exists, the business.

What is an abstraction?

   Alan kayresumion the five basic characteristics of Smalltalk for an object, the first object-
oriented language that was successful and one of the languages that is based on JAVA. These
characteristics represent a pure approach to object-oriented programming.
1. Everything is an object. Think of an object as a variable stores data, allows you "raise
requests" asking him to perform operations on itself. In theory, you can take any conceptual
component of the problem that is being addressed.
2. A program is a bunch of objects that tell each other what to do r
sending messages. To make a solicitude to an object, you must send a message to that object.
More specifically, you can think of a message is a request to call a method that belongs to a
particular object.
3. Each object has its own memory made up of other objects. Stated another
way, you can create a new class of Obeto defining a package containing existing objects.
Therefore, it may increase the complexity of a program hiding behind the simplicity of the
objects.
4. Every object has an associated type. As the saying goes, every object is an instance of a case
where "class" synonymous with "type." The most important distinguishing characteristic of a
class is "the set of messages that can be sent."
5. All objects of a particular type can receive the same messages. As discussed below, this
statement is really important. Since an object of type "circle" is also an object of type "shape," a
circle can be guaranteed to accept shape messages. This means that you can write code to
communicate with objects of type form and automatically control anything that fits the
description of a form. This capability is one of impersonation most important concepts of OOP.

Booch offers an even more succinct description of object:

- An object has state, behavior and identity.

This means that an object can have internal data (which provides state), methods (to provide a
behavior) and each object can be uniquely distinguished from other objects, ie, each object has
a unique memory address .

The object-oriented approach

Reference is made to the elements in the problem space called "objects" to their
representations in the solution space. The idea is that the program can adapt by itself to the
lingo of the problem by adding new types of objects so that when you read the code describing
the solution, you are reading words that also express the problem. Thus OOP allows you to
describe the problem in terms of the problem rather than in terms of the computer.

Why use classes?

Since a class describes a set of objects having characteristics (data elements) and behavior
(functionality) identical actually a class is a type of data because, for example, a floating point
number also has a set of characteristics and performance . The difference is that the
programmer defines a class to fit a problem rather than force the use of an existing data type
that was designed to represent a storage unit in a machine. You can extend the programming
language by adding new data types specific to suit your needs. The programming system
supports the new classes and provides all combinations of type providing defined types.
Creating abstract data types (classes) is a fundamental concept in object-oriented programming.
What is an object?

Once a class has been defined, you can create as many objects of that class as desired and these
objects can be handled as if the elements of the problem that is being addressed.

But how do you make a object do useful work for the programmer? There must be a way to
make an application in order to do something, such as complete a transaction, draw something
on screen or a switch.

What is an interface

Also, each object can satisfy only certain requests. Requests can be made to an object are
defined by its interface and is the type that determines the interface. An example with the
representation of a light bulb:




The interface determines the applications that can be done to a certain object, so there must be
a code somewhere to satisfy that request. This, along with the hidden data, define what it calls
the implementation. From the standpoint of procedural programming, this is not complicated.
One type has a method associated with each possible request, and when a specific request is
made to a objesto, this method is called. This process is summarized by saying that the
developer "send a message" (make a request) to an object and the object knows what to do
with this message (it executes the code).

In this example, the name of the type / class is Light, the name of this particular object is lz Light
and applications that can be done to an object light is on, off, or dim glow. It has created a light
object defining a "reference" (lz) for that object and calling new to request a new object of that
type. To send a message to the object, defined the object name and is related to the application
of the message by a point. From the point of view of the user of a predefined class, that is the
ultimate programming objects.

The diagram above follows the format of UML (UnifiedModelingLanguage, Unified Modeling
Language). Each class is represented by a box by typing the name of the guy at the top, the data
members in the intermediate zone and methods (functions of said object receiving any message
sent to the developer that object) in the bottom . Often in these diagrams only show the name
of the class and public method, not including the buffer zone, as in this case. If you are only
interested in the class name, it is not necessary to include the bottom.



Class 5
Primitive data types IN JAVA
There are a bunch of guys that are used very often in programming and requires special
treatment. Types can be considered as "primitive", the reason for this special treatment is that
to create a new object, a simple variable small, not efficient. To these primitive types, Java uses
the technique used in C and C + +, that is, instead of creating the new variable creates a variable
"automatic" is not a reference.

Java determines the size of each primitive type. These sizes do not change from one machine
architecture to another. This invariability of the sizes is one of the reasons of portability java.




Defaults primitive members

When a primitive data type as a member of a class, Java guarantees that you will be assigned a
default value if it fails to boot:




The defaults are only the values that Java guarantees when the variable is used as a class
member. This ensures that the member variables of primitive type always be initialized
(something C + + does not do), reducing a source of potential errors. However, this initial value
may not be correct or even legal for the program you are writing. It is best to always initialize
variables explicitly.

This warranty does not apply to initialize local variables, those that are not class fields.



Class 6

CONCEPTS OF OBJECT-ORIENTED PROGRAMMING (OOP)

1 What is OOP?

Is to develop programs from objects. These objects waiting messages, process and send
messages to other objects. In object-oriented programming, objects are defined that make up an
application. These objects are formed by a series of features and operations that can be
performed on them.

2 What is an object?
The answer to this question in terms outside the programming seems simple. An object is a
person, animal or thing. It is distinguished from other objects to have certain characteristics and
is good for something, or put another way, you can perform various operations with or on that
object. For example:

A house is an object.

FEATURES:

Number of floors, Total height in meters, the facade color, number of windows, door number,
city, street and number where it is located, etc..

OPERATIONS

Build, destroy, painted facade, modify any of the characteristics, such as opening a new window,
etc.

Obviously, each object can be defined in terms of a multitude of features and an extensive array
operations. Now in terms of programming, the programmer mission will determine what
features and interest to maintain operations on an object. For example, on the home object may
not be necessary to know its location and therefore, these features are not part of the object
defined by the programmer. The same could be said about the operations. In terminology of
object-oriented programming, the characteristics of the object are called attributes and
operations METHODS. Each of these methods is a procedure or function
belonging to an object.

FORMAL INFORMAL TERMINOLOGY Terminology
FEATURES ATTRIBUTES
Operations (procedures and functions) METHODS



An object is formed by a number of features or data (attributes) and a set of operations
(methods). No conceivable only on the basis of data or operations but as a whole.

Example: Think about what methods would be needed to make a car turn

  Insert the key

Turn the key
This would trigger the electrical system
The engine ignite
3. Classes and Objects

In OOP we must distinguish between two closely related concepts, the class and object.

Analogous to how to define variables in a programming language, when you declare an object
must define the type of object to which it belongs. This type is the class.

In C, we define two variables X and Y integer as follows:




int X, Y;

In this case, X and Y are variables and the type of these variables is integer. The way to declare
objects in Java is the same:

Ccasa casa1, house2;

In this case, house2 casa1 and variables are effectively but somewhat special, are
OBJECTS. Furthermore, the type of objects is Ccasa. This type is the class of the object

Analogy

Variable → Object
(X, Y) (casa1, house2)




→ Class Type
(Int) (Ccasa)




Declaring casa1 and house2 as objects belonging to the class Ccasa, it indicates that house2
casa1 and have a number of attributes (data) and are nPuertas, nVentanas and color, and also a
number of methods (operations that can be performed on them) as: abrirVentanas (),
cerrarVentanas (), etc..

4. Properties must meet to be considered a language object oriented.
POTTING INHERITANCE
  POLYMORPHISM

Encapsulation

Encapsulation is the property possessed objects hide their attributes, and even methods to
other parts of the program or other objects. The natural way to build

a class is to define a set of attributes which generally are not accessible outside of the same
object, but can only be modified by the methods which are defined as accessible from the
outside of that class.

Ccasa class {
int nPuertas, nVentanas; String color;

public Ccasa (int np, int nv, co String) {
nPuertas = np; nVentanas = nv, color = co;
}

public void paint (String co) {
color = co;
}

public void abrirVentanas (int n) {
nVentanas = nVentanas + n;
}

public void cerrarVentanas (int n)
{
nVentanas nVentanas =-n;
if (nVentanas <0)
nVentanas = 0;
}

public void abrirPuertas (int n) {
nPuertas = nPuertas + n;
}

public void cerrarPuertas (int n)
{
nPuertas nPuertas =-n;
if (nPuertas <0)
nPuertas = 0;
}
}
/ / HERE STATEMENT Ccasa casa1 objects and instances, house2;

The normal way to declare the class Ccasa is to define a set of attributes that are not accessible
from anywhere in the program, but only through certain methods. So, if you open a new
window in the house casa1, traditional philosophy of a programmer would do the following:

casa1.N_VENTANAS casa1.N_VENTANAS = + 1;

However, the natural way to do it in OOP is calling the method:

casa1.abrirVentanas (1);

That method (procedure) will increase by 1 nVentanas attribute. This does not mean that the
attribute can not be accessed nVentanas the traditional way (if it had been defined as public,
but for that language may be regarded as OOP, should allow for the possibility of prohibiting
access to the attributes directly.

Inheritance.

One of the main advantages of OOP. This property allows you to define other descendant
classes, so that the new class (the child class) inherits from the parent class all its attributes and
methods. The new class can define new attributes and methods can even redefine existing
attributes and methods (for example, change the type of an attribute or operations performed
by a given method.) Is the natural way to define objects in real life. Most people would say, for
example, that a house is a house with a garden. It has the same characteristics and properties or
operations you can perform on a house and also incorporates a new feature, the garden. At
other times, they added functionality (methods) and attributes. For example: a duck is a bird
that nothing. It has the same characteristics as the birds and should only declare a method on
the new class (the swim method).

This property enables code reuse and is very easy to take advantage of the existing class code,
modifying them minimally to fit the new specifications.

Example:

Suppose we have constructed Ccasa class and we want to define a new class that represents the
chalets. In this case you may want to define a new attribute that represents the square meters
of garden. Instead of redefining a new class from scratch, can be used for writing code Ccasa
class as follows.
As can be seen, only have to declare that the new class is a descendant of Ccasa Cchalet (extends
Ccasa) and declares the new attribute.




Clearly, we must redefine constructor method to initialize the new attribute mJardin. But the
methods for open / close doors or windows is not necessary to define them, are
Ccasa inherited from class and can be used, for example as follows: chalet1.pintar ("White");




Polymorphism

Polymorphism allows the same message to objects of different classes do these also behave
differently (different objects can have methods with the same name or the same object
methods can have identical names but different parameters)

Ccasa class {

public Ccasa (int np, int nv, co String) {

nPuertas = np; nVentanas = nv, color = co;
}

public Ccasa () {nPuertas = 0; nVentanas = 0, color = "";
}

}

You have two methods with the same name but different parameters. In the first case, the
attributes of the object initialized with the parameters of the method and in the second case will
be initialized to zero, for example. Also, if you have two objects and chalet1 casa1 and calls the
method:

chalet1.abrirVentanas (2)

Will execute the procedure code abrirVentanas Cchalet class and class
Ccasa.
Bibliography

http://es.scribd.com/doc/3258260/98/La-clase-InputStream



Class 7



'Class'

The classes are the mold for the creation of objects comprise:

 Methods. - Functions programmed to perform a certain task.
 Attributes. - Variables we will use in our program.
 Builders.
Method  main (in the case of JAVA)

In Java, almost all are classes (objects). The language requires the OOP and allows the possibility
to program using any other technique other than this. For this reason, a program will consist of
one or more source files and each will have defined one or more classes. In a source file can
declare one or more classes and will look similar to this:

class Class1 {
...
}

class Class2 {
...
}

Clasen class
{
...
}
A class consists of a portion of the return, and another for the body of the same:

Class Declaration
{
Class body
}

In the previous template has simplified the look of the class declaration, but you can make sure
that it contains at least the keyword class and the name given to the class.

The body of the class starts with an open brace ({) and ends with a closing brace (}). Within the
body of the class are declared attributes and class methods. For everything written in Java alone
program starts running (as in C) from the main () method.

public: indicates that the method main () is public and therefore can be called from other
classes. All main () method must be public in order to run from the Java interpreter (JVM).
static: indicates that the class does not need to be instantiated in order to use the method that
qualifies. (Not create any instance or object class Hello). It also indicates that the method is the
same for all instances that may be created.
 void: indicates that the main function returns no value.

The main method must always accept, as a parameter, an array of strings, containing the
possible arguments that are passed to the program on the command line, but as in our case, not
used.

"Conventions for writing classes, objects and methods"

The following is not necessarily a rule, is only a convention in this case that seeks to make Java
code more readable touch for when you check your code and correct it.

 Classes always begin in uppercase as well as each of the words that follow. Example:
myFirstClass
 methods instead start with lowercase letter and then capitalized on each additional word is
used. Example: esteEsMiPrimerMetodo ()
 Attributes like methods start with lowercase, and words have the same start with a capital
letter. Example: esteEsUnAtributo

Bibliography

http://es.scribd.com/doc/3258260/98/La-clase-InputStream

www.legga.com



Class 8
Object modeling
The term object arises in the late seventies in computer science, to reference notations to
problem solving, which are apparently different but mutually linked from a perspective different
from structured analysis.
These notations define objects representing components of the modular system is decomposed
to define knowledge.
This model looks at reality as objects interacting with responsibilities, where
each object could contain internal objects to form more functionality
complex.
Were set out different ways to perform the analysis, design and programming, and that variety
is still present.

Object Oriented Analysis is a method of analysis to examine the requirements from a class of
objects that are searched in the vocabulary of the problem domain, in order to represent the
user experience in outlining the requirement

Object Oriented Design is a design method for understanding and process decomposition and
object-oriented notation obtaining the logical model is class and object structures and the
physical model is architecture modules and processes as well as static models and dynamic.

The Object-oriented programming is the design implementation, where programs are collections
of cooperating objects. Each object belongs to a class hierarchy, and classes belong to a
hierarchy of classes related by inheritance.

Object orientation provides elements to develop solutions based on their theory, and are those
seen in the graph.

Additionally there are three minor elements of the object model, and are now marked in
purple.



What is abstraction?

An abstraction denotes the essential characteristics of an object distinguishable from other
objects and provides conceptual limits to the viewer's perspective.

When looking abstractions is necessary to focus on the important details, primarily on
similarities, differences ignoring for the moment to describe and specify some details of the
system and not go through the relevant unnoticed. A concept can be an abstraction only if it can
be described, understood and analyzed independently of the mechanisms used to achieve its
goals.

Abstractions are always influenced by the observer according to their experience and needs.
Abstraction is the recognition of the similarities between objects, situations or real-world
processes.

The abstraction focuses attention on the external view of the object to separate the essential
functioning of the object from its implementation, which is the principle of abstraction barrier.
Obtaining the abstractions of the problem domain is the core of object-oriented design, which
can be grouped into:

Abstraction of Bank says that an object represents a useful model of the problem domain or the
domain of a solution which has a personality.
Abstraction of Action states that an object provides a generalized set of operations which
perform the same function type



Class 8
Object modeling

The term object arises in the late seventies in computer science, to reference notations to
problem solving, which are apparently different but mutually linked from a perspective different
from structured analysis.

These notations define objects representing components of the modular system is decomposed
to define knowledge.

This model looks at the reality and responsibilities interacting objects, where each object could
contain internal objects to form more complex functionality.

Were set out different ways to perform the analysis, design and programming, and that variety
is still present.




Object Oriented Analysis is a method of analysis to examine the requirements from a class of
objects that are searched in the vocabulary of the problem domain, in order to represent the
user experience in outlining the requirement

Object Oriented Design is a design method for understanding and process decomposition and
object-oriented notation obtaining the logical model is class and object structures and the
physical model is architecture modules and processes as well as static models and dynamic
object-oriented programming is the design implementation, where programs are collections of
cooperating objects. Each object belongs to a class hierarchy, and classes belong to a hierarchy
of classes related by inheritance.

Object orientation provides elements to develop solutions based on their theory, and are those
seen in the graph.
Additionally there are three minor elements of the object model, and are now marked in purple.

What is abstraction?

An abstraction denotes the essential characteristics of an object distinguishable from other
objects and provides conceptual limits to the viewer's perspective.
When looking abstractions is necessary to focus on the important details, primarily on
similarities, differences ignoring for the moment to describe and specify some details of the
system and not go through the relevant unnoticed. A concept can be an abstraction only if it can
be described, understood and analyzed independently of the mechanisms used to achieve its
goals.

Abstractions are always influenced by the observer according to their experience and needs.
Abstraction is the recognition of the similarities between objects, situations or real-world
processes.

The abstraction focuses attention on the external view of the object to separate the essential
functioning of the object from its implementation, which is the principle of abstraction barrier.
Obtaining the abstractions of the problem domain is the core of object-oriented design, which
can be grouped into:

Abstraction of Bank says that an object represents a useful model of the problem domain or the
domain of a solution which has a personality.

Abstraction of Action states that an object provides a generalized set of operations which
perform the same function type

Virtual Machine states that an object abstraction grouping of operations used in an upper or
lower level control is associated with a set of common purposes verbs

Abstraction coincidental groups a set of operations or unrelated models and are associated with
a set of verbs or nouns unrelated

Every good abstraction reflects how well you manage the system vocabulary

What is encapsulation?

The abstraction of an object precedes the implementation of its services, the implementation of
an object is a secret for abstraction and should be hidden for its customers, leaving as the only
answer to their service commitment regardless of how the fix, making nowhere a complex
system depends on the implementation of some other object, edging to respect the purpose of
this abstraction

While the abstraction suggests to do, encapsulation is directed at how it will perform, allowing
programs to reliably change with minimal effort this barrier.

Encapsulation and abstraction are complementary concepts, abstraction focuses on the
operation of an object observable. The encapsulation is focused on the implementation which
gives rise to the operation.

The class of an object that is born must have two parts:

An interface for services that are related to other objects, also known as external view.
An implementation which is the implementation of services is known as internal view

The encapsulation of the idea of having a very complex system that requires much attention and
become an object that handles everything internally and can be created easily.

Encapsulation is a process of sharing of elements constituting an abstraction of its structure and
operation, serves to separate encapsulation of an abstract interface and implementation.

Modularity

The target an individual program components also reduces complexity of grouping a set of
components for some purpose or common feature allowing components locate efficiently

Modularity is performed to divide a system into modules separately compilable, but with certain
minimum connections dependencies with other modules.

Modularity takes care of packing abstractions in discrete units called
modules, ie the physically packaged modularization classes and objects.

By modularizing takes advantage of the cost reduction of software design and review allowing
independent modules even reuse core modules for any system.

To achieve good modularity, modules should be constructed:

Modularity is the property of a system of decomposed into a cohesive set of modules with weak
couplings.
There are three factors likely to accept the decisions of modularization:

The modules serve as indivisible units of software that can be reused in other applications.
 Many compilers can generally object code in segments, one for each module.

A good code modularization allows quickly locate function as a
map.

HIERARCHY

A hierarchy is a rank or order of abstractions. A set of abstractions can repeatedly form a
hierarchy. By identifying hierarchies in the design, understanding the problem is simplified.

The hierarchy of generalization / specialization is formed by grouping abstractions within the
scheme which is a type B of A. For example, a car is a type of vehicle, is therefore to define a
relationship between classes, where a class defines the structure and behavior of one or more
classes (single inheritance and multiple inheritance respectively)

Inheritance represents a hierarchy of abstractions where a subclass (child class)
one or more inherited from superclasses (parent class).

The structure and operation of the various classes can form a superclass, and the inheritance
hierarchy is a generalization / specialization where the superclasses represent generalized
abstractions and subclass represents the specialization of the superclass methods, which are
added, modified and hidden .
The abstraction is intended to provide a barrier to hide the methods and statements, but
inheritance opens this interface to see the states and methods without abstraction. There are
levels of abstraction, speaking in terms of hierarchy.

A high-level abstraction is a generalization and a low-level abstraction is a
specialization

The hierarchy of total / part is formed by grouping abstractions within the framework of C D is
an example: A student is part of a group; Aggregation denotes the ratio total / part of a
hierarchy in which several objects are part of a Overall, the set of objects of a group denotes the
total lack of any such objects does not affect the overall identity and total destruction does not
involve the destruction of conforming parts.

A family seen as a total is made up of a father, a mother and children who are the parties, the
lack of a child does not destroy the family, but also the division destroys family members.

Summary
Finally, the encapsulation helps reduce complexity hiding details. The modular group helps the
solution to a problem.
Abstraction and hierarchy to classify similarities to simplify the understanding
Tipeamiento

One type is an accurate characterization of the structural and functional properties shared by a
collection of entities, classes or objects.

A force tipeamiento is a class of an object as well as to other types of objects to be
interchangeable or most can be exchanged only for very restricted roads, to have guys like units
of measure you can divide distance for a speed type, but not be possible to divide the
temperature between weight, tipeamiento requires only to perform certain legal combinations
of abstractions.

A programming language can be strongly typed, regularly typed or simply not be typed, and still
be object-oriented.

A strong typing prevents mixing abstractions illogical or unexpected results.

A semantic dependency introduces strong typing, so any small change in the class, can interfere
with customers who interact with it.
A force tipeamiento is a class of an object, and objects of different types, to be interchangeable,
or most, may be exchanged only limited changes.

The most important benefits of a strongly typed language are:

- Detects errors in the cycle of edit, compile and debug, despite being tedious.
- The type declaration auida to document a program.
- Most compilers generate efficient code when the types are declared.
- Disappearance of unpredictable behavior by assuming unwanted conversions.
- No type checking a program can rumble mysteriously at runtime.

CONCURRENCE

Concurrency allows different objects to act simultaneously, each program has at least one child
control, but a concurrent program can have multiple threads of control: some transient and
others throughout the runtime.

The machines run on multithreaded systems truly allow concurrent threads of control
A lightweight process shares memory space with another lightweight process, while the
combination of a heavy process is assigned its own memory space.
An object-oriented system can see the real world as a set of cooperating objects concurrently,
with each active site is an independent activity center.

Concurrency is the property to distinguish an object from one active inactive in a multithreaded.

PERSISTENCE

Persistence is responsible for saving the state and the class of an object over time and / or
space.
Persistence is the property of an object to transcend time (the object continues to exist even
after the cessation of its creator) and / or space (the object changes its position in the memory
space that was created).
Object
From the perspective of human knowledge can be an object: Anything tangible or intangible.
    Anything that can be learned intellectually.
    Something toward which thought or action can be directed. An object has:
- State.
- Operation.
- Identity.

STATE

The operation of an object is influenced by its history: the order under which he operates an
object is influenced by its history: the order under which an object is important opera.

We define an attribute property, or referenced single variable, with an inherent characteristic or
distinctive trait or faction which contribute to a single object.

The terms property and attribute are indistinct, both refer to the characteristics of an object.

The state of an object are all properties (typically static) of an object plus the current values
(usually dynamic) of each of these properties.

OPERATION

The operation of an object acts and reactúa in terms of its state changes and messages posted or
transmitted.

The operation of an object represents the outside is visible and its activity is measurable.

OPERATION
It is the action performed by an object to invoke the services of another object in order to get a
reaction, the result of the operation will be defined by the object's state at the time of
responding to the client. The operations defined for an object are called methods in terms of
programming and are defined as procedures and functions
 "To every action there is a reaction"

The state of an object represents an accumulation of results of its operation, a method denotes
a service provided by an object to its clients. The three most common types of methods are:

Modifier. Method that modifies the state of an object.

Selector. Method to query the state of an object without altering the state.

Iterative. Method to query all relevant parties to the state of an object with a well-defined value
repeatedly.

Additionally there are also methods to create and destroy objects:

Constructor. The constructor is a method created by an object which is initializer their status

Destroyer. It is a method of liberating state of an object and destroyer of it.

The role of an object is the mask to define a contract between abstraction and its clients, ie the
role of an object is defined by its methods.

The responsibility of an object are all services provided to all contracts supported.

A role are the services offered by an object, while responsibility is the fulfillment of the services
supported by a contract, the state jointly define the role and function of an object to play in the
world while meeting their responsibilities

The terms are interchangeable and operation method, both refer to its operation

IDENTITY

Each object is unique, even though sharing the same properties of another object, since it
occupies a different space. That is, an object has an authenticity identidad.Esta shown in the
variable of time and space.
 Identity is the property of an object to be distinguished from all other objects.
Relationships between objects

When multiple objects relate these make assumptions about each other, including the methods
performed well as the state of operation. The hierarchy of objects are of two types:

- League
A league is derived from the physical connection (with a message) or conceptual (no message) of
two objects, wherein an object can collaborate with another object by means of a message.
The message represents an association between an object that acts as a client using the services
of another object acts as a server.
The message between two objects is usually unidirectional and bidirectional rarely. An object to
interact with another through a league can play three roles.
   Customer actor. An object can operate on other objects but never be operated by other
objects.
   Server. An object does not operate upon other objects but can be operated by other objects.
   Agent. An object can be operated on other objects and can be operated
on other objects. Namely to serve as a client or server for one or more objects, for example:
If we consider two objects:

During the analysis of a problem can ignore the visibility, but you need to consider when
implementing the visibility through the leagues to determine the scope and access of objects on
each side of the league.



Currently an object can see another of four ways:



 The server object is global customer.
 The server object is a parameter of the method of the client.
 The server object is an object of the customer.
 The object server is locally declared object in a client method.

Two objects can communicate through a single league if they are synchronized and to achieve
synchronization of an active object with a liability can exist in three forms

 Sequential. A passive object synchrony guarantees the existence of a single active object look
upon synchronization.
 Protected. A passive object ensures synchronization with multiple threads
control only when active objects provide mutual exclusion
 Synchronized. A passive object ensures synchronization with multiple threads of control only
when the passive object ensures mutual exclusion
When an object passes a message to another through a link, the objects must be synchronized
somehow past messages can take any of the following ways.

 Synchrony. An operation begins when the station has initiated the action and the transmitter
is ready to both receive the message, the sender and receiver definitely wait until both parties
are ready to proceed
 Resistance. It is similar to the sync, except that the emitter
abandon the operation if the receiver is not completely ready
 Waiting Time. It is similar to the transmitter sync except wait a certain time until the receiver
is ready
 Asynchronous. The issuer can initiate messages regardless of whether the receiver is ready to
receive the message.

- Aggregation
The league denotes a relationship between client server, moreover aggregation denotes a
hierarchical part / total to navigate from the whole (aggregate) to any of its parts (attributes).
If the lifetime of an object or attribute is determined by the lifetime of the whole object, to be
considered as a parameter value is known as the aggregation composition, but if the life time of
an object is independent of the time Object life entirety to be considered as a reference
parameter known as aggregation,.



Aggregation helps encapsulate secret parts as a whole, but the links may be substituted if
desired aggregation break the coupling between objects.



Aggregation allows objects with complex workings but displayed by the encapsulation as simple
objects

What are classes?

A class is a group, type or group marked by common properties, cot distinction, a classification
of qualities or conditions classification.

A class is a set of objects sharing a common structure and operation.

An object is an instance of a class, therefore, an object is not a class, a class of objects born.

Objects that share common structures and performances can not be grouped in a class except by
nature objects.
A class is the mold of a compound data type, and an object representing the variable type
memory housed in a class. When you assign a memory space for the object is when we say that
was instantiated, for example:

Consider the class with their respective attributes Rabbit

We can make an instance of this class have similar attributes, but does not mean you have to be
an exact copy of the class rabbit, for example we PEPE object that has the attributes listed
below, and is different from Koko is another rabbit



But both maintain similarities with the class of which have been instantiated

INTERFACE AND IMPLEMENTATION

If a class is segmented this can have two views, one internal and one external, the external form
its interface while the inner shape its implementation

The interface of a class provides an outside view and emphasizes the abstraction while hiding
the secrets of the structure and functioning. Initially is to declare all methods applicable to
instances of that class, the statement may also be included in other classes, constants, variables,
and exceptions, ie properties necessary to complete abstraction.

The implementation of a class provides the internal view, which covers the "secrets" of the
operation. The implementation of a class is to implement all the methods defined in the
interface.

A class interface basically consists of three parts:

   PUBLIC: Statements available to all customers.
   PROTECTED: Statements accessible only to its class, its subclasses and their friends.
   PRIVATE: Statements accessible only to the class and their friends (friends refers to what is in
the class and its methods).

Relationships between classes

In particular, the problem domain abstractions relate obtained in different ways, the totality of
these relations are known as class structure. Relations between two classes have two main
reasons:

   A list of classes may indicate the hierarchical share some characteristics. A list of classes may
indicate some connection semantics.
There are three basic types of relationships:

  Generalization / specialization. In this, two classes are linked by the relationship
  Total / Party. Two classes are linked by the relation "part of"
  Association. Two classes are linked by descent semantics

Programming languages, specifically object-oriented, providing direct support for some
combinations of the following relationships:

 Association. The association denotes a semantic dependence, ie, their relationship is applied in
concept and is not required to encode physical dependence.



The association is named after the link through which bind classes and indicates a direction to
hear the reading direction of the association for their classes.



At the time of analysis are extremely useful to indicate dependencies, without elaborating. An
association has a cardinality between parts to indicate the number of classes associated with
another number of classes




  Inheritance.
For there must be an inheritance subclass can inherit the structure and operation of its
superclass.



Inheritance is the relationship between classes, where one class shares the structure and / or
function defined in a class (single inheritance) or more classes (multiple inheritance).



The class to inherit property is called superclass and inherited class is called subclass.



A subclass can increase or restrict the structure and operation of its super class. When a subclass
increases its superclass is said that "inherited by extension".



When a superclass is designed to group functionality and structure, but not designed to create
instances is called abstract class.
What are the clients of a class?
Polymorphism is useful when tenemosmuchas classes with the same protocol.



With polymorphism, eliminating large CASE instruction type, for each known object type and
therefore known to react.



Polymorphism is a concept, where the name of a method, operations may denote objects of
various kinds, as long as these are related by some common superclass.



An object is enabled to respond as required by the message, despite having the same method
name, for example:



It's like talking about the method to drive a car and a standard automatic, both methods are
consistent with the name but have different solution sequences, furthermore, both derived
from the car class.



The need for multiple inheritance in programming languages oriented OOP is a great debate,
because multiple inheritance is like having many parents for a child. One of the problems raised
by the presence of multiple inheritance is an ancestor inheritance of more than one possible
conceptual path, this situation is called inheritance repeated. The problem arises if the child's
parents have different religions, therefore, be difficult to choose a religion.
CLASSES AND OBJECTS AS THE ANALYSIS AND DESIGN

In all practical applications are always static classes, so their existence, and semantic
relationships are fixed, but the objects are dynamic, being created and destroyed at the time of
program execution

ANALYSIS AND DESIGN RULES

During the initial stages of analysis and design, developers have two primary tasks

- Identify the classes and objects of the vocabulary of the problem domain.
- Inventing the structures with which objects work to provide the solution to the problem.

Classes and objects are called abstraction of the problem, and the structures are called
cooperative implementation mechanisms.

In the analysis it is important to focus attention on the external view of the abstractions and
implementation mechanisms. These views represent the logical framework of the problem

In the implementation of design attention is fixed on the inside view of the abstractions and
mechanisms of implementation, thus involving physical framework.

BUILD QUALITY

Process design of classes and objects is incremental, iterative, to determine whether a class or
object is well designed can be measured based on:

- Coupling. A measure of strength in the partnership established by a connection from one
module to another or between classes, a strong coupling avoids the independence between
modules or classes of system, a module or class is tightly coupled hard to understand, change or
correct therefore the complexity of system design can be reduced using a weak coupling
between modules or classes
- Cohesion. A measure of the degree of community among design elements
OO as a module, simple objects or simple classes, the least desirable form of cohesion is
coincidental, in which abstractions are complete unrelated grouped in the same class or module.



Coupling and cohesion are criteria to allow a class or module be sufficient, whole and primitive.



- Sufficiency. For sufficiency means that class or module have characteristics indispensable to
permit abstraction and iteration different meaning, but using the minimum necessary
- Fortitude. This means the class or interface module that captures everything
abstraction without significant gaps, a class or module must have a

general interface to be useful to any customer allowing us to obtain reusable code for different
purposes, one must also consider that as long as general design and construction.
- Primitiveness. If too many methods provided in levels get final levels
end resorts but many methods may leave early levels to achieve a grouping of operations. If
necessary increase the functionality sufficient to rely on primitive classes




SELECTION METHODS

Planning a class or interface module is usually very hard work, it is advisable to make a first
attempt to design a class, then to rely on the needs of their clients created is determined
whether increases, modifies and redefines interface, but worth saying that you need to have a
general thought at all times to allow classes capable of responding to different customers.

If in a given class are stored all methods in primitive form is displayed and well defined small
operation, a good designer knows the balance between wanting many contracts: large classes in
methods, and few contracts: small classes with many relationships.

Methods can be placed taking into account the following criteria.

 Reusability. Useful operation in more than one context.
 Complexity. Difficulty of implementing the operation.
 Applicability. Operating Considerations for specific contexts
 Implementation Knowledge. The implementation of the operation depends upon internal
details of the class.

SELECTION OF FOREIGN

The relationship between classes and objects is linked to the choice of methods.

If it is decided that in order to send an "m" to object B, then B can directly or indirectly be
accessible to A, for which they must name the operation "m" in the implementation of A,
considering the visibility required

The representation of a class or object should be, almost always, one of the secrets of
encapsulation of abstraction.

An advantage of encapsulation is to make changes to the representation, provided they do not
apply a functional violation of the assumptions made by the customer. This happens without
affecting any of its customers or contract because the protocol is not affected

CLASSIFICATION

To find the solution of a problem is necessary to discover and identify. The process of
discovering abstractions and mechanisms to look detached from the vocabulary of the problem
domain plus some other implicit

If we rely on the classification of the abstractions and mechanisms are identified generalization
hierarchies, specialization and aggregation.

Classification is a tool to modularize, you can place certain classes and objects in the same
module depending on the similarities of their statements. The similarity can be obtained using
the cohesion and coupling.

The classification will always be related to the focus, vision, experience and need the classifier.

IDENTIFICATION OF CLASSES AND OBJECTS

Historically there are three basic approaches to classify:

No classification is absolute, because some structures can be mostly favored classes of one
application to another, no classification scheme represents the actual structure or the natural
order. Some classifications may be more significant over other as our interest but not represent
reality more accurately or adequately but to serve our purposes

Classification classic. - All entities with a property or collection of properties common form a
category, the traditional classification comes from Plato, Aristotle then, by means of classifying
plants and animals, and to find answers to questions like: Is animal? Is Mineral? Is it vegetable?

One thing can be named according to the knowledge gained from the nature of their properties
and effects, the practical approach using real estate as a criterion of similarity between objects,
specifically objects can be grouped into sets depending on the presence or absence of a
particular property
Conceptual clustering. - It is a modern variation of the classical approach of trying to explain
derivative knowledge, this approach class or group of entities is generated to make the first
conceptual description of the class. The long tapering conceptual clustering with fuzzy theory in
which objects belong to one or more groups of attitudes varying degrees, depending on the
classification considers the functionality of their bodies.

The traditional classification and conceptual clustering are sufficient to explain most complex
designs classifications

Prototype theory. - Is derived from the use of cognitive theory, if we try to classify games and
they can not be properly represented by the classical mold by not sharing similar properties all
games, however the team's theory unifies game ratings as family resemblances. An object class
is represented by a prototype object and an object is considered a member of that class if and
only if it is similar to the prototype significantly.

Instead prototype theory unifies the classification of games as family resemblances, an object
class is represented as an object prototype and an object is considered a member of this class if
and only if it is similar to the prototype significantly.

Currently these three classification approaches have direct application to object-oriented
design.
CLASS 9
Primitive Data Types in Java

A data type is an attribute or characteristic that is the data-this serves to tell the
computer what kind of information to be processed, for example, what values can take
and what operations can be performed with them. The most common data types are:
integers, floating point numbers (decimal), strings, dates, times, colors, etc.. Below is a
table of the most primitive data types used, and a description of each.
Boolean
ie values that can be true or false. Occupies 1-bit and the default value is false
char
The characters are 16-bit and are encoded in Unicode 1.1.5, in other languages are
only 8-bit ASCII. Occupies 16-bits
byte
unsigned 8-bit integer, ie the fewer number (two to the seventh) and two in the eighth.
The internal representation is in 2's complement
Short
unsigned 16-bit integer. The internal representation is in 2's complement
int
unsigned 32-bit integer. The internal representation is in 2's complement
Long
unsigned 64-bit integer. The internal representation is in 2's complement
float
32-bit real mobile with coma. The internal representation is IEEE 754-1985.
doublé
32-bit real mobile with coma. The internal representation is IEEE 754-1985.
Each primitive type has an associated class, you can store the same information but
always through objects.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
Core Java
Core JavaCore Java
Core Java
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Java notes
Java notesJava notes
Java notes
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Java features
Java featuresJava features
Java features
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
java training in jaipur|java training|core java training|java training compa...
 java training in jaipur|java training|core java training|java training compa... java training in jaipur|java training|core java training|java training compa...
java training in jaipur|java training|core java training|java training compa...
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Core java
Core javaCore java
Core java
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Poject documentation deepak
Poject documentation deepakPoject documentation deepak
Poject documentation deepak
 

Destaque

Manuales lenguaje de programación java el lenguaje de programación java nxt
Manuales lenguaje de programación java el lenguaje de programación java nxtManuales lenguaje de programación java el lenguaje de programación java nxt
Manuales lenguaje de programación java el lenguaje de programación java nxtCesar Martinez Collazos
 
Introducción a la Programación en Java
Introducción a la Programación en JavaIntroducción a la Programación en Java
Introducción a la Programación en Javapbcanessa
 
High Five Conference Program
High Five Conference ProgramHigh Five Conference Program
High Five Conference ProgramArik Abel
 
Programación en Java (I)
Programación en Java (I) Programación en Java (I)
Programación en Java (I) Cristian
 
Manual declaracion 22_pn y pj_islr
Manual declaracion 22_pn y pj_islrManual declaracion 22_pn y pj_islr
Manual declaracion 22_pn y pj_islrUNEG
 

Destaque (7)

The green rush
The green rushThe green rush
The green rush
 
Manuales lenguaje de programación java el lenguaje de programación java nxt
Manuales lenguaje de programación java el lenguaje de programación java nxtManuales lenguaje de programación java el lenguaje de programación java nxt
Manuales lenguaje de programación java el lenguaje de programación java nxt
 
Introducción a la Programación en Java
Introducción a la Programación en JavaIntroducción a la Programación en Java
Introducción a la Programación en Java
 
High Five Conference Program
High Five Conference ProgramHigh Five Conference Program
High Five Conference Program
 
Programación en Java (I)
Programación en Java (I) Programación en Java (I)
Programación en Java (I)
 
Manual declaracion 22_pn y pj_islr
Manual declaracion 22_pn y pj_islrManual declaracion 22_pn y pj_islr
Manual declaracion 22_pn y pj_islr
 
Lenguaje de programación java
Lenguaje de programación javaLenguaje de programación java
Lenguaje de programación java
 

Semelhante a Class 1

OOPM Introduction.ppt
OOPM Introduction.pptOOPM Introduction.ppt
OOPM Introduction.pptvijay251387
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Chapter1pp
Chapter1ppChapter1pp
Chapter1ppJ. C.
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_javaHarry Potter
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingJames Wong
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_javaHoang Nguyen
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_javaTony Nguyen
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingYoung Alista
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingFraboni Ec
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingLuis Goldster
 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)yuan99
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsMukesh Tekwani
 
Learn java in one day and learn it well 2016 jamie chan
Learn java in one day and learn it well 2016   jamie chanLearn java in one day and learn it well 2016   jamie chan
Learn java in one day and learn it well 2016 jamie chananand_study
 
1 2 java development
1 2 java development1 2 java development
1 2 java developmentKen Kretsch
 
R:\ap java\class slides\chapter 1\1 2 java development
R:\ap java\class slides\chapter 1\1 2 java developmentR:\ap java\class slides\chapter 1\1 2 java development
R:\ap java\class slides\chapter 1\1 2 java developmentKen Kretsch
 

Semelhante a Class 1 (20)

OOPM Introduction.ppt
OOPM Introduction.pptOOPM Introduction.ppt
OOPM Introduction.ppt
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter1pp
Chapter1ppChapter1pp
Chapter1pp
 
Presentation5
Presentation5Presentation5
Presentation5
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
212 kuliah 01   pengenalan pemrograman berorientasi objek (java)212 kuliah 01   pengenalan pemrograman berorientasi objek (java)
212 kuliah 01 pengenalan pemrograman berorientasi objek (java)
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs concepts
 
Learn java in one day and learn it well 2016 jamie chan
Learn java in one day and learn it well 2016   jamie chanLearn java in one day and learn it well 2016   jamie chan
Learn java in one day and learn it well 2016 jamie chan
 
1 2 java development
1 2 java development1 2 java development
1 2 java development
 
R:\ap java\class slides\chapter 1\1 2 java development
R:\ap java\class slides\chapter 1\1 2 java developmentR:\ap java\class slides\chapter 1\1 2 java development
R:\ap java\class slides\chapter 1\1 2 java development
 

Class 1

  • 1. Class 1 How to start programming in Java? This part of the study material is not intended to address still concepts, but rather, you can configure any computer window xp or Windows 7 32 or 64 bit and get it ready to start programming. First of all: Installing "jdk-7u7-nb-7_2-windows-i586-ml" JDK "Java Development Kit", will not only compile but run applications, available for a variety of operating systems: http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html METHOD 1: Use the Shell to run java code This point is important for you to read and performers very well using the following commands: • javac.exe, compiler generated files *. Apartir class source code (*. Java). The *. Java is text, you can create and edit in a text editor, using the syntax of Java. • Java.exe, systems interpreter for PC / Windows, executes bytecode files (files compiled class extension). The *. Class have executable code, bytecode, platform independent, to be executed on a "hypothetical or virtual machine" called Java Virtual Machine (JVM). Is this JVM neutral who plays this code making a particular code on the CPU used. This avoids having to make a different program for each CPU or plataforma.1 Shell enters the system and see what happens when Digitas commands: java or javac. You will realize that the javac command is not enabled, therefore the following steps and then try to use the command in question, the difference observed. Remember watching the second image of this manual and look in the directory where it is located javac command.
  • 2. To educate the system accepts this command indicating that we should add "environment variables" as indicated in the graph. Creating our first program in java Install then an editor to start coding (in this case Notepad + +) After that, create the following program and save it in the directory "c: ProgramasJava" Note that the file name must be named identical to the class, using case sensitive. Finally run the program, first compile the program with javac and then running the java program. METHOD 2: Using the Eclipse IDE ENTERNO (Available at www.eclipse.org - Section "downloads" download the Eclipse Classic 4.2) This method is much faster than before, it is a method of abstraction for programming while we should not install the JDK, and load the necessary libraries to program without tread very rodeo. STEP 1: Download and unzip the file indicated STEP 2: After that opening the Eclipse IDE, the program requests a folder where you will save the projects that we believe in java, proceed as indicated in the graph (you must create the folder previously). STEP 3: Follow the following sequence of actions to create a project in java. Look what happens next.
  • 3. Now insert a class as follows With the IDE, the only line of code you write play, which was noted below Run the program with the button, watch out. Further notes what happened in "ProgramasJava2" you created. REFERENCES http://www.ajpdsoft.com/modules.php?name=news&file=print&sid=270 CLASS 2 Step by step creation of the first program in Java using Eclipse 1. Run the sequence of actions detailed in the chart. 2. Run after the sequence of actions detailed in the chart. 3. Insert a class called "PruebaAlbum" as follows. 4. Now insert a class called "Album", in the same way as the previous step.
  • 4. 5. The result after the above steps is a structure as follows. 6. Declare the following attributes within the class "Album" 7. Then set the SET and GET methods (methods are inserting, modifying and extracting the values that variables may have happened before, "automatically generated"), this operation is called to create getters and setters. 8. Notice how you generated the following code block without you had to write something. 9. Define the following constructor. The constructor is a method that must have the same name as the class and is used to initialize the attributes of an object, usually receives values have past, a quick way is to develop a method using getters and setters the previous step. 10. Now we instantiate an object of class "Album" in class "PruebaAlbum", this instance or reference to create should be made in the main. See how you created two instances, and the way in which you can send arguments. 11. In the previous step we created two instances, how can we show these values on screen? We must develop a new method in the "Album", will be called "ImprimirAlbum" 12. Then call the method created from the two instances declared in step 10.
  • 5. 13. And finally see the execution, after clicking on the button should appear something as follows: Class 3 INTRODUCTION TO JAVA CONCEPTS Java and all Java-based trademarks are trademarks of Sun Microsystems.1 What is Java JDK? JDK stands de java Developers Kit is, toolset to develop (applications) in countless classes Java. Existen accompanying the JDK that is installed in order to get started programming in JAVA. What makes it different from the other JAVA programming languages? What distinguishes Java from other programming languages is its conception of departure, in which language is to create a road that can be used to program in all types of operating systems and processors. One of the most important features is that the programs "executable", created by the Java compiler, are independent of the architecture. Run interchangeably in a variety of microprocessors and computers with different operating systems. Is the language is compiled or interpreted? Java is compiled when the source code is translated into an object called machine code (binary, bytecode) and is interpreted because the machine code can be run on any platform which should be an interpreter executing it in real time.
  • 6. To run it, you need an interpreter, the JVM (JavaVirtual Machine) Java virtual machine. Thus, it is possible to compile the program on a UNIX workstation and run it on another Windows using the Java virtual machine for Windows. This JVM is responsible for reading the bytecodes and translate them into executable instructions directly on a particular microprocessor. The Java Virtual Machine (JVM). The Java virtual machine is the revolutionary idea of language. It is the entity that provides platform independence for Java programs compiled into byte-code. Bibliography http://es.scribd.com/doc/3258260/98/La InputStream class- http://ingensis.blogspot.com/2010/06/java-is-a-language-compiled-e.html http://www.alegsa.com.ar/Diccionario/C/4133.php http://www.alegsa.com.ar/Diccionario/C/4133.php Class 4 The programmer must establish the association between the machine model "solution space" that is where to deploy the solution, such as a computer, and the problem is what you really want to solve "problem space" that is where the problem exists, the business. What is an abstraction? Alan kayresumion the five basic characteristics of Smalltalk for an object, the first object- oriented language that was successful and one of the languages that is based on JAVA. These characteristics represent a pure approach to object-oriented programming. 1. Everything is an object. Think of an object as a variable stores data, allows you "raise requests" asking him to perform operations on itself. In theory, you can take any conceptual component of the problem that is being addressed. 2. A program is a bunch of objects that tell each other what to do r sending messages. To make a solicitude to an object, you must send a message to that object.
  • 7. More specifically, you can think of a message is a request to call a method that belongs to a particular object. 3. Each object has its own memory made up of other objects. Stated another way, you can create a new class of Obeto defining a package containing existing objects. Therefore, it may increase the complexity of a program hiding behind the simplicity of the objects. 4. Every object has an associated type. As the saying goes, every object is an instance of a case where "class" synonymous with "type." The most important distinguishing characteristic of a class is "the set of messages that can be sent." 5. All objects of a particular type can receive the same messages. As discussed below, this statement is really important. Since an object of type "circle" is also an object of type "shape," a circle can be guaranteed to accept shape messages. This means that you can write code to communicate with objects of type form and automatically control anything that fits the description of a form. This capability is one of impersonation most important concepts of OOP. Booch offers an even more succinct description of object: - An object has state, behavior and identity. This means that an object can have internal data (which provides state), methods (to provide a behavior) and each object can be uniquely distinguished from other objects, ie, each object has a unique memory address . The object-oriented approach Reference is made to the elements in the problem space called "objects" to their representations in the solution space. The idea is that the program can adapt by itself to the lingo of the problem by adding new types of objects so that when you read the code describing the solution, you are reading words that also express the problem. Thus OOP allows you to describe the problem in terms of the problem rather than in terms of the computer. Why use classes? Since a class describes a set of objects having characteristics (data elements) and behavior (functionality) identical actually a class is a type of data because, for example, a floating point number also has a set of characteristics and performance . The difference is that the programmer defines a class to fit a problem rather than force the use of an existing data type that was designed to represent a storage unit in a machine. You can extend the programming language by adding new data types specific to suit your needs. The programming system supports the new classes and provides all combinations of type providing defined types. Creating abstract data types (classes) is a fundamental concept in object-oriented programming.
  • 8. What is an object? Once a class has been defined, you can create as many objects of that class as desired and these objects can be handled as if the elements of the problem that is being addressed. But how do you make a object do useful work for the programmer? There must be a way to make an application in order to do something, such as complete a transaction, draw something on screen or a switch. What is an interface Also, each object can satisfy only certain requests. Requests can be made to an object are defined by its interface and is the type that determines the interface. An example with the representation of a light bulb: The interface determines the applications that can be done to a certain object, so there must be a code somewhere to satisfy that request. This, along with the hidden data, define what it calls the implementation. From the standpoint of procedural programming, this is not complicated. One type has a method associated with each possible request, and when a specific request is made to a objesto, this method is called. This process is summarized by saying that the developer "send a message" (make a request) to an object and the object knows what to do with this message (it executes the code). In this example, the name of the type / class is Light, the name of this particular object is lz Light and applications that can be done to an object light is on, off, or dim glow. It has created a light object defining a "reference" (lz) for that object and calling new to request a new object of that type. To send a message to the object, defined the object name and is related to the application of the message by a point. From the point of view of the user of a predefined class, that is the ultimate programming objects. The diagram above follows the format of UML (UnifiedModelingLanguage, Unified Modeling Language). Each class is represented by a box by typing the name of the guy at the top, the data members in the intermediate zone and methods (functions of said object receiving any message sent to the developer that object) in the bottom . Often in these diagrams only show the name of the class and public method, not including the buffer zone, as in this case. If you are only interested in the class name, it is not necessary to include the bottom. Class 5
  • 9. Primitive data types IN JAVA There are a bunch of guys that are used very often in programming and requires special treatment. Types can be considered as "primitive", the reason for this special treatment is that to create a new object, a simple variable small, not efficient. To these primitive types, Java uses the technique used in C and C + +, that is, instead of creating the new variable creates a variable "automatic" is not a reference. Java determines the size of each primitive type. These sizes do not change from one machine architecture to another. This invariability of the sizes is one of the reasons of portability java. Defaults primitive members When a primitive data type as a member of a class, Java guarantees that you will be assigned a default value if it fails to boot: The defaults are only the values that Java guarantees when the variable is used as a class member. This ensures that the member variables of primitive type always be initialized (something C + + does not do), reducing a source of potential errors. However, this initial value may not be correct or even legal for the program you are writing. It is best to always initialize variables explicitly. This warranty does not apply to initialize local variables, those that are not class fields. Class 6 CONCEPTS OF OBJECT-ORIENTED PROGRAMMING (OOP) 1 What is OOP? Is to develop programs from objects. These objects waiting messages, process and send messages to other objects. In object-oriented programming, objects are defined that make up an application. These objects are formed by a series of features and operations that can be performed on them. 2 What is an object?
  • 10. The answer to this question in terms outside the programming seems simple. An object is a person, animal or thing. It is distinguished from other objects to have certain characteristics and is good for something, or put another way, you can perform various operations with or on that object. For example: A house is an object. FEATURES: Number of floors, Total height in meters, the facade color, number of windows, door number, city, street and number where it is located, etc.. OPERATIONS Build, destroy, painted facade, modify any of the characteristics, such as opening a new window, etc. Obviously, each object can be defined in terms of a multitude of features and an extensive array operations. Now in terms of programming, the programmer mission will determine what features and interest to maintain operations on an object. For example, on the home object may not be necessary to know its location and therefore, these features are not part of the object defined by the programmer. The same could be said about the operations. In terminology of object-oriented programming, the characteristics of the object are called attributes and operations METHODS. Each of these methods is a procedure or function belonging to an object. FORMAL INFORMAL TERMINOLOGY Terminology FEATURES ATTRIBUTES Operations (procedures and functions) METHODS An object is formed by a number of features or data (attributes) and a set of operations (methods). No conceivable only on the basis of data or operations but as a whole. Example: Think about what methods would be needed to make a car turn Insert the key Turn the key This would trigger the electrical system The engine ignite
  • 11. 3. Classes and Objects In OOP we must distinguish between two closely related concepts, the class and object. Analogous to how to define variables in a programming language, when you declare an object must define the type of object to which it belongs. This type is the class. In C, we define two variables X and Y integer as follows: int X, Y; In this case, X and Y are variables and the type of these variables is integer. The way to declare objects in Java is the same: Ccasa casa1, house2; In this case, house2 casa1 and variables are effectively but somewhat special, are OBJECTS. Furthermore, the type of objects is Ccasa. This type is the class of the object Analogy Variable → Object (X, Y) (casa1, house2) → Class Type (Int) (Ccasa) Declaring casa1 and house2 as objects belonging to the class Ccasa, it indicates that house2 casa1 and have a number of attributes (data) and are nPuertas, nVentanas and color, and also a number of methods (operations that can be performed on them) as: abrirVentanas (), cerrarVentanas (), etc.. 4. Properties must meet to be considered a language object oriented.
  • 12. POTTING INHERITANCE POLYMORPHISM Encapsulation Encapsulation is the property possessed objects hide their attributes, and even methods to other parts of the program or other objects. The natural way to build a class is to define a set of attributes which generally are not accessible outside of the same object, but can only be modified by the methods which are defined as accessible from the outside of that class. Ccasa class { int nPuertas, nVentanas; String color; public Ccasa (int np, int nv, co String) { nPuertas = np; nVentanas = nv, color = co; } public void paint (String co) { color = co; } public void abrirVentanas (int n) { nVentanas = nVentanas + n; } public void cerrarVentanas (int n) { nVentanas nVentanas =-n; if (nVentanas <0) nVentanas = 0; } public void abrirPuertas (int n) { nPuertas = nPuertas + n; } public void cerrarPuertas (int n) { nPuertas nPuertas =-n; if (nPuertas <0)
  • 13. nPuertas = 0; } } / / HERE STATEMENT Ccasa casa1 objects and instances, house2; The normal way to declare the class Ccasa is to define a set of attributes that are not accessible from anywhere in the program, but only through certain methods. So, if you open a new window in the house casa1, traditional philosophy of a programmer would do the following: casa1.N_VENTANAS casa1.N_VENTANAS = + 1; However, the natural way to do it in OOP is calling the method: casa1.abrirVentanas (1); That method (procedure) will increase by 1 nVentanas attribute. This does not mean that the attribute can not be accessed nVentanas the traditional way (if it had been defined as public, but for that language may be regarded as OOP, should allow for the possibility of prohibiting access to the attributes directly. Inheritance. One of the main advantages of OOP. This property allows you to define other descendant classes, so that the new class (the child class) inherits from the parent class all its attributes and methods. The new class can define new attributes and methods can even redefine existing attributes and methods (for example, change the type of an attribute or operations performed by a given method.) Is the natural way to define objects in real life. Most people would say, for example, that a house is a house with a garden. It has the same characteristics and properties or operations you can perform on a house and also incorporates a new feature, the garden. At other times, they added functionality (methods) and attributes. For example: a duck is a bird that nothing. It has the same characteristics as the birds and should only declare a method on the new class (the swim method). This property enables code reuse and is very easy to take advantage of the existing class code, modifying them minimally to fit the new specifications. Example: Suppose we have constructed Ccasa class and we want to define a new class that represents the chalets. In this case you may want to define a new attribute that represents the square meters of garden. Instead of redefining a new class from scratch, can be used for writing code Ccasa class as follows.
  • 14. As can be seen, only have to declare that the new class is a descendant of Ccasa Cchalet (extends Ccasa) and declares the new attribute. Clearly, we must redefine constructor method to initialize the new attribute mJardin. But the methods for open / close doors or windows is not necessary to define them, are Ccasa inherited from class and can be used, for example as follows: chalet1.pintar ("White"); Polymorphism Polymorphism allows the same message to objects of different classes do these also behave differently (different objects can have methods with the same name or the same object methods can have identical names but different parameters) Ccasa class { public Ccasa (int np, int nv, co String) { nPuertas = np; nVentanas = nv, color = co; } public Ccasa () {nPuertas = 0; nVentanas = 0, color = ""; } } You have two methods with the same name but different parameters. In the first case, the attributes of the object initialized with the parameters of the method and in the second case will be initialized to zero, for example. Also, if you have two objects and chalet1 casa1 and calls the method: chalet1.abrirVentanas (2) Will execute the procedure code abrirVentanas Cchalet class and class Ccasa.
  • 15. Bibliography http://es.scribd.com/doc/3258260/98/La-clase-InputStream Class 7 'Class' The classes are the mold for the creation of objects comprise:  Methods. - Functions programmed to perform a certain task.  Attributes. - Variables we will use in our program.  Builders. Method  main (in the case of JAVA) In Java, almost all are classes (objects). The language requires the OOP and allows the possibility to program using any other technique other than this. For this reason, a program will consist of one or more source files and each will have defined one or more classes. In a source file can declare one or more classes and will look similar to this: class Class1 { ... } class Class2 { ... } Clasen class { ... } A class consists of a portion of the return, and another for the body of the same: Class Declaration { Class body
  • 16. } In the previous template has simplified the look of the class declaration, but you can make sure that it contains at least the keyword class and the name given to the class. The body of the class starts with an open brace ({) and ends with a closing brace (}). Within the body of the class are declared attributes and class methods. For everything written in Java alone program starts running (as in C) from the main () method. public: indicates that the method main () is public and therefore can be called from other classes. All main () method must be public in order to run from the Java interpreter (JVM). static: indicates that the class does not need to be instantiated in order to use the method that qualifies. (Not create any instance or object class Hello). It also indicates that the method is the same for all instances that may be created. void: indicates that the main function returns no value. The main method must always accept, as a parameter, an array of strings, containing the possible arguments that are passed to the program on the command line, but as in our case, not used. "Conventions for writing classes, objects and methods" The following is not necessarily a rule, is only a convention in this case that seeks to make Java code more readable touch for when you check your code and correct it.  Classes always begin in uppercase as well as each of the words that follow. Example: myFirstClass  methods instead start with lowercase letter and then capitalized on each additional word is used. Example: esteEsMiPrimerMetodo ()  Attributes like methods start with lowercase, and words have the same start with a capital letter. Example: esteEsUnAtributo Bibliography http://es.scribd.com/doc/3258260/98/La-clase-InputStream www.legga.com Class 8 Object modeling
  • 17. The term object arises in the late seventies in computer science, to reference notations to problem solving, which are apparently different but mutually linked from a perspective different from structured analysis. These notations define objects representing components of the modular system is decomposed to define knowledge. This model looks at reality as objects interacting with responsibilities, where each object could contain internal objects to form more functionality complex. Were set out different ways to perform the analysis, design and programming, and that variety is still present. Object Oriented Analysis is a method of analysis to examine the requirements from a class of objects that are searched in the vocabulary of the problem domain, in order to represent the user experience in outlining the requirement Object Oriented Design is a design method for understanding and process decomposition and object-oriented notation obtaining the logical model is class and object structures and the physical model is architecture modules and processes as well as static models and dynamic. The Object-oriented programming is the design implementation, where programs are collections of cooperating objects. Each object belongs to a class hierarchy, and classes belong to a hierarchy of classes related by inheritance. Object orientation provides elements to develop solutions based on their theory, and are those seen in the graph. Additionally there are three minor elements of the object model, and are now marked in purple. What is abstraction? An abstraction denotes the essential characteristics of an object distinguishable from other objects and provides conceptual limits to the viewer's perspective. When looking abstractions is necessary to focus on the important details, primarily on similarities, differences ignoring for the moment to describe and specify some details of the system and not go through the relevant unnoticed. A concept can be an abstraction only if it can be described, understood and analyzed independently of the mechanisms used to achieve its goals. Abstractions are always influenced by the observer according to their experience and needs.
  • 18. Abstraction is the recognition of the similarities between objects, situations or real-world processes. The abstraction focuses attention on the external view of the object to separate the essential functioning of the object from its implementation, which is the principle of abstraction barrier. Obtaining the abstractions of the problem domain is the core of object-oriented design, which can be grouped into: Abstraction of Bank says that an object represents a useful model of the problem domain or the domain of a solution which has a personality. Abstraction of Action states that an object provides a generalized set of operations which perform the same function type Class 8 Object modeling The term object arises in the late seventies in computer science, to reference notations to problem solving, which are apparently different but mutually linked from a perspective different from structured analysis. These notations define objects representing components of the modular system is decomposed to define knowledge. This model looks at the reality and responsibilities interacting objects, where each object could contain internal objects to form more complex functionality. Were set out different ways to perform the analysis, design and programming, and that variety is still present. Object Oriented Analysis is a method of analysis to examine the requirements from a class of objects that are searched in the vocabulary of the problem domain, in order to represent the user experience in outlining the requirement Object Oriented Design is a design method for understanding and process decomposition and object-oriented notation obtaining the logical model is class and object structures and the physical model is architecture modules and processes as well as static models and dynamic object-oriented programming is the design implementation, where programs are collections of cooperating objects. Each object belongs to a class hierarchy, and classes belong to a hierarchy
  • 19. of classes related by inheritance. Object orientation provides elements to develop solutions based on their theory, and are those seen in the graph. Additionally there are three minor elements of the object model, and are now marked in purple. What is abstraction? An abstraction denotes the essential characteristics of an object distinguishable from other objects and provides conceptual limits to the viewer's perspective. When looking abstractions is necessary to focus on the important details, primarily on similarities, differences ignoring for the moment to describe and specify some details of the system and not go through the relevant unnoticed. A concept can be an abstraction only if it can be described, understood and analyzed independently of the mechanisms used to achieve its goals. Abstractions are always influenced by the observer according to their experience and needs. Abstraction is the recognition of the similarities between objects, situations or real-world processes. The abstraction focuses attention on the external view of the object to separate the essential functioning of the object from its implementation, which is the principle of abstraction barrier. Obtaining the abstractions of the problem domain is the core of object-oriented design, which can be grouped into: Abstraction of Bank says that an object represents a useful model of the problem domain or the domain of a solution which has a personality. Abstraction of Action states that an object provides a generalized set of operations which perform the same function type Virtual Machine states that an object abstraction grouping of operations used in an upper or lower level control is associated with a set of common purposes verbs Abstraction coincidental groups a set of operations or unrelated models and are associated with a set of verbs or nouns unrelated Every good abstraction reflects how well you manage the system vocabulary What is encapsulation? The abstraction of an object precedes the implementation of its services, the implementation of
  • 20. an object is a secret for abstraction and should be hidden for its customers, leaving as the only answer to their service commitment regardless of how the fix, making nowhere a complex system depends on the implementation of some other object, edging to respect the purpose of this abstraction While the abstraction suggests to do, encapsulation is directed at how it will perform, allowing programs to reliably change with minimal effort this barrier. Encapsulation and abstraction are complementary concepts, abstraction focuses on the operation of an object observable. The encapsulation is focused on the implementation which gives rise to the operation. The class of an object that is born must have two parts: An interface for services that are related to other objects, also known as external view. An implementation which is the implementation of services is known as internal view The encapsulation of the idea of having a very complex system that requires much attention and become an object that handles everything internally and can be created easily. Encapsulation is a process of sharing of elements constituting an abstraction of its structure and operation, serves to separate encapsulation of an abstract interface and implementation. Modularity The target an individual program components also reduces complexity of grouping a set of components for some purpose or common feature allowing components locate efficiently Modularity is performed to divide a system into modules separately compilable, but with certain minimum connections dependencies with other modules. Modularity takes care of packing abstractions in discrete units called modules, ie the physically packaged modularization classes and objects. By modularizing takes advantage of the cost reduction of software design and review allowing independent modules even reuse core modules for any system. To achieve good modularity, modules should be constructed: Modularity is the property of a system of decomposed into a cohesive set of modules with weak couplings.
  • 21. There are three factors likely to accept the decisions of modularization: The modules serve as indivisible units of software that can be reused in other applications. Many compilers can generally object code in segments, one for each module. A good code modularization allows quickly locate function as a map. HIERARCHY A hierarchy is a rank or order of abstractions. A set of abstractions can repeatedly form a hierarchy. By identifying hierarchies in the design, understanding the problem is simplified. The hierarchy of generalization / specialization is formed by grouping abstractions within the scheme which is a type B of A. For example, a car is a type of vehicle, is therefore to define a relationship between classes, where a class defines the structure and behavior of one or more classes (single inheritance and multiple inheritance respectively) Inheritance represents a hierarchy of abstractions where a subclass (child class) one or more inherited from superclasses (parent class). The structure and operation of the various classes can form a superclass, and the inheritance hierarchy is a generalization / specialization where the superclasses represent generalized abstractions and subclass represents the specialization of the superclass methods, which are added, modified and hidden . The abstraction is intended to provide a barrier to hide the methods and statements, but inheritance opens this interface to see the states and methods without abstraction. There are levels of abstraction, speaking in terms of hierarchy. A high-level abstraction is a generalization and a low-level abstraction is a specialization The hierarchy of total / part is formed by grouping abstractions within the framework of C D is an example: A student is part of a group; Aggregation denotes the ratio total / part of a hierarchy in which several objects are part of a Overall, the set of objects of a group denotes the total lack of any such objects does not affect the overall identity and total destruction does not involve the destruction of conforming parts. A family seen as a total is made up of a father, a mother and children who are the parties, the lack of a child does not destroy the family, but also the division destroys family members. Summary
  • 22. Finally, the encapsulation helps reduce complexity hiding details. The modular group helps the solution to a problem. Abstraction and hierarchy to classify similarities to simplify the understanding Tipeamiento One type is an accurate characterization of the structural and functional properties shared by a collection of entities, classes or objects. A force tipeamiento is a class of an object as well as to other types of objects to be interchangeable or most can be exchanged only for very restricted roads, to have guys like units of measure you can divide distance for a speed type, but not be possible to divide the temperature between weight, tipeamiento requires only to perform certain legal combinations of abstractions. A programming language can be strongly typed, regularly typed or simply not be typed, and still be object-oriented. A strong typing prevents mixing abstractions illogical or unexpected results. A semantic dependency introduces strong typing, so any small change in the class, can interfere with customers who interact with it. A force tipeamiento is a class of an object, and objects of different types, to be interchangeable, or most, may be exchanged only limited changes. The most important benefits of a strongly typed language are: - Detects errors in the cycle of edit, compile and debug, despite being tedious. - The type declaration auida to document a program. - Most compilers generate efficient code when the types are declared. - Disappearance of unpredictable behavior by assuming unwanted conversions. - No type checking a program can rumble mysteriously at runtime. CONCURRENCE Concurrency allows different objects to act simultaneously, each program has at least one child control, but a concurrent program can have multiple threads of control: some transient and others throughout the runtime. The machines run on multithreaded systems truly allow concurrent threads of control A lightweight process shares memory space with another lightweight process, while the combination of a heavy process is assigned its own memory space.
  • 23. An object-oriented system can see the real world as a set of cooperating objects concurrently, with each active site is an independent activity center. Concurrency is the property to distinguish an object from one active inactive in a multithreaded. PERSISTENCE Persistence is responsible for saving the state and the class of an object over time and / or space. Persistence is the property of an object to transcend time (the object continues to exist even after the cessation of its creator) and / or space (the object changes its position in the memory space that was created). Object From the perspective of human knowledge can be an object: Anything tangible or intangible. Anything that can be learned intellectually. Something toward which thought or action can be directed. An object has: - State. - Operation. - Identity. STATE The operation of an object is influenced by its history: the order under which he operates an object is influenced by its history: the order under which an object is important opera. We define an attribute property, or referenced single variable, with an inherent characteristic or distinctive trait or faction which contribute to a single object. The terms property and attribute are indistinct, both refer to the characteristics of an object. The state of an object are all properties (typically static) of an object plus the current values (usually dynamic) of each of these properties. OPERATION The operation of an object acts and reactúa in terms of its state changes and messages posted or transmitted. The operation of an object represents the outside is visible and its activity is measurable. OPERATION
  • 24. It is the action performed by an object to invoke the services of another object in order to get a reaction, the result of the operation will be defined by the object's state at the time of responding to the client. The operations defined for an object are called methods in terms of programming and are defined as procedures and functions "To every action there is a reaction" The state of an object represents an accumulation of results of its operation, a method denotes a service provided by an object to its clients. The three most common types of methods are: Modifier. Method that modifies the state of an object. Selector. Method to query the state of an object without altering the state. Iterative. Method to query all relevant parties to the state of an object with a well-defined value repeatedly. Additionally there are also methods to create and destroy objects: Constructor. The constructor is a method created by an object which is initializer their status Destroyer. It is a method of liberating state of an object and destroyer of it. The role of an object is the mask to define a contract between abstraction and its clients, ie the role of an object is defined by its methods. The responsibility of an object are all services provided to all contracts supported. A role are the services offered by an object, while responsibility is the fulfillment of the services supported by a contract, the state jointly define the role and function of an object to play in the world while meeting their responsibilities The terms are interchangeable and operation method, both refer to its operation IDENTITY Each object is unique, even though sharing the same properties of another object, since it occupies a different space. That is, an object has an authenticity identidad.Esta shown in the variable of time and space. Identity is the property of an object to be distinguished from all other objects.
  • 25. Relationships between objects When multiple objects relate these make assumptions about each other, including the methods performed well as the state of operation. The hierarchy of objects are of two types: - League A league is derived from the physical connection (with a message) or conceptual (no message) of two objects, wherein an object can collaborate with another object by means of a message. The message represents an association between an object that acts as a client using the services of another object acts as a server. The message between two objects is usually unidirectional and bidirectional rarely. An object to interact with another through a league can play three roles. Customer actor. An object can operate on other objects but never be operated by other objects. Server. An object does not operate upon other objects but can be operated by other objects. Agent. An object can be operated on other objects and can be operated on other objects. Namely to serve as a client or server for one or more objects, for example: If we consider two objects: During the analysis of a problem can ignore the visibility, but you need to consider when implementing the visibility through the leagues to determine the scope and access of objects on each side of the league. Currently an object can see another of four ways:  The server object is global customer.  The server object is a parameter of the method of the client.  The server object is an object of the customer.  The object server is locally declared object in a client method. Two objects can communicate through a single league if they are synchronized and to achieve synchronization of an active object with a liability can exist in three forms  Sequential. A passive object synchrony guarantees the existence of a single active object look upon synchronization.  Protected. A passive object ensures synchronization with multiple threads control only when active objects provide mutual exclusion  Synchronized. A passive object ensures synchronization with multiple threads of control only when the passive object ensures mutual exclusion
  • 26. When an object passes a message to another through a link, the objects must be synchronized somehow past messages can take any of the following ways.  Synchrony. An operation begins when the station has initiated the action and the transmitter is ready to both receive the message, the sender and receiver definitely wait until both parties are ready to proceed  Resistance. It is similar to the sync, except that the emitter abandon the operation if the receiver is not completely ready  Waiting Time. It is similar to the transmitter sync except wait a certain time until the receiver is ready  Asynchronous. The issuer can initiate messages regardless of whether the receiver is ready to receive the message. - Aggregation The league denotes a relationship between client server, moreover aggregation denotes a hierarchical part / total to navigate from the whole (aggregate) to any of its parts (attributes). If the lifetime of an object or attribute is determined by the lifetime of the whole object, to be considered as a parameter value is known as the aggregation composition, but if the life time of an object is independent of the time Object life entirety to be considered as a reference parameter known as aggregation,. Aggregation helps encapsulate secret parts as a whole, but the links may be substituted if desired aggregation break the coupling between objects. Aggregation allows objects with complex workings but displayed by the encapsulation as simple objects What are classes? A class is a group, type or group marked by common properties, cot distinction, a classification of qualities or conditions classification. A class is a set of objects sharing a common structure and operation. An object is an instance of a class, therefore, an object is not a class, a class of objects born. Objects that share common structures and performances can not be grouped in a class except by nature objects.
  • 27. A class is the mold of a compound data type, and an object representing the variable type memory housed in a class. When you assign a memory space for the object is when we say that was instantiated, for example: Consider the class with their respective attributes Rabbit We can make an instance of this class have similar attributes, but does not mean you have to be an exact copy of the class rabbit, for example we PEPE object that has the attributes listed below, and is different from Koko is another rabbit But both maintain similarities with the class of which have been instantiated INTERFACE AND IMPLEMENTATION If a class is segmented this can have two views, one internal and one external, the external form its interface while the inner shape its implementation The interface of a class provides an outside view and emphasizes the abstraction while hiding the secrets of the structure and functioning. Initially is to declare all methods applicable to instances of that class, the statement may also be included in other classes, constants, variables, and exceptions, ie properties necessary to complete abstraction. The implementation of a class provides the internal view, which covers the "secrets" of the operation. The implementation of a class is to implement all the methods defined in the interface. A class interface basically consists of three parts: PUBLIC: Statements available to all customers. PROTECTED: Statements accessible only to its class, its subclasses and their friends. PRIVATE: Statements accessible only to the class and their friends (friends refers to what is in the class and its methods). Relationships between classes In particular, the problem domain abstractions relate obtained in different ways, the totality of these relations are known as class structure. Relations between two classes have two main reasons: A list of classes may indicate the hierarchical share some characteristics. A list of classes may indicate some connection semantics.
  • 28. There are three basic types of relationships: Generalization / specialization. In this, two classes are linked by the relationship Total / Party. Two classes are linked by the relation "part of" Association. Two classes are linked by descent semantics Programming languages, specifically object-oriented, providing direct support for some combinations of the following relationships: Association. The association denotes a semantic dependence, ie, their relationship is applied in concept and is not required to encode physical dependence. The association is named after the link through which bind classes and indicates a direction to hear the reading direction of the association for their classes. At the time of analysis are extremely useful to indicate dependencies, without elaborating. An association has a cardinality between parts to indicate the number of classes associated with another number of classes Inheritance. For there must be an inheritance subclass can inherit the structure and operation of its superclass. Inheritance is the relationship between classes, where one class shares the structure and / or function defined in a class (single inheritance) or more classes (multiple inheritance). The class to inherit property is called superclass and inherited class is called subclass. A subclass can increase or restrict the structure and operation of its super class. When a subclass increases its superclass is said that "inherited by extension". When a superclass is designed to group functionality and structure, but not designed to create instances is called abstract class.
  • 29. What are the clients of a class? Polymorphism is useful when tenemosmuchas classes with the same protocol. With polymorphism, eliminating large CASE instruction type, for each known object type and therefore known to react. Polymorphism is a concept, where the name of a method, operations may denote objects of various kinds, as long as these are related by some common superclass. An object is enabled to respond as required by the message, despite having the same method name, for example: It's like talking about the method to drive a car and a standard automatic, both methods are consistent with the name but have different solution sequences, furthermore, both derived from the car class. The need for multiple inheritance in programming languages oriented OOP is a great debate, because multiple inheritance is like having many parents for a child. One of the problems raised by the presence of multiple inheritance is an ancestor inheritance of more than one possible conceptual path, this situation is called inheritance repeated. The problem arises if the child's parents have different religions, therefore, be difficult to choose a religion. CLASSES AND OBJECTS AS THE ANALYSIS AND DESIGN In all practical applications are always static classes, so their existence, and semantic relationships are fixed, but the objects are dynamic, being created and destroyed at the time of program execution ANALYSIS AND DESIGN RULES During the initial stages of analysis and design, developers have two primary tasks - Identify the classes and objects of the vocabulary of the problem domain. - Inventing the structures with which objects work to provide the solution to the problem. Classes and objects are called abstraction of the problem, and the structures are called
  • 30. cooperative implementation mechanisms. In the analysis it is important to focus attention on the external view of the abstractions and implementation mechanisms. These views represent the logical framework of the problem In the implementation of design attention is fixed on the inside view of the abstractions and mechanisms of implementation, thus involving physical framework. BUILD QUALITY Process design of classes and objects is incremental, iterative, to determine whether a class or object is well designed can be measured based on: - Coupling. A measure of strength in the partnership established by a connection from one module to another or between classes, a strong coupling avoids the independence between modules or classes of system, a module or class is tightly coupled hard to understand, change or correct therefore the complexity of system design can be reduced using a weak coupling between modules or classes - Cohesion. A measure of the degree of community among design elements OO as a module, simple objects or simple classes, the least desirable form of cohesion is coincidental, in which abstractions are complete unrelated grouped in the same class or module. Coupling and cohesion are criteria to allow a class or module be sufficient, whole and primitive. - Sufficiency. For sufficiency means that class or module have characteristics indispensable to permit abstraction and iteration different meaning, but using the minimum necessary - Fortitude. This means the class or interface module that captures everything abstraction without significant gaps, a class or module must have a general interface to be useful to any customer allowing us to obtain reusable code for different purposes, one must also consider that as long as general design and construction. - Primitiveness. If too many methods provided in levels get final levels end resorts but many methods may leave early levels to achieve a grouping of operations. If necessary increase the functionality sufficient to rely on primitive classes SELECTION METHODS Planning a class or interface module is usually very hard work, it is advisable to make a first
  • 31. attempt to design a class, then to rely on the needs of their clients created is determined whether increases, modifies and redefines interface, but worth saying that you need to have a general thought at all times to allow classes capable of responding to different customers. If in a given class are stored all methods in primitive form is displayed and well defined small operation, a good designer knows the balance between wanting many contracts: large classes in methods, and few contracts: small classes with many relationships. Methods can be placed taking into account the following criteria.  Reusability. Useful operation in more than one context.  Complexity. Difficulty of implementing the operation.  Applicability. Operating Considerations for specific contexts  Implementation Knowledge. The implementation of the operation depends upon internal details of the class. SELECTION OF FOREIGN The relationship between classes and objects is linked to the choice of methods. If it is decided that in order to send an "m" to object B, then B can directly or indirectly be accessible to A, for which they must name the operation "m" in the implementation of A, considering the visibility required The representation of a class or object should be, almost always, one of the secrets of encapsulation of abstraction. An advantage of encapsulation is to make changes to the representation, provided they do not apply a functional violation of the assumptions made by the customer. This happens without affecting any of its customers or contract because the protocol is not affected CLASSIFICATION To find the solution of a problem is necessary to discover and identify. The process of discovering abstractions and mechanisms to look detached from the vocabulary of the problem domain plus some other implicit If we rely on the classification of the abstractions and mechanisms are identified generalization hierarchies, specialization and aggregation. Classification is a tool to modularize, you can place certain classes and objects in the same module depending on the similarities of their statements. The similarity can be obtained using
  • 32. the cohesion and coupling. The classification will always be related to the focus, vision, experience and need the classifier. IDENTIFICATION OF CLASSES AND OBJECTS Historically there are three basic approaches to classify: No classification is absolute, because some structures can be mostly favored classes of one application to another, no classification scheme represents the actual structure or the natural order. Some classifications may be more significant over other as our interest but not represent reality more accurately or adequately but to serve our purposes Classification classic. - All entities with a property or collection of properties common form a category, the traditional classification comes from Plato, Aristotle then, by means of classifying plants and animals, and to find answers to questions like: Is animal? Is Mineral? Is it vegetable? One thing can be named according to the knowledge gained from the nature of their properties and effects, the practical approach using real estate as a criterion of similarity between objects, specifically objects can be grouped into sets depending on the presence or absence of a particular property Conceptual clustering. - It is a modern variation of the classical approach of trying to explain derivative knowledge, this approach class or group of entities is generated to make the first conceptual description of the class. The long tapering conceptual clustering with fuzzy theory in which objects belong to one or more groups of attitudes varying degrees, depending on the classification considers the functionality of their bodies. The traditional classification and conceptual clustering are sufficient to explain most complex designs classifications Prototype theory. - Is derived from the use of cognitive theory, if we try to classify games and they can not be properly represented by the classical mold by not sharing similar properties all games, however the team's theory unifies game ratings as family resemblances. An object class is represented by a prototype object and an object is considered a member of that class if and only if it is similar to the prototype significantly. Instead prototype theory unifies the classification of games as family resemblances, an object class is represented as an object prototype and an object is considered a member of this class if and only if it is similar to the prototype significantly. Currently these three classification approaches have direct application to object-oriented design.
  • 33. CLASS 9 Primitive Data Types in Java A data type is an attribute or characteristic that is the data-this serves to tell the computer what kind of information to be processed, for example, what values can take and what operations can be performed with them. The most common data types are: integers, floating point numbers (decimal), strings, dates, times, colors, etc.. Below is a table of the most primitive data types used, and a description of each. Boolean ie values that can be true or false. Occupies 1-bit and the default value is false char The characters are 16-bit and are encoded in Unicode 1.1.5, in other languages are only 8-bit ASCII. Occupies 16-bits byte unsigned 8-bit integer, ie the fewer number (two to the seventh) and two in the eighth. The internal representation is in 2's complement Short unsigned 16-bit integer. The internal representation is in 2's complement int unsigned 32-bit integer. The internal representation is in 2's complement Long unsigned 64-bit integer. The internal representation is in 2's complement float 32-bit real mobile with coma. The internal representation is IEEE 754-1985. doublé 32-bit real mobile with coma. The internal representation is IEEE 754-1985. Each primitive type has an associated class, you can store the same information but always through objects.