Você está na página 1de 4

Programming Foundations Object-Oriented Design

What is an object?
They are well defined ideas, even (comparing with the real world) you can touch or see them, like a date,
bank account. Objects are not always physical items or visible items.

Objects have identity ( they are separated from other objects), attributes (their own attributes,
information that describes their current state) and behavior (things they can do)

A little suggestion when you what to know if it`s an object just ask yourself, can you put The in front of
it?

What is an class?

We use classes to create objects, the entire point of object oriented design it`s not about objects, it`s
about classes!

A class describe what a object will be, is a blueprint, a detailed description and definition.

Creating a class
Name : what is it?

Employee, BankAccount etc

Attributes what describes it? (proprieties, data)

Width, Height, Color, Score - objects

Behavior : what can it do? ( operations)

Play, Open, Search, Save - methods


Each object is an instance of a class the process of creating an object it`s called instatiation

They are 4 fundamentals ideas in OOP :

1.Abstraction
- this term is the essential idea of the OOP, is the foundation that supports the others : inheritance and
polymorphism.

- means that we focus on the essentials quality of that class rather than one specific thing

- means that we have an idea that is separate than any specific instance

- we will focus on the essential quality of an idea not creating different classes for each bank account for
exemple. We will create a class with the core attributes and than create object for different bank
accounts. So it will be like: What should a bank account looks like?

Abstraction is a good feature of OOPS, and it shows only the necessary details to the client of an object.
Means, it shows only necessary details for an object, not the inner details of an object.
Example: - When you want to switch ON television, is not necessary to show all the functions of TV.
Whatever is required to switch on TV will be showed by using abstract class.

2.Polymorphism
- we are inheriting when usefull but I override it when that s suitable.

- polymorphism is referring about the fact that a behavior can be the same as a name and as principle
but with different out put, like the “+” sign when combining two strings or two integers, or about a
method who is inheritated but overrided

- polymorphism let us do the right thing in the right time

- polymorphism is nothing but assingning behavior or value in a subclass to something that was already
declared in the main classs. Simply, polymorphism takes more than one form.

3.Inheritance
- Inheritance is a concept where one class shares the structure and behavior defined in another class.
Inheritance applied on on class is called Single Inheritance, and if it depends on multiple classes, then is
called multiple inheritance.

4.Encapsulation

- It`s not about been secretive, is not the point, it`s about reducing dependencies between
different parts of the application

- The idea of encapsulation is that you enclose your attributes and behaviours and then you hide
everything about that object beside what is absolutely necessary to expose

- Encapsulation is an attribute of an object, and it contains all data wich is hidden. That hidden
data can be restricted to the members of that class.

- Levels are Public, Protected, Private, internal and Protected Internal.


5. Creating a class in Java

Você também pode gostar