Introduction to Objects 2016-6-13 1. Abstraction:The object-oriented approach Everything is an object. A program is a bunch of objects telling each other.

Slides:



Advertisements
Similar presentations
COM vs. CORBA.
Advertisements

Programming Paradigms and languages
DT228/3 Web Development WWW and Client server model.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Introduction to Web Database Processing
Introduction to Web Interface Technology (CSE2030)
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
ASP.NET Programming with C# and SQL Server First Edition
Chapter 10 Classes Continued
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
C++ fundamentals.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
UNIT-V The MVC architecture and Struts Framework.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 13 Slide 1 Application architectures.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Access Control Problem A primary consideration in object- oriented design is to “separate the things that change from the things that stay.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Internet Applications Notes for Chapter 19 Digital Domain, 2 ed.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Programming Languages and Paradigms Object-Oriented Programming.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Introduction to Object-oriented programming and software development Lecture 1.
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
CPS120: Introduction to Computer Science The World Wide Web Nell Dale John Lewis.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
JAVA Introduction ● One of the main JAVA design goal is reducing complexity for programmer – Development time is half or less comparing to equivalent C++
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
COM vs. CORBA Computer Science at Azusa Pacific University September 19, 2015 Azusa Pacific University, Azusa, CA 91702, Tel: (800) Department.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Introduction to Object Oriented Programming CMSC 331.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 Inheritance. 2 Why use inheritance?  The most important aspect of inheritance is that it expresses a relationship between the new class and the base.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Introduction to JavaScript CS101 Introduction to Computing.
Learners Support Publications Object Oriented Programming.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Reusing Classes composition The trick is to use the classes without soiling the existing code. In this chapter you’ll see two ways to accomplish.
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
Salman Marvasti Sharif University of Technology Winter 2015.
Object-Oriented Programming Chapter Chapter
M1G Introduction to Programming 2 5. Completing the program.
REST By: Vishwanath Vineet.
Introduction to JavaScript Fort Collins, CO Copyright © XTR Systems, LLC Introduction to JavaScript Programming Instructor: Joseph DiVerdi, Ph.D., MBA.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
 2006 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
JAVA Introduction ការណែនាំពី Java
Polymorphism 2019/4/29.
Presentation transcript:

Introduction to Objects

Abstraction:The object-oriented approach Everything is an object. A program is a bunch of objects telling each other what to do by sending messages. Each object has its own memory made up of other objects. Every object has a type. All objects of a particular type can receive the same messages. An object has state, behavior and identity

An object has an interface Objects that are identical except for their state during a program’s execution are grouped together into “classes of objects,” and that’s where the keyword class came from. Once a class is established, you can make as many objects of that class as you like. There needs to be a way to make a request of the object so that it will do something. The requests you can make of an object are defined by its interface, and the type is what determines the interface. There must be code somewhere to satisfy that request. This, along with the hidden data, comprises the implementation

Example: The Light The name of the type/class is Light, the name of this particular Light object is lt, and the requests that you can make of a Light object are to turn it on, turn it off, make it brighter, or make it dimmer.

An object provides services While you’re trying to develop or understand a program design, one of the best ways to think about objects is as “service providers.” Your program itself will provide services to the user, and it will accomplish this by using the services offered by other objects. Your goal is to produce (or even better, locate in existing code libraries) a set of objects that provide the ideal services to solve your problem. Thinking of an object as a service provider has an additional benefit: It helps to improve the cohesiveness of the object. High cohesion is a fundamental quality of software design: It means that the various aspects of a software component “fit together” well

The hidden implementation Class creators: those who create new data types. Client programmers: the class consumers who use the data types in their applications. The goal of the class creator is to build a class that exposes only what’s necessary to the client programmer and keeps everything else hidden. Access Control: To have boundaries that are respected by all parties involved

Access Control in Java Java uses three explicit keywords to set the boundaries in a class: public, private, and protected. public means the following element is available to everyone. private means that no one can access that element except the creator of the type. protected acts like private, with the exception that an inheriting class has access to protected members, but not private members. Java also has a “default” access, which comes into play if you don’t use one of the aforementioned specifiers. This is usually called package access because classes can access the members of other classes in the same package (library component), but outside of the package those same members appear to be private

Reusing the implementation Composition: place an object of a class inside a new class Inheritance: create a new class based on the original one

Inheritance Inheritance: take the existing class, clone it, and then make additions and modifications to the clone

Example: Shape

Is-a vs. is-like-a relationships The derived class is exactly the same type as the base class since it has exactly the same interface. This can be thought of as pure substitution, often referred to as the substitution principle. There are times when you must add new interface elements to a derived type, thus extending the interface. The new type can still be substituted for the base type, but the substitution isn’t perfect because your new methods are not accessible from the base type. This can be described as an is-like-a relationship

Example: Is-a VS Is-like-a

Interchangeable objects with polymorphism When dealing with type hierarchies, you often want to treat an object not as the specific type that it is, but instead as its base type. This allows you to write code that doesn’t depend on specific types. Such code is unaffected by the addition of new types, and adding new types is the most common way to extend an object-oriented program to handle new situations

Example: Interchangeable objects The BirdController object just works with generic Bird objects and does not know what exact type they are. This is convenient from BirdController’s perspective because it doesn’t have to write special code to determine the exact type of Bird it’s working with or that Bird’s behavior

Early binding VS Late binding early binding: The compiler generates a call to a specific function name, and the runtime system resolves this call to the absolute address of the code to be executed. late binding: The compiler does ensure that the method exists and performs type checking on the arguments and return value, but it doesn’t know the exact code to execute

Example: Late binding The calls to doSomething( ) automatically work correctly, regardless of the exact type of the object

Upcasting We call this process of treating a derived type as though it were its base type upcasting, that is, moving up the inheritance diagram

The singly rooted hierarchy In Java, all classes should ultimately be inherited from a single base class. The name of this ultimate base class is simply Object. All objects in a singly rooted hierarchy have an interface in common, so they are all ultimately the same fundamental type. All objects in a singly rooted hierarchy can be guaranteed to have certain functionality

Containers Problem: You don’t know how many objects you’re going to need to solve a particular problem, or how long they will last. You also don’t know how to store those objects. The solution to most problems in object- oriented design seems flippant: You create another type of object. The new type of object that solves this particular problem holds references to other objects. The special object is called a container

Some containers provided by Java List Map Set

Parameterized types (generics) Downcasting: cast down the hierarchy to a more specific type. Not safe and often error prone. The solution is called a parameterized type mechanism. A parameterized type is a class that the compiler can automatically customize to work with particular types

Object creation & lifetime Every time you want to create an object, you use the new operator to build a dynamic instance of that object. Java provides a feature called a garbage collector that automatically discovers when an object is no longer in use and destroys it

Exception handling: dealing with errors Error handling has been a particularly difficult issue. Exception handling wires error handling directly into the programming language and sometimes even the operating system. An exception is an object that is “thrown” from the site of the error and can be “caught” by an appropriate exception handler designed to handle that particular type of error

Concurrent programming A fundamental concept in computer programming is the idea of handling m There’s a large class of problems in which you’re simply trying to partition the problem into separately running pieces (tasks) so that the whole program can be more responsive. Within a program, these separately running pieces are called threads, and the general concept is called concurrency. ore than one task at a time. Java’s concurrency is built into the language

Java and the Internet What is the Web? The Web can seem a bit of a mystery at first, with all this talk of “surfing,” “presence,” and “home pages.” Client/server computing The Web as a giant server

Client/server computing The primary idea of a client/server system is that you have a central repository of information— some kind of data, usually in a database—that you want to distribute on demand to some set of people or machines. A key to the client/server concept is that the repository of information is centrally located so that it can be changed and so that those changes will propagate out to the information consumers. The information repository, the software that distributes the information, and the machine(s) where the information and software reside are called the server. The software that resides on the consumer machine, communicates with the server, fetches the information, processes it, and then displays it on the consumer machine is called the client

The Web as a giant server The Web is actually one giant client/server system. All the servers and clients coexisting on a single network at once. The Web browser: a big step forward

Client-side programming Basic HyperText Markup Language (HTML) contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and dropdown lists, as well as a button that could only be programmed to reset the data on the form or “submit” the data on the form back to the server. The text within the submission tells CGI what to do with it. Step forward: Plug-ins, Scripting languages and Java

Plug-ins This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself into the appropriate spot in the browser. The value of the plug-in for client-side programming is that it allows an expert programmer to develop extensions and add those extensions to a browser without the permission of the browser manufacturer

Scripting languages With a scripting language, you embed the source code for your client-side program directly into the HTML page, and the plug-in that interprets that language is automatically activated while the HTML page is being displayed. One scripting language that you can expect a Web browser to support without a plug-in is JavaScript

Java in client side programming Java allows client-side programming via the applet and with Java Web Start. An applet is a mini-program that will run only under a Web browser

Server-side programming A more complicated request to a server generally involves a database transaction. A common scenario involves a request for a complex database search, which the server then formats into an HTML page and sends to you as the result. These database requests must be processed via some code on the server side, which is generally referred to as server-side programming

Summary A well-written Java program is generally far simpler and much easier to understand than a procedural program. What you’ll see are the definitions of the objects that represent concepts in your problem space (rather than the issues of the computer representation) and messages sent to those objects to represent the activities in that space. One of the delights of object-oriented programming is that, with a well-designed program, it’s easy to understand the code by reading it. Usually, there’s a lot less code as well, because many of your problems will be solved by reusing existing library code