Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2 of Computer Science II

Similar presentations


Presentation on theme: "Lecture 2 of Computer Science II"— Presentation transcript:

1 Lecture 2 of Computer Science II
Design Principles Instructor: Mrs. Eman Alajrami

2 Agenda Data Structures and Algorithms
Design Principles Agenda Data Structures and Algorithms Object oriented design principles. Object oriented design techniques. Java examples of object oriented design. Object oriented design patterns  Page 2

3 Data structures and algorithms
Definitions Data Structures : systematic way of organizing and accessing data. Algorithm: a step by step procedure for performing some task in a finite amount of time. Algorithm Example: Algorithm LargestNumber Input: A non-empty list of numbers L. Output: The largest number in the list L. largest ← L0 for each item in the list L≥1, do if the item > largest, then largest ← the item return largest  Page 3

4 Data structures and algorithms
High Level Design Goals Correctness. Efficiency. What are the features of a good computer program? It is essential that the program be correct, doing what it is supposed to do and containing no bugs. The program should be efficient, using no more time or memory than is necessary. The program should be general-purpose, so that we don't have to start from scratch the next time we build a similar program. Finally, all other things being equal, the program should be rapidly developed.  Page 4

5 Data structures and algorithms
Implementation Goals Robustness. Adaptability. Reusability. Robustness Every good programmer wants to develop software that is robust, which means , capable of handling unexpected inputs that are not explicitly defined for its application. For example, if a program is expecting a positive integer (for example, representing the price of an item) and instead is given a negative integer, then the program should be able to recover gracefully from this error. Adaptability Modern software applications, such as Web browsers and Internet search engines, typically involve large programs that are used for many years. Software, therefore, needs to be able to evolve over time in response to changing conditions in its environment. Thus, another important goal of quality software is that it achieves adaptability (also called evolvability). Reusability Going hand in hand with adaptability is the desire that software be reusable, that is, the same code should be usable as a component of different systems in various applications.  Page 5

6 Object Oriented Design Principles
1. Abstraction Means to distill a complicated system down to its most fundamental parts and describe these parts in a simple, precise language. Benefits robustness since it leads to understandable and correct implementation.  Page 6

7 Object Oriented Design Principles
1. Abstraction ADT: is a mathematical model of a data structure that specifies the type of data stored, the operations on them, and the types of parameters of the operations. An ADT specifies what each operation does, but not how it does it. Examples in Java? ( Complex Numbers, Deque, lists, Trees, Queue, Set, Stack, ….. ) Benefits: Clarity, Robustness.  Page 7

8 Object Oriented Design Principles
2. Encapsulation The idea of encapsulation comes from : (i) the need to cleanly distinguish between the specification and the implementation of an operation and (ii) the need for modularity. You just know how to use it Benefits: Security. modularity  Page 8

9 Object Oriented Design Principles
3. Modularity Modularity refers to an organizing structure in which different components of a software system are divided into separate functional units. Benefits: Clarity. Reusability.  Page 9

10 Object Oriented Design Techniques
1. Classes and Objects Class: a specification of the data fields that the object contains, as well as of the operations that the object can execute. Objects: are simply instances of these classes.  Page 10

11 Object Oriented Design Techniques
2. Interfaces and Strong Typing In Java an interface is similar to an abstract class in that its members are not implemented. In interfaces, _none_ of the methods are implemented. There is no code at all associated with an interface.  Page 11

12 Object Oriented Design Techniques
3. Inheritance and Polymorphism Benefits of inheritance: Reduction of redundant code. Reusability of code Polymorphism: Inheritance. Overriding. Overloading.  Page 12

13 Java Examples of Object-Oriented Design
Interface examples  Page 13

14 Java Examples of Object-Oriented Design
Interface examples  Page 14


Download ppt "Lecture 2 of Computer Science II"

Similar presentations


Ads by Google