Introduction
Total Page:16
File Type:pdf, Size:1020Kb
Object oriented programming using Java UNIT-1 Introduction: Approaches to Software Design, Evolution of the Object Model, Benefits of Object Programming; Object Model: Objects, Classes, Sub-classing and Inheritance, Polymorphism Object Programming in Windowed Environments: Benefits of OOP in Windowed Application Environments, Application Frameworks and Class Libraries. ------------------------------------------------------------------------------------------------------ Introduction Software design is a process to conceptualize the software requirements into software implementation. Software design takes the user requirements as challenges and tries to find optimum solution. Number of Issues that must be addressed in software design that are maintainability, reusability, portability, security, integrity, and user friendliness of software products. There are multiple variants of software design. Let us study them briefly: Structured Design Structured design is a conceptualization of problem into several well-organized elements of solution. It is basically concerned with the solution design. Benefit of structured design is, it gives better understanding of how the problem is being solved. Structured design is mostly based on ‘divide and conquer’ strategy where a problem is broken into several small problems and each small problem is individually solved until the whole problem is solved. The small pieces of problem are solved by means of solution modules. These modules are arranged in hierarchy. They communicate with each other. A good structured design always follows some rules for communication among multiple modules, namely - Cohesion - grouping of all functionally related elements. Coupling - communication between different modules. A good structured design has high cohesion and low coupling arrangements. Function Oriented Design In function-oriented design, the system is comprised of many smaller sub- systems known as functions. These functions are capable of performing significant task in the system. Function oriented design inherits some properties of structured design where divide and conquer methodology is used. This design mechanism divides the whole system into smaller functions, which provides means of abstraction by concealing the information and their operation. These functional modules can share information among themselves by means of information passing and using information available globally. Object Oriented Design Object oriented design works around the entities and their characteristics instead of functions involved in the software system. The whole concept of software solution revolves around the engaged entities. Let us see the important concepts of Object Oriented Design: Objects - All entities involved in the solution design are known as objects. For example, person, banks, company and customers are treated as objects. Every entity has some attributes associated to it and has some methods to perform on the attributes. Classes - A class is a generalized description of an object. An object is an instance of a class. Class defines all the attributes, which an object can have and methods, which defines the functionality of the object. In the solution design, attributes are stored as variables and functionalities are defined by means of methods or procedures. Encapsulation - In OOD, the attributes (data variables) and methods (operation on the data) are bundled together is called encapsulation. Encapsulation not only bundles important information of an object together, but also restricts access of the data and methods from the outside world. This is called information hiding. Inheritance - OOD allows similar classes to stack up in hierarchical manner where the lower or sub-classes can import, implement and re- use allowed variables and methods from their immediate super classes. This property of OOD is known as inheritance. This makes it easier to define specific class and to create generalized classes from specific ones. Polymorphism - OOD languages provide a mechanism where methods performing similar tasks but vary in arguments, can be assigned same name. This is called polymorphism, which allows a single interface performing tasks for different types. Depending upon how the function is invoked, respective portion of the code gets executed. Software Design Approaches Here are two generic approaches for software designing: Top down Design We know that a system is composed of more than one sub-systems and it contains a number of components. Top-down design takes the whole software system as one entity and then decomposes it to achieve more than one sub-system or component based on some characteristics. Each sub-system or component is then treated as a system and decomposed further. This process keeps on running until the lowest level of system in the top-down hierarchy is achieved. Top-down design starts with a generalized model of system and keeps on defining the more specific part of it. When all components are composed the whole system comes into existence. Top-down design is more suitable when the software solution needs to be designed from scratch and specific details are unknown. Bottom-up Design The bottom up design model starts with most specific and basic components. It proceeds with composing higher level of components by using basic or lower level components. It keeps creating higher level components until the desired system is not evolved as one single component. With each higher level, the amount of abstraction is increased. Bottom-up strategy is more suitable when a system needs to be created from some existing system, where the basic primitives can be used in the newer system. Both, top-down and bottom-up approaches are not practical individually. Instead, a good combination of both is used. The algorithms are designed using two approaches that are the top-down and bottom-up approach. In the top-down approach, the complex module is divided into submodules. On the other hand, bottom-up approach begins with elementary modules and then combine them further. The prior purpose of an algorithm is to operate the data comprised in the datastructure. In other words, an algorithm is used to perform the operations on the data inside the data structures. Comparison Chart BASIS FOR TOP-DOWN APPROACH BOTTOM-UP APPROACH COMPARISON Basic Breaks the massive problem Solves the fundamental into smaller sub problems. low-level problem and integrates them into a larger one. Process Submodules are solitarily Examine what data is to be encapsulated, and BASIS FOR TOP-DOWN APPROACH BOTTOM-UP APPROACH COMPARISON analysed. implies the concept of information hiding. Communication Not required in the top-down Needs a specific amount approach. of communication. Redundancy Contain redundant Redundancy can be information. eliminated. Programming Structure/procedural oriented Object-oriented languages programming languages (i.e. C) programming languages follows the top-down approach. (like C++, Java, etc.) follows the bottom-up approach. Mainly used in Module documentation, test Testing case creation, code implementation and debugging. Evolution of the Object Model Evolution & Overview of Java By the end of 1980s and the early 1990s, Object-oriented programming using C++ took hold. For a brief moment, it seemed as if programmers had found the perfect language finally. C++ was a language that could be used to create a wide range of programs. However, forces were brewing that would drive computer language evolution forward once again. Within few years WWW (World Wide Web) and the Internet would reach critical mass. This event would cause another revolution in programming. Java is general purpose language which is used for developing either Stand alone Programs or either you can develop We Programs or Web Applets First of all program of java is Compiled then it is transferred into the byte codes For Executing java programs java name of the compiler is used for Converting the java program into the byte code and then by using the interpreter we converts the Bytes code into the machine language. If we simply execute the programs on our Machine then it is called as the Stand Alone Programs but if we using the Applets for which includes Graphical Environment then it is called as Web Applets. JAVA History Every Languages have a history or Every Language has a past Java is Developed in 1991 in USA And it was Called as OAK and it is Developed by James Gosling name of the Engineer of the Microsoft Sun Team. Java Was Developed For Developing the Electronics' things Like VCR, Televisions etc. The History of Java Includes. In 1990 Sun Microsoft Team develop java for Electronics Things but in 1991 java was Comes with the new name Called as OAK then After that in 1992 java was come with the new idea of developing Software's for the Handheld Devices Like Mobile Phones ,Pagers etc. But in 1993 Java Was So Popular in the World Wide Web or in the Internet For Developing Games and Graphical Applications with the help of Applets The Most Important usable thing in Graphical Programming. Features of Java Compiled and Interpreter Java has both Compiled and Interpreter Feature Program of java is First Compiled and Then it is must to Interpret it .First of all The Program of java is Compiled then after Compilation it creates Bytes Codes rather than Machine Language Then After Bytes Codes are Converted into the Machine Language is Converted into the Machine Language with the help of the Interpreter So For Executing the java Program First of