1 / 23

Software Design

Software Design. Lecture 1 “ Introduction to Java and OOP”. Lecture Overview. Chapter 1.4 -1.6 of “Java Software Solutions” Slides and exercises can be found on: http://www.media.aau.dk/sd. Java Fundamentals. Java is a object oriented language

thane
Download Presentation

Software Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Design Lecture 1 “ Introduction to Java and OOP” Aalborg Media Lab

  2. Lecture Overview • Chapter 1.4 -1.6 of “Java Software Solutions” • Slides and exercises can be found on:http://www.media.aau.dk/sd Aalborg Media Lab

  3. Java Fundamentals • Java is a object oriented language • Java is accompanied by the “Java standard library ” • Java can be executed using the web • Is constantly under development Chapter 1.4 Aalborg Media Lab

  4. A simple Java Application //************************************************** // Application printing a single line in console //************************************************** class HelloDan { public static void main(String args[]) //entry point { System.out.println (“What’s the frequency Kenneth?”); } } Aalborg Media Lab

  5. Java’s Structure • Every Java application consists of class definitions • In the Java programming language: • A program is made up of one or more classes • A class contains one or more methods • A method contains program statements • A Java application always contains a method called main (entry point) Aalborg Media Lab

  6. object method information provided to the method (parameters) Using Objects • The System.out object represents a destination to which we can send output • In the HelloDan program, we invoked the println method of the System.out object: System.out.println ("What’s the frequency Kenneth?"); Aalborg Media Lab

  7. Using Comments • Comments allow programmers to communicate their thoughts independent of the code • Serves as documentation, VERY IMPORTANT !! • Comments are “inline documentation” // this is a single line comment /* This is a block comment */ Aalborg Media Lab

  8. Identifiers and Reserved Words • Language consists of identifiers • Words we make up • Words another programmer did choose(for example when using the Java standard library) • Reserved words • Java is case sensitive • Class  start with capital letter • Methods  start with small letter Aalborg Media Lab

  9. Code Style • Use descriptive names • Make your code readable by using blank spaces and new lines(Listing 1.2 & 1.3) Aalborg Media Lab

  10. About languages • All programs must be translated to machine language in order to be executed and each type of CPU has its own specific binary machine language (01101…) • There are four programming language levels: • machine language • assembly language • high-level language • fourth-generation language Chapter 1.5 Aalborg Media Lab

  11. Compiler & Interpreters 1/2 • Compilers are small programs translating a language (source code) into another language (target language) • Interpreters interweaves translation and execution(one line at a time) Aalborg Media Lab

  12. Compiler Aalborg Media Lab

  13. Java Using Compiler & Interpreter Aalborg Media Lab

  14. Syntax & Semantic • The syntax rules of a language define how we can put together symbols, reserved words, and identifiers to make a valid program • The semantics of a program statement define what that statement means (its purpose or role in a program) • A program that is syntactically correct is not necessarily logically (semantically) correct • A program will always do what we tell it to do, not what we meant to tell it to do Aalborg Media Lab

  15. Errors • The compiler will find syntax errors and other basic problems (compile-time errors) • If compile-time errors exist, an executable version of the program is not created • A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors) • A program may run, but produce incorrect results, perhaps using an incorrect formula (logical errors) Aalborg Media Lab

  16. Environment • JDK • compile and execute • BlueJ (editor) • writing the code Aalborg Media Lab

  17. Compiling and Execution • The JDK and a simple Editor (Notepad) are enough for coding, compiling and execution Aalborg Media Lab

  18. BlueJ Environment • Java based development environment for Java • BlueJhttp://www.bluej.org/download/download.html Aalborg Media Lab

  19. Object-Oriented Programming • Object is fundamental entity in Java • Developing software by defining objects that interact with each other • OOP is mapping real life situations into a program • Mapping objects and their behavior Chapter 1.6 Aalborg Media Lab

  20. Problem Solving • Life cycle of program development • Understand the problem • Design a solution • Considering alternatives / refining • Implementing the solution • Testing / fixing / refining the solution Aalborg Media Lab

  21. Concepts/Terminology of OOP • Object (real object of the problem domain) • Attribute (characteristics of objects, state) • Method (objects behavior) • Class (objects are defined trough classes, concept) • Multiple object can be created from a class • Encapsulation • Only object itself can change his state (manages itself) • Inheritance • Reuse of class concepts for similar classes • Polymorphism Aalborg Media Lab

  22. Account Charge Account Bank Account Savings Account Checking Account Inheritance • One class can be used to derive another via inheritance • Classes can be organized into inheritance hierarchies Aalborg Media Lab

  23. Exercises • Use BlueJ for following exercises • JSS 1.1 • JSS 1.3 • Try out the Hello application (BlueJ demos) • Add method stop, printing “Bye, world”. Aalborg Media Lab

More Related