Objects Classes CSCI1302 Lakshmish Ramaswamy Organizational Matters TA
Objects & Classes CSCI-1302 Lakshmish Ramaswamy
Organizational Matters • TA: Bijaya Rath • TA Hours: – Monday 2: 30 PM – 3: 30 PM – Wednesday 2: 00 PM – 3: 00 PM – Location – 538 GSRC • Email: bijayarath@gmail. com
Object Oriented Programming • Most popular programming paradigm • Object oriented languages – Smalltalk, C++, Java • Object – The fundamental concept in Java • Object has both structure and state • Defines operations that manipulate the state
Information Hiding • Object is an atomic unit • User should not directly access the parts of the object – You don’t modify the bits of an integer • The internal variables of the object can be accessed via the methods provided • Encapsulation – Grouping data and operations – Implementation hidden from user
Concepts in OO • Goal: Promoting code reuse • Generic code – Code which works for multiple object types • Inheritance – Creating new types with extended (or restricted) functionalities • Polymorphism – Reference type which can reference multiple different types
Objects and Classes in Java • Object is an instance of a class • Class is enhancement of a structure • Members can be both functions (called methods) and data (called fields) • Visibility of the members can be restricted • Information hiding via the private class – Members in the private section are inaccessible from methods not in class
Example …
Example …
Example
Javadoc • Class Specification – Represents design and permitted operations • Implementation – Internal details on how operations are performed – Not important to class user – May contain proprietary information • Specification should be shared; Implementation to be hidden – C++ places them in different files
Javadoc • List of methods can be automatically generated from implementation – Return types and signatures • Javadoc – Program that automatically generates documentation for classes – Output is a set of HTML files • javadoc First. Program. java • Also adds comments beginning with /** • Special tags in comments – @author, @param, @return
Javadoc Example
- Slides: 13