Wednesday, February 23, 2011

Entity on Programming

Entity is an object whose existence can be distinguished against other objects. Entities can be people, objects, places, events, concepts. Example :

  • People: STUDENTS, LECTURERS, SUPPLIER, VENDOR
  • Objects: CAR, ENGINE, ROOM
  • Venue: THE STATE, THE VILLAGE, KAMPONG
  • Genesis: SALES, REGISTER
  • Concept: ACCOUNT, COURSE

An entity has a number of attributes
Example: The student has the name and address
Entity set is aa set of entities that share the same attributes
In programming OOP (Object Oriented Programming) or object-oriented Programming is a new way of thinking and logic in dealing with the problems that will try to overcome with the help of computers. OOP, unlike its predecessor (Structured Programming), trying to see problems through observation of the real world where every object is a single entity that has a combination of data structures and specific functions. This contrasts with structured programming where data structures and functions are defined separately and are not closely related.
it can be explained in the following code fragment:

in Python
#Class in Python (OOP)
class className(): # this class name in the form of entity name
def setName(self, name):
self.name = name
def getName(self):
return self.name
def saying(self):
print "Hello %s " % self.name
>>> className
<class __main__.className at 0x009B2BD0>
>>> first = className() # this object first
>>> second = className() # this object second
>>> first.setName("Neoriz") # set Name with Neoriz
>>> second.setName("NeoSack") # set Name with NeoSack
>>> first.getName() # display Name in object first
'Neoriz' # result object first
>>> first.saying() # display first object
Hello Neoriz
view raw Entity_python hosted with ❤ by GitHub

in Java
// Entity on Java
public class nameEntitas {
private String Name;
// getName
public String getName() {
return this.Name;
}
// set Name entity
public void setKode(String Name) {
this.Name = Name;
}
}
view raw Entitas_Java hosted with ❤ by GitHub




hopefully useful for those who love OOP

No comments:

Post a Comment