The Object-Oriented Thought Process Chapter 04

Slides:



Advertisements
Similar presentations
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 10: Continuing with classes Constructors, using classes.
Advertisements

OOD - Principles Design Class Diagrams Chapter 10 pp ; ;
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 3rd Edition.
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
Classes in C++ Bryce Boe 2012/08/15 CS32, Summer 2012 B.
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
Chapter 10: Writing Class Definitions Visual Basic.NET Programming: From Problem Analysis to Program Design.
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
Mason Vail.  A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
Chapter 4 -2 part Writing Classes 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All.
10-Nov-15 Java Object Oriented Programming What is it?
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Visibility Control.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
CourseOutline Example & JavaBeans Lec Start with Example Displaying Course Outlines User will select either course “web design & development” or.
© 2004 Pearson Addison-Wesley. All rights reserved September 14, 2007 Anatomy of a Method ComS 207: Programming I (in Java) Iowa State University, FALL.
CSC 205 Java Programming II Defining & Implementing Classes.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Chapter 3 Introduction to Classes and Objects Definitions Examples.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Outline Anatomy of a Class Encapsulation Anatomy of a Method Copyright © 2014 Pearson Education, Inc.
Comp1004: Building Better Objects II Encapsulation and Constructors.
COMP Information Hiding and Encapsulation Yi Hong June 03, 2015.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Object Oriented Programming. Constructors  Constructors are like special methods that are called implicitly as soon as an object is instantiated (i.e.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
Andrew(amwallis) Classes!
Classes and Objects.
Module Road Map Refactoring Why Refactoring? Examples
Object-Oriented Programming
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Creating Your OwnClasses
Anatomy of a Class & Method
Anatomy of a class Part I
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
CS212: Object Oriented Analysis and Design
Chapter 4: Writing classes
Properties 7: Properties Programming C# © 2003 DevelopMentor, Inc.
Encapsulation and Constructors
Outline Writing Classes Copyright © 2012 Pearson Education, Inc.
Classes, Encapsulation, Methods and Constructors (Continued)
Chapter 9 Objects and Classes
Defining Classes and Methods
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Outline Anatomy of a Class Encapsulation Anatomy of a Method
CIS16 Application Development and Programming using Visual Basic.net
Introduction to Objects & Classes
Encapsulation September 13, 2006 ComS 207: Programming I (in Java)
Object-Oriented Programming
NAME 436.
Barb Ericson Georgia Institute of Technology Oct 2005
Encapsulation.
Anatomy of a class Part I
Classes and Objects Systems Programming.
CSG2H3 Object Oriented Programming
Day 11 The Last Week!.
Presentation transcript:

The Object-Oriented Thought Process Chapter 04 The Anatomy of a Class

The Name of the Class The name of the class is important for several reasons. To identify the class itself. The name must be descriptive. The choice of a name is important because it provides information about what the class does and how it interacts within larger systems.

Comments Regardless of the syntax of the comments used, comments are vital to understanding the function of a class. While comments are vital to the documentation and maintenance of code, it is important not to over-comment.

Attributes Attributes represent the state of the object because they store the information about the object. In many designs all attributes are private. Keeping the interface design as minimal as possible. The only way to access these attributes is through the method interfaces provided.

Methods Methods represent the behavior of the object because they provide the functionality. Methods are defined by their signature and are used to invoke certain behaviors. One of the uses of methods is as accessor methods.

Accessor Methods Controlled access to attributes is provided by methods. These method are called accessors. Sometimes accessors are referred to as getters and setters. public void setName(String iName) { name = iName; } public String getName() { return name;

Public Methods Both the constructors and the accessor methods are declared as public and are part of the public interface. Other methods can be part of the public interface as well. public void giveDestination (){ }

Private Methods It is common for methods in a class to be hidden from other classes. These methods are declared as private: private void turnRight(){ } private void turnLeft() {