The method is started by creating a new instance of its class which calls super class method pack to fit window according to subcomponents and makes frame visibility. In line 105 command line arguments are read to take port number for listening. Line 107 creates a serversocket along given port number greater than 1024 and builds RTPSocket to listen the port plus closes the serversocket. Lines 113-116 reads client IP address and client state is changed to INT.
I/O stream filters are created by using 118-119 command lines. A Non-blocking While loop works until request type is SETUP in line 125 (lines 124-147). When request type is SETUP, state is changed to READY and printed as new state value and calls send_RTSP_response for responding client which outputs RTSP/1.0 200 OK, CSeq, RTSPSeq Nb and session value. It works within lines 124-147 and also creates instance VideoStream with given filename (movie.mjpeg) and establish Datagram (transmission) socket within client. In lines 149-187, non-blocking while loop entertain client request and respond according to the state. Line 152 read parse_RTSP_request and "If, else" statements are executed according to the request. If parse_RTSP_request is PLAY and state is READY then client is responded by server, timer starts running, makes state to PLAYING and prints new state. If parse_RTSP_request is PAUSE and state is PLAYING then server sends response to the client, stops the timer and converts state to READY prints new state as well. If paese_RTSP_request is TEARDOWN then the server stops the timer, closes the server socket and exits the method.
Task 5
a)Java as an Object Oriented Programming (OOP):
Object Oriented Programming - describe what it is, the benefits and disadvantages, and how it is used in software development. In particular, discuss whether or not you think it is a successfulapproach for a beginner to programming. Use Java as an example of an OOP language.
The concept of object oriented programming is different from other programming languages. The main focus of OOP is objects instead of actions to complete a task. This type of approach is highly concerned with data rather then the logic. Data is treated as critical element in OOP, bounded closely to the functions operated on it and is protected from any external modification from outside of the functions.
OOP in software development: Object oriented programming provides easy way to deal with complexity in developing software systems with strengths of data abstraction. Program designs are based on operational data instead of operations themselves. OOP technology is built upon object models. Classes and objects used in OOP help understanding models and solving complex problems (Buyya 2004).
Some important features of OOP discussed by Buyya (2004) includes;
1)Abstraction of data: complex details are hard to capture in real world. OOP provides technique of abstraction focusing on necessary attributes and behavior relevant to the programming in a specific problem domain. Data abstraction consists of more common feature of objects and procedures at a single interface for multiple tasks.
2) Encapsulation: codes and data combined in to a single unit is called encapsulation. In java, class and objects provides encapsulation to secure manipulated data from external misuse.
3) inheritance: OOP's inheritance feature allows to extend and reuse the existing codes without repeating or rewriting them. It derives new classes from existing classes in a hierarchy. Inheritance is useful in extension and specification of programs.
4) Polymorphism: processing objects in data types and data classes differently or different objects responding in different ways to the same message is referred as polymorphism.
5) concurrency: Java concurrency based on threading, synchronization and scheduling deals with complex application development allowing extra ordinary flexibility in software applications.
6) programs can be divided in to models to reduce the complexity. Models are invisible units of the software that can be reused. Models, in OOP, are used for implementation of abstract data types.
Most commonly OOP languages are Java, C++ and C. examples of some other OOP languages includes Simla, Ada, Smalltalk, Objective C, Object Pascal and Eiffel.
Advantages of OOP as stated by Buyya (2004) in Software development:
OOP can enhance the software reusability
Maintenance and cost of the software can be reduced
Provides security by restricting external data accessibility
Software can be easily developed for complex problems
Improves the performance of the software
Quality of the software can be improved
Design process is facilitated by class hierarchies to increase extensibility
Achieve modularity
Makes data abstraction possible
Java provides greater flexibility, modularity and reusability as an object oriented language. It is centered on creating, manipulating and making objects that work together. Every thing in the world (e.g. person, ball, ground, mortgage etc.) can be modeled as an object. Object properties are described by using data while behaviors of objects are represented by using methods. Different classes of objects are created and arranged in a hierarchy to allow a child class inherits properties and behaviors from its parent class. Pre-defined classes can be grouped in packages to use in java programs. (Choudhri 2001).
Object oriented programming works in a way that allow multiple objects acting for a common message, but each of them in a way that is unique to the responding object. Simultaneously, OOP allows encapsulating an object to hide or protect the data associated with that object which gives an easy view without security access.
Another advantage is that OOP groups the objects and tasks in a manner where each model is capable of independent consideration. This is very important in making enhancements to a large software program. Modularity addresses the activity of making changes to the setup of a single portion of the programming without effecting structure and functionalities of the other existing modules.
Inheritance property of Java processes the objects in a way that they can acquire the properties of the objects of other class. In object oriented language, inheritance provides adding additional features to an existing class without any modification i.e. reusability. This can be achieved by deriving a new class from the existing class. This new derived class will contain combined features of both of the classes.
According to Chaudhry (2001), java language has simple and clean structure that helps programmers write and read programs easily.
Java was originally developed by James Gosling at Sun Microsystems and released in 1995. Syntax of the language evolved from C and C++ with a simplified object model and very few low-level constructions.
Java programs are compiled into Java Virtual Machine (JVM) to generate a byte code (.class file) which is platform independent and can run on any machine that has a Java interpreter
Security: Java language is designed in a way that it considers the security measures like loss of data and program integrity and damage to system users. According to Chaudhry (2001) Java is much reliable for advance security dependant systems even those developed to secure military systems.
Java provides multiple levels of reliability because pointers and automatic type conversion are avoided in java programming. Java compiler performs additional checks to identity type mismatches and other inconsistencies and runtime system duplicates checks performed by compiler. The runtime system also performs additional verification checks for executable bytecodes from valid Java program.
Java is famous for multi-media programming with its built-in multimedia capabilities. Graphics interchange Format, GIF and JPEG of Java supports images. Audio formats are AIFF, AU and WAV and Music formats supported by Java are MIDI and RMF (Chaudhry 2001)
Java for beginners: A simple object oriented approach of java makes it easy understandable for beginners as compared to the other languages. Java has an ability of automatic garbage collection and memory allocation. It has smaller number of language constructs although java is such a powerful language.
Java concurrency model is simple for the beginners to use concurrency effectively. Java has built-in support for multitasking. Any number of threads, executing parallel, can be created by Java programming. Ada provides built-in support for concurrency and is commonly used for teaching concurrency. However Ada does not support for GUI interfaces hence makes it difficult to write a simple concurrent program. A concurrent program is ideal if it provides support to multiple input and output sources. Java support GUI interfaces hence makes easy to write concurrent programs.
It is easy for the students to put the program on their web pages for test and critique by tutors who can then monitor the progress by visiting student's web page. It makes a simple feed back mechanism for learners.
Java is so popular and has a greater publicity which makes students excited about learning the language. Greater publicity with growing importance in the real world and ease of building GUI programs also provides a motivation for beginners in Java.
Java has its systematic structure that enable learners to know it is an organized manner rather then having a need to engulf it as a whole. A beginner is at ease of programming once introduced to Java.
Encapsulation: Java is featured to hide the complex nature of programming which makes it better teaching language. Java is easy to explain and understand.
A charming integral part of Java is Unicode charter set which allow learners addressing issues of international market software development. Java feature of learn as you use is a right methodology for technically challenged student/programmer. A student who starts in Java programming as a beginner would be able to learn Java step by step while doing hands on programming.
My own experience at UWE as a beginner to Java programming has been exciting as I was familiar with C++ which is quite complicated as compared to Java but general format is same. Starting understanding the basics like object classes and nest them in loops provided me an overall idea of how java program works. Little practice and more hand on programming skills made me confident. Although it was a short session to learn a new programming language but I gained a lot and a way how to improve further in future.
, java learners gain more interest
Java provides simpler network capabilities for beginners to experience writing network-aware programs. Accessing specific URLs on the web allow students to gain better understanding of how the works.
Java is inherently integrated with networking capabilities to make distributed computing easy. As stated Chaughry (2001) "writing network programs in Java is like a sending and receiving data from a file".
Java codes can run on many different hardware and software platforms e.g. several varieties of UNIX, NT and Windows etc. Java programs are portable and independent hardware and software platforms.