CLASES nOTES V3 (1).pptx - CLASSES Faculty name u2013...

This preview shows page 1 - 8 out of 23 pages.

Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceCLASSES
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceWHAT IS OBJECT ORIENTED PROGRAMMINGObject-oriented programming (OOP) is a programming paradigmbased on the concept of "objects“.Programs are divided into small entities called objects.Focus: Objects have both data (attributes) and methods (behavior) - both are in collective focus
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceOBJECT ORIENTED PROGRAMMINGObject 1Object 2DataMethodsDataMethodsObject 3DataMethods
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceBASIC TERMINOLOGYClass - a representation of a type of object. It is the blueprint that describe the details of an object (properties and behavior).- a category of similar objects (such as automobiles)- does not hold any values of the object’s attributes object- usually a person, place or thing (a noun)- instance of a class, and it has its own state, behavior and identity.attribute- description of objects in a class- how object appears at the momentmethod - an action performed by an object (a verb)- how object reacts to external inputs
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceClass diagramProduct-code: String-description: String-Price: double+setCode(String)+getCode(): String+setDescription(String)+getDescription(): String+setPrice(double)+getPrice(): double+getPriceFormatted(): StringFieldsMethodsFields: of a class store the data for a classMethods define the task that a class performsEncapsulation: refers to fields and methods that can be accessed by other classes.
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceUML– Unified Modeling Language Refer to example on previous slideUML is used to describe classes and objects of Object Oriented applicationThe – in UML class diagram marks private fields and methods that cannot be accessed by other classesThe + in UML class diagram marks public fields and methods that can be accessed by other classesFor each field name is given followed by colon followed by datatypeFor each method , name is given followed by parentheses followed by colon followed by datatype of value that is going to be returned. If there are parameters these are listed in parenthesesNo parameters the parentheses are left empty
Faculty name – Information and Computer TechnologyDepartment name – Department of Computer ScienceInstance variablesAn instance variable maybe a primitive datatypeobject created from Java class such as String classAn object created from user-defined class such as Product classPrivate: prevent access other classes from accessing instance variables

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture