Advanced Programming in Java

Slides:



Advertisements
Similar presentations
Programming Paradigms and languages
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Object-Oriented Analysis and Design
Chapter 1 Object-Oriented System Development
Object Oriented System Development with VB .NET
Reasons to study concepts of PL
1 CMSC 132: Object-Oriented Programming II Software Development IV Department of Computer Science University of Maryland, College Park.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
Abstract Data Types and Encapsulation Concepts
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
UML and Object Oriented Concepts
Introduction to Object-oriented programming and software development Lecture 1.
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++
The Evolution of the Object Model OOAD. The Evolution of the Object Model software engineering trends observed The shift in focus from programming-in-the-small.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
1 Programming Language History and Evolution In Text: Chapter 2.
Computer Concepts 2014 Chapter 12 Computer Programming.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
Chapter 12 Support for Object oriented Programming.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Salman Marvasti Sharif University of Technology Winter 2015.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Introduction to OOP Mehdi Einali Advanced Programming in Java 1.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Introduction to OOP Mehdi Einali Advanced Programming in Java 1.
MANAGING COMPLEXITY Lecture OO01 Introduction to Object-oriented Analysis and Design Abstract Data Types.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ISBN Chapter 12 Support for Object-Oriented Programming.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
Programming Language History and Evolution
Object Oriented Systems Design
Programming paradigms
Object Oriented Programming
OOP: Object-oriented programming
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Abstract Data Types and Encapsulation Concepts
Object Oriented Programming F3031
Sections Basic Concepts of Programming
CSCI-235 Micro-Computer Applications
CS101 Introduction to Computing Lecture 19 Programming Languages
Review: Two Programming Paradigms
11.1 The Concept of Abstraction
JAVA Introduction ការណែនាំពី Java
TIM 58 Chapter 8: Class and Method Design
Programming Language History and Evolution
Names, Binding, and Scope
Abstract Data Types and Encapsulation Concepts
Subprograms and Programmer Defined Data Type
Ada – 1983 History’s largest design effort
Programming Language Design
Advanced Programming Behnam Hatami Fall 2017.
Programming Languages 2nd edition Tucker and Noonan
Principles of Programming Languages
Overview of Programming Paradigms
Object-Oriented Programming
Programming Languages and Paradigms
CS 2704 Object Oriented Software Design and Construction
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Advanced Programming in Java Introduction to OOP Mehdi Einali

agenda Object Oriented Programming History of Programming languages Characteristics of objects Interface Encapsulation

Object oriented programming

Abstraction Simplification of complex system via interface(Modeling) Machine language Assembly: an abstraction of the machine language Many languages are abstraction of assembly language Fortran, Basic, C But they still require you to think in terms of the structure of the computer Rather than the structure of the problem

Different Contexts Problem Space Solution Space the place where the problem exists such as a business Solution Space the place where you’re implementing that solution such as a computer The effort required to perform this mapping

Library Problem Suppose you want to write a library program What are the elements of your program? We think about methods and variables…

Object Oriented Approach OO approach goes a step further Lets the programmer represent problem space elements This representation is general enough The programmer is not constrained to any particular type of problem. The elements in the problem space and their representations in the solution space are referred to as “objects”

Why OOP?

OOP The program is allowed to adapt itself to the lingo of the problem by adding new types of objects when you read the code, you’re reading words that also express the problem. This is a more flexible and powerful language abstraction

Reuse Book Journal Teacher Student Course Grant Paper Library System Education System Research System

Change SW system could not change with requirements Maintenance is more expensive than development Avoid cascading changes Increase cohesion / balance coupling Object Orientation

Advantage of OOP Abstraction Seamless in modeling Reuse Best fit to problem domain Reuse Good for Change Extendibility Maintainability Modifiability Testability

Evaluation of programming languages to OOP

generation 1 First-generation languages (1954–1958) FORTRAN I Mathematical expressions ALGOL 58 Mathematical expressions Flowmatic Mathematical expressions IPL V Mathematical expressions This first generation of high-order programming languages therefore represented a step closer to the problem space and a step further away from the underlying machine

Generation 2 Second-generation languages (1959–1961) FORTRAN II Subroutines, separate compilation ALGOL 60 Block structure, data types COBOL Data description, file handling Lisp List processing, pointers, garbage collection Emphasis was on algorithmic abstractions Machines were becoming more and more powerful then more kinds of problems could be automated, especially for business applications read these personnel records first, sort them next, and then print this report A step closer to the problem space and further away from the underlying machine

generation 3 Third-generation languages (1962–1970) PL/1 FORTRAN + ALGOL + COBOL ALGOL 68 Rigorous successor to ALGOL 60 Pascal Simple successor to ALGOL 60 Simula Classes, data abstraction Advent of transistors and then integrated circuit technology, the cost of computer hardware had dropped dramatically Larger problems could now be solved, but these demanded the manipulation of more kinds of data Support data abstraction describe the meaning of related kinds of data (their type)

Genertion gap The generation gap (1970–1980) Many different languages were invented, but few endured. However, the following are worth noting: C Efficient; small executable FORTRAN 77 ANSI standardization Creation of literally a couple of thousand different programming languages and dialects Few of these languages survived

oop Object-orientation boom (1980–1990, but few languages survive) Smalltalk 80 Pure object-oriented language C++ Derived from C and Simula Ada83 Strong typing; heavy Pascal influence Eiffel Derived from Ada and Simula

Frameworks Emergence of frameworks (1990–today) Visual Basic Eased development of the graphical user interface (GUI) for Windows applications Java Successor to Oak; designed for portability Python Object-oriented scripting language J2EE Java-based framework for enterprise computing .NET Microsoft’s object-based framework Visual C# Java competitor for the Microsoft .NET Framework Visual Basic .NET Visual Basic for the Microsoft .NET Framework

Topology of 1st and early 2nd gen Basic physical building block of all applications is the subprogram (or the paragraph - COBOL) Flat physical structure, consisting only of global data and subprograms An error in one part of a program can have a devastating ripple effect across the rest of the system

Late 2nd and Early 3rd Gen The first software abstraction, now called the ‘procedural’ abstraction Variety of parameter-passing mechanisms Nesting subprogram, theories about control structures, scope and visibility of structures Structured design methods Greater control over algorithmic abstractions Still fails to address the problems of programming-in-the-large and data design.

Late Third-Generation Larger programming projects meant larger development teams, and thus the need to develop different parts of the same program independently Separately compiled module Need for semantic consistency among module interfaces Most of these languages had dismal support for data abstraction and strong typing, such errors could be detected only during execution of the program.

Object based and object oriented Procedural abstraction is not enough Data abstraction is important to mastering complexity Data-driven design methods emerged, which provided a disciplined approach to the problems of doing data abstraction in algorithmically oriented languages Theories regarding the concept of a type appeared, which eventually found their realization in languages such as Pascal If procedures and functions are verbs and pieces of data are nouns, a procedure-oriented program is organized around verbs while an object-oriented program is organized around nouns

Beyond programming languages Enterprise Application Integration(EAI) Service Oriented architecture(SOA)

OOP vs. Procedural Approach Elements of OOP Objects Message passing between objects Elements of procedural programming Functions Variables Function invocation The way of thinking Thinking about objects and relations Thinking about functions and computer structure

Object characteristics

OOP Characteristics Alan Kay summarized five basic characteristics of Smalltalk 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

Booch’s description of an Object An object has state, behavior and identity Booch added identity to the description An object (may) have internal data which gives it state An object (may) have methods to produce behavior And each object can be uniquely distinguished from every other object Each object has a unique address in memory

interface

Interface Each object can satisfy only certain requests The requests you can make of an object are defined by its interface The type is what determines the interface

Representation of a light bulb

Person in an Education System

New names in OOP Function  Method, Service Variable  Property, State

encapsulation

Encapsulation Commercial products are encapsulated Remote control TV Cell phone They are Black Boxes Hidden Implementations Public interface

encapsulate

Why Encapsulation? Simplified use Open implementation  bad use Even for the producer Open implementation  bad use Hiding the implementation reduces bugs It is more beautiful!

Object Encapsulation Encapsulation of a problem-space concept into a class of objects Define interface Hide the implementation Black box The client may see the implementation But can not use it directly This is better even for the producer (programmer)

Access Control Access to some parts of the class is restricted Public and Private area of the class The client of a class can use only public area Public area = class interface Public methods Public variables

Example: Rectangle Lets encapsulate a rectangle What is a rectangle? An object Which has length and width (properties) Lets you specify its length and width Can calculate its area and perimeter

Class Declaration public class Rectangle { private int width, length; public void setWidth(int w) { width = w; } public void setLength(int l) { length = l; public int calculateArea(){ return width*length; public int calculatePerimeter(){ return (width+length)*2; Class Declaration Private area: hidden implementation Public area : the interface

How to Use Rectangle? Rectangle rect = new Rectangle(); rect.setWidth(2); rect.setLength(7); System.out.println(rect.calculateArea()); System.out.println(rect.calculatePerimeter()); Object creation or instantiation

Grady Booch Booch Method Three Amigos(1994-95) Ivar Jacobson Object Modeling Technique(OMT) Rumbaugh Process Objectory Unified Modeling Language(UML) Unified Process(UP) Object Oriented Analysis and Design-3rd edtion(2007) گریدی بوچ (به انگلیسی: Grady Booch) (متولد ۲۷ فوریه ۱۹۵۵)یک مهندس نرم‌افزار آمریکایی است که بیشتر به خاطر همکاری‌اش بر روی زبان مدل‌سازی یکپارچه به همراه ایوار جاکوبسون و جیمز رامبورگ معروف است. وی همچنین در عرصهٔ بین‌المللی به خاطر کارهای نوآورانه‌اش در معماری نرم‌افزار، مهندسی نرم‌افزار و محیط توسعه مشارکتی چهره‌ای شناخته شده می‌باشد. زندگی‌نامه وی در سال ۱۹۷۷ یک مدرک کارشناسی از آکادمی نیروی هوایی ایالات متحده آمریکا و در سال ۱۹۷۹ یک مدرک کارشناسی ارشد در رشتهٔ برق ازدانشگاه کالیفرنیا، سانتا باربارا دریافت نمود.[۱] بوچ سال‌ها به عنوان سرپرست محققان، از ابتدای تأسیس در سال ۱۹۸۱، در شرکت نرم‌افزار گویا کار می‌کرد و بعد از آنکه این شرکت توسط کمپانی آی‌بی‌ام در سال ۲۰۰۳ خریداری شد، تا سال ۲۰۰۸ در آن ماند. سپس با عنوان سرپرست محققان در بخش تحقیقات نرم‌افزاری آی‌بی‌ام همکاری کرده و چندین ویراستاری را برای بنجامین کامینگ انجام داد. در سال ۱۹۹۵ عنوان پیرو در انجمن ماشین‌های حسابگر  ACM به وی القا شد.[۲] وی همچنین به محض ورودش به آی‌بی‌ام نیز عنوان پیرو را دریافت نموده بود که تا ۲۰۰۸ در این سمت باقی ماند. او سال ۲۰۱۰ نیز به عنوان پیرو در مؤسسه مهندسان برق و الکترونیک دست یافت.[۳] کار بوچ زندگی کاری خود را صرف ارتقای هنر و علم توسعه نرم‌افزاری نموده است. در دههٔ ۱۹۸۰، یکی از معروف‌ترین کتاب‌های برنامه‌نویسی آدا را تألیف نمود. وی بیشتر به خاطر نقشش در توسعهٔ زبان مدل‌سازی یکپارچه در کنار ایوار جاکوبسون و جیمز رامبورگ شهرت دارد. آی‌بی‌ام ۱۱۳۰ بوچ اولین برنامه‌نویسی خود را برای آی‌بی‌ام ۱۱۳۰ ارئه داد.[۴] ... درای فروشگاه آی‌بی‌ام محلمون رو با مشت باز کردم و منتظر موندم تا فروشنده یه نگاه ترحم‌انگیز بهم انداخت. بعد از این که یه مدت با هم صحبت کردیم یه [دفترچه] فورترن بهم داد. مطمئنم وقتی داشت این‌کارو می‌کرد پیش خودش فکر می‌کرد «دیگه هیچوقت این بچه رو نمی‌بینم.». هفتهٔ بعد من برگشتم به فروشگاه و گفتم «این خیلی باحاله! همه‌اش رو خونده‌ام و یه برنامهٔ کوچولو هم نوشتم. کجا می‌تونم یه کامیپوتر پیدا کنم؟». یارو، برای ذوق و شوق من، یه زمان برنامه‌نویسی با آی‌بی‌ام ۱۱۳۰ آخر هفته اونم آخر شب پیدا کرد. این اولین خاطرهٔ من از برنامه‌نویسی بود، و باید از اون فروشندهٔ ناشناس برای شروع کردن شغلم تشکر کنم. مرسی آی‌بی‌ام. روش بوچ نمودار کلاس بوچ یک روش توسعهٔ نرم‌افزاری به نام روش بوچ ایجاد کرد که در کتاب طراحی و آنالیز شی‌گرا خود معرفی شد. او برای ساده کردن کدها، اضافه نمودن کلاس‌ها را توصیه نمود. روش بوچ روشی است که در مهندسی نرم‌افزار استفاده می‌شود. این روش یک زبان مدل‌سازی شی و اسلوب‌شناسی است که به وفور در طراحی و آنالیز شی‌گرا استفاده شده است. این روش توسط گریدی بوچ در شرکت نرم‌افزار گویا ایجاد شد. جنبه‌های نمادی روش بوچ امروزه توسط زبان مدل‌سازی یکپارچه(یو ام‌ال) جایگزین شده است، که عناصر گرافیکی از روش بوچ را به همراه عناصرتکنیک مدل‌سازی شی (او ام تی) و مهندسی نرم‌افزار شی‌گرا (او او اس ای) در خود دارد. ابعاد روش‌شناختی روش بوچ به چندین اسلوب‌شناسی و فرایند تقسیم شده است، مانند فرایند یکپارچه رشنال (آر یو پی). الگوی طراحی بوچ همچنین در الگوی طراحی دستی داشت. برای مثال، وی مقدمه‌ای بر کتاب الگوهای طراحی نوشت. تحقیقات آی‌بی‌ام - آلمادن وی هم اکنون در تحقیقات آی‌بی‌ام - آلمادن سرپرست تحقیقات در بخش مهندسی نرم‌افزار است، جایی که کار بر روی کتاب دستی معماری نرم‌افزار را ادامه داده و چندین پروژهٔ دیگر مربوط به مهندسی نرم‌افزار را رهبری می‌کند. کتاب‌ها گریدی کتاب‌ها و مقالات زیادی را به چاپ رسانیده است. بخشی از آن به قرار زیر می‌باشد: ۱۹۸۳، مهندسی نرم‌افزار با آدا.[۵] ۱۹۹۵، راه حل‌های شی: پروژهٔ شی گرا.[۶] ۱۹۹۹، فرایند توسعه نرم‌افزار متحد. به همراه ایوار جاکوبسون و جیمز رامبورگ.[۷] ۲۰۰۰، دوره‌های آموزشی کامل یو ام‌ال. به همراه ایوار جاکوبسون و جیمز رامبورگ.[۸] ۲۰۰۴، راهنمای مرجع زبان مدل سازی متحد، چاپ دوم. به همراه ایوار جاکوبسون و جیمز رامبورگ.[۹] ۲۰۰۵، راهنمای کاربر زبان مدل سازی متحد، چاپ دوم. به همراه ایوار جاکوبسون و جیمز رامبورگ.[۱۰] ۲۰۰۷، آنالیز و طراحی شی گرا به همراه کاربردها.[۱۱]

end