1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Intro to advanced programming (lập TRÌNH NÂNG CAO SLIDE)

48 26 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 48
Dung lượng 636,37 KB

Nội dung

ADVANCED PROGRAMMING (LTNC) Course Topics – Java Basics         Declarations and Access Control Data Types Varialable Assignments Operators Object Orientation Flow Control, Exceptions String Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 2/48 Course Topics – Java Basics        Class defination Access modifiers Inheritance Overriding / Overloading Object reference Constructor and instantiation Class and Object varialables Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 3/48 Course Topics – GUI (SWING)         Swing overview Swing by examples Swing components Layout Management Event Handling Performing custom painting More Swing Features and Concepts How to use the Swing components Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 4/48 Grading    Attendance: 15% Midterm exam: 35% (Lab) Final exam: 50% (Lab) Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 5/48 Bibliography Core JAVA, Volume I, Cay S Horstmann, Gary Cornell, Sun MicroSystem Press, USA 2008 Core JAVA, Volume II, Cay S Horstmann, Gary Cornell, Sun MicroSystem Press, USA 2008 Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 6/48 Computer Program Set of instructions written in a programming language that tells the computer what to Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 7/48 The Programming Process Defining the problem Planning the solution Coding the program Testing the program Documenting the program Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 8/48 The Programming Process: Defining the Problem    What is the input What output you expect How you get from the input to the output Coding the Program   Translate algorithm into a formal programming language Within syntax of the language   Text editor Programming environment: Interactive Development Environment (IDE) Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 9/48 Languages Machine code or machine languages  A sequence of 0’s and 1’s giving machine specific instructions Example: 00011001  Displayed as hexadecimal    Only language the computer understands All other programming languages are translated to machine language Computer dependent Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 10/48 - IDE     Provides comprehensive facilities to computer programmers for software development Normally consists of a source code editor, build automation tools and a debugger IDEs can contain compiler, interpreter Some Java IDEs:   Eclipse Netbean 34 Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 34/48 TECHNOLOGY     The Java Platform A platform is the hardware or software environment in which a program runs We've already mentioned some of the most popular platforms like Microsoft Windows, Linux, Solaris OS, and MacOS Most platforms can be described as a combination of the operating system and underlying hardware The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms The Java platform has two components: The Java Virtual Machine The Java Application Programming Interface (API) Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 35/48 TECHNOLOGY  Simple   We wanted to build a system that could be programmed easily without a lot of esoteric training and which leveraged today's standard practice.Java omits many rarely used, poorly understood, confusing features of C++ that, in our experience, bring more grief than benefit The syntax for Java is, indeed, a cleaned-up version of the syntax for C++ There is no need for header files, pointer arithmetic (or even a pointer syntax), structures, unions, operator overloading, virtual base classes, and so on Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 36/48 TECHNOLOGY  Object Oriented   Simply stated, object-oriented design is a technique for programming that focuses on the data (= objects) and on the interfaces to that object The object-oriented facilities of Java are essentially those of C++ The object-oriented features of Java are comparable to C++ The major difference between Java and C++ lies in multiple inheritance, for which Java has found a better solution, and in the Java metaclass model Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 37/48 TECHNOLOGY  Distributed   Java has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP Java applications can open and access objects across the Net via URLs with the same ease as when accessing a local file system The networking capabilities of Java to be both strong and easy to use Anyone who has tried to Internet programming using another language will revel in how simple Java makes onerous tasks like opening a socket connection Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 38/48 TECHNOLOGY    Robust Java is intended for writing programs that must be reliable in a variety of ways Java puts a lot of emphasis on early checking for possible problems, later dynamic (run-time) checking, and eliminating situations that are error-prone The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data This feature is also very useful The Java compiler detects many problems that, in other languages, would show up only at run time As for the second point, anyone who has spent hours chasing memory corruption caused by a pointer bug will be very happy with this feature of Java Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 39/48 TECHNOLOGY  Architecture Neutral   The compiler generates an architecture-neutral object file format—the compiled code is executable on many processors, given the presence of the Java run time system The Java compiler does this by generating bytecode instructions which have nothing to with a particular computer architecture Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the fly Portable  Unlike C and C++, there are no "implementationdependent" aspects of the specification The sizes of the primitive data types are specified, as is the behavior of arithmetic on them Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 40/48 TECHNOLOGY  Interpreted   The Java interpreter can execute Java bytecodes directly on any machine to which the interpreter has been ported Since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory High Performance  While the performance of interpreted bytecodes is usually more than adequate, there are situations where higher performance is required The bytecodes can be translated on the fly (at run time) into machine code for the particular CPU the application is running on Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 41/48 TECHNOLOGY  Multithreaded    The benefits of multithreading are better interactive responsiveness and real-time behavior If you have ever tried to multithreading in another language, you will be pleasantly surprised at how easy it is in Java Threads in Java also have the capacity to take advantage of multiprocessor systems if the base operating system does so Secure  Java is intended to be used in networked/distributed environments Toward that end, a lot of emphasis has been placed on Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 42/48 A SHORT HISTORY OF JAVA   Java goes back to 1991, when a group of Sun engineers, led by Patrick Naughton, Sun Fellow and James Gosling, wanted to design a small computer language that could be used for consumer devices like cable TV switchboxes Since these devices not have a lot of power or memory, the language had to be small and generate very tight code Also, because different manufacturers may choose different central processing units (CPUs), it was important not to be tied down to any single architecture The project got the code name "Green.“ In 1992, the Green project delivered its first product, called "*7." It was an extremely intelligent remote control Unfortunately, no one was interested in producing this at Sun, and the Green people had to find other ways to market their technology However, none of the standard consumer electronics companies were interested.Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 43/48 A SHORT HISTORY OF JAVA    The Green project (with a new name of "First Person, Inc.") spent all of 1993 and half of 1994 looking for people to buy its technology—no one was found The World Wide Web part of the Internet was growing bigger and bigger The key to the Web is the browser that translates the hypertext page to the screen In 1994, most people were using Mosaic, a noncommercial Web browser that came out of the supercomputing center at the University of Illinois in 1993 In the SunWorld interview, Gosling says that in mid1994, the language developers realized that "We could build a real cool browser It was one of the few things in the client/server mainstream that needed some of the weird things we'd done: architecture neutral, real-time, reliable, secure—issues that weren't terribly important in the workstation SoLâm weTP.built browser." 44/48 Khoa CNTT world – ĐH Nông HCM a 01/2016 A SHORT HISTORY OF JAVA    Sun released the first version of Java in early 1996 People quickly realized that Java 1.0 was not going to cut it for serious application development The big news of the 1998 JavaOne conference was the upcoming release of Java 1.2, which replaced the early toy-like GUI and graphics toolkits with sophisticated and scalable versions that come a lot closer to the promise of "Write Once, Run Anywhere"™ than their predecessors Three days after (!) its release in December 1998, Sun's marketing department changed the name to the catchy term Java Standard Edition Software Development Kit Version 1.2 Besides the "Standard Edition," two other editions were introduced: the "Micro Edition" for embedded devices such as cell phones, and the "Enterprise Edition" for server-side processing Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 45/48 HOW WIL JAVA TECHNOLOGY CHANGE MY LIFE    Get started quickly: Although the Java programming language is a powerful object-oriented language, it's easy to learn, especially for programmers already familiar with C or C++ Write less code: Comparisons of program metrics (class counts, method counts, and so on) suggest that a program written in the Java programming language can be four times smaller than the same program in C++ Write better code: The Java programming language encourages good coding practices, and its garbage collection helps you avoid memory leaks Its object orientation, its JavaBeans component architecture, and its wide-ranging, easily extendible API let you reuse other people's tested code and introduce fewer bugs Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 46/48 HOW WIL JAVA TECHNOLOGY CHANGE MY LIFE     Develop programs more quickly: Your development time may be as much as twice as fast versus writing the same program in C++ Why? You write fewer lines of code and it is a simpler programming language than C++ Avoid platform dependencies: You can keep your program portable by avoiding the use of libraries written in other languages Write once, run anywhere: Because Java applications are compiled into machine-independent bytecodes, they run consistently on any Java platform Distribute software more easily: With Java Web Start technology, users will be able to launch your applications with a single click of the mouse Khoa CNTT – ĐH Nông Lâm TP HCM 01/2016 47/48 CREATING YOUR FIRST APPLICATION  Create a source file A source file contains text, written in the Java programming language, that you and other programmers can understand You can use any text editor to create and edit source files  Compile the source file into a class file The Java compiler, javac, takes your source file and translates its text into instructions that the Java Virtual Machine can understand The instructions contained within this file are known as bytecodes  Run the program The Java launcher (java) uses the Khoa Java Virtual Machine to01/2016 run your 48/48 CNTT – ĐH Nông Lâm TP HCM ... The Programming Process: Defining the Problem    What is the input What output you expect How you get from the input to the output Coding the Program   Translate algorithm into a formal programming. ..     Provides comprehensive facilities to computer programmers for software development Normally consists of a source code editor, build automation tools and a debugger IDEs can contain compiler,... instructions which have nothing to with a particular computer architecture Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the

Ngày đăng: 29/03/2021, 10:53

TỪ KHÓA LIÊN QUAN