1 / 24

Road to Object Oriented Programming

Road to Object Oriented Programming. Advanced programming ce244 Sharif University of Technology Feb 2007. Outline. Deadlines Objects Object Oriented Languages Editing your first java program Compiling, running and debugging Homework. Deadlines. By the end of the week you should have :

shalondar
Download Presentation

Road to Object Oriented Programming

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. Road to Object Oriented Programming Advanced programming ce244 Sharif University of Technology Feb 2007 Taha Abachi

  2. Outline • Deadlines • Objects • Object Oriented Languages • Editing your first java program • Compiling, running and debugging • Homework Taha Abachi

  3. Deadlines By the end of the week you should have : • The Java CD • Java installed on your machines • Edited, run, debugged your first Java programs without any trouble • Examined Java IDEs Taha Abachi

  4. Objects • Abstraction • Programming languages • Problem space • Definition • State : internal data • Behavior : methods • Identity : each object can be uniquely distinguished from every other object Taha Abachi

  5. Features of an Object • An object has an interface • An object provides services • The hidden implementation • Data encapsulation • Reusing the implementation • Inheritance:reusing the interface Taha Abachi

  6. Features of an Object (cont’d) • Sample object • Date : • Day : 1..31 • Month : 1..12 • Year : 1300..1500 • Problems • Inconsistent data: no dependency to other fields • Day := 32 • Inflexible representation • Date : longint Date := 28351 days passed after a specific date Taha Abachi

  7. Features of an Object (cont’d) • Clients of the code • Yourself • Teammates • Customers • An infant programmer • Solution :Separating implementation form interface • More Secure and flexible Taha Abachi

  8. Object Oriented Languages • 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. Taha Abachi

  9. Installing Java • Install JDK • Install Java Documentation • API(Application programming Interface) • Set Environment variables • Choose a text editor Taha Abachi

  10. Java Characteristics • Portability : • compile programs to a intermediary format called JBC C:\>javac HelloWorld.java to produce HelloWorld.class • Interpreting : JVM Taha Abachi

  11. Portability Taha Abachi

  12. Java is Object Oriented • Every thing in Java is an Object. • Objects in OOP mirror the properties and behavior of the real world objects. • They have their own set of data and functions (called method) that operate on these data. Taha Abachi

  13. First Program in Java • Use a text editor • Write down your program • Java is case sensitive • Compile your program • Run Taha Abachi

  14. HelloWorld public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } Taha Abachi

  15. Java program files • Each class is saved in a file of the same name with java extension. • Note java is case sensitive language, even as far as the class file names are concerned. • The Hello class should be saved in a file called HelloWorld.java class . Taha Abachi

  16. Syntax Highlighting public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } Taha Abachi

  17. The method main ( ) • The main() method is the point where a Java program starts running. • Any executable Java class must have the main() method in this specific format: public static void main(String[ ] args){ ………….. ………….. } Taha Abachi

  18. Time to compile • Use javac command to compile your java programms : C:\> javac HelloWorld.java HelloWorld.class (JBC file) is created • You may face some errors • Correct erroneous parts and compile again Taha Abachi

  19. Run • The Java command is used to run the class (JBC) file: c:\> Java HelloWorld Taha Abachi

  20. Congratulations You are a Java programmer NOW! Taha Abachi

  21. Java Development Environments • Sun's JDK is not an environment. • Sun's Java Workshop • Microsoft's Visual J++ • Symantec's Cafe • Borland's J Builder • Metrowerks' Code Warrior • Tek-Tools' Kawa. Taha Abachi

  22. Java Development Environments • My candidates : • IntelliJ IDEA • Eclipse • Textpad Taha Abachi

  23. Homework • Install Java properly • Write and Test you first Java program • Design an object oriented environment for manipulating geometrical shapes : • Different subtypes (square, circle, etc.) • Common characteristics (fields & methods) • Particular characteristics • Use UML (Unified Modeling Language) notation Taha Abachi

  24. Questions? Taha Abachi

More Related