Friday, October 28, 2016

                                            Polymorphism

In object-oriented programming, Polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. In other words, It is the ability to redefine methods for derived classes. Polymorphism is considered to be a requirement of any true Object-Oriented Programming Language (OOPL). There can we several types of Polymorphism.

What are the different types of Polymorphism ?

  • Ad hoc polymorphism: When the function denotes different heterogeneous implementations depending on a limited range of individually specified types and combinations. Ad hoc polymorphism is supported in many languages using function overloading.
  • Parametric polymorphism: When code is written without mention of any specific time and thus can be used transparently with any number of new types. In object-oriented programming community, this is often known as generics or generic programming. In functional programming community, this is often simply referred to as polymorphism.
  • Sub typing :This is also called subtype polymorphism or inclusion polymorphism. When a name denotes instances of many different classes related by some common superclass. In the object-oriented programming community, this is often simply referred to as polymorphism.
The interaction between parametric polymorphism and sub typing that leads to the concepts of variance  and bounded quantification. 

When is Polymorphism useful ?

The usefulness of Polymorphism depends on the programmer's design and logic. If the programmer  wants to bind your implementation at runtime then Subtype polymorphism will be useful. If you want to invoke different implementation at runtime based on the input arguments then ad-hoc polymorphism will help. If the programmer wants to write a code with a family of types, the code can ignore type specific details and  just interact with the base type of family. Even though the code thinks it is using an object's class could actually be the base class or any one of its subclasses. This makes it easier the programmer to write the code and the readers to understand.Overall, polymorphism provides a powerful feature in binding the  implementation at runtime and provides design extensibility.
_________________________________________________________________________________

References



_________________________________________________________________________________

Friday, October 21, 2016

                               Deadlock   

      Earlier the computer operating system ran only one program at a time. All the resources of the system were available to this one program. As technology developed, operating system ran multiple programs at once, interleaving them.This brought in the problem of Deadlock. Deadlock is a situation in which two computer programs share the same resources and effectively prevent each other from accessing the resources which results in both programs ceasing to function. In other words, this is a condition that occurs when two processes are each waiting for the each other to complete before proceeding and thus, the result is that both processes hang. Deadlocks mostly occur in multitasking and client/server environments.

What are the necessary conditions ?

There are four necessary conditions to achieve deadlocks :-

1) Mutual Exclusion: At least one resource must be held in a non-shareable mode; If any other process requests this resource, then the process must wait for the resource to be released.

2) Hold and Wait :A process must be simultaneously holding at least one resource and waiting for at least one resource that is currently being held by some other process.

3) No preemption: Once a process is holding a resource, then that resource cannot be taken away from that process until the process voluntarily releases it.
4)Circular Wait : A set of processes {P0,P1,P2, ....PN } must exist such that every P[i] is waiting       for P[(i+1)%(N+1)].



How to handle a deadlock ?


1)Generally speaking there are three ways of handling deadlocks:
  • Deadlock prevention or avoidance - Do not allow the system to get into a deadlocked state.
  • Deadlock detection and recovery - Abort a process or preempt some resources when deadlocks are detected.
  • Ignore the problem all together - If deadlocks only occur once a year or so, it may be better to simply let them happen and reboot as necessary than to incur the constant overhead and system performance penalties associated with deadlock prevention or detection. 

2) In order to avoid deadlocks, the system must have additional information about all processes. In particular, the system must know what resources a process will or may request in the future.

3)Deadlock detection is fairly straightforward, but deadlock recovery requires either aborting processes or preempting resources, neither of which is an attractive alternative.

4)If deadlocks are neither prevented nor detected, then when a deadlock occurs the system will gradually slow down, as more and more processes become stuck waiting for resources currently held by the deadlock and by other waiting processes. Unfortunately this slowdown can be indistinguishable from a general system slowdown when a real-time process has heavy computing needs.
_________________________________________________________________________________

Reference

_________________________________________________________________________________

Friday, October 14, 2016

                       Chrome  Extensions
        An extension is a zipped bundle of files- HTML, CSS, JavaScript, images and anything else that is needed and that adds functionality to the Google Chrome browser. Many extensions add UI to the  Google Chrome in the form of browser actions or page actions.Each extension can have at most one browser action or page action. A browser action that is most relevant to most pages is chosen. A page action is chosen according to when the extension icon should be active or inactive, depending on the page. Extensions are essentially web pages that can use all the APIs that the browser provides to web page. 
Each of the extensions have the following files 

  • A manifest file
  • One or more HTML files (unless the extension is a theme)
  • Optional: One or more Javascript files
  • Optional: Any other files your extension needs- for example, image files

The manifest file, called manifest.json, gives information about the extension such as the most important files and the capabilities that the extension might use.
     The most popular Google Chrome Extensions are Honey, Hangouts, Momentum, Office Online, Grammarly, Google Keep and Stay Focused. Each of them improvise the functions provided to us by  Chrome. 
The Extension Honey helps people find the best deal on any of the online shopping sites. The extension Hangout helps people to keep in touch and communicate.The Extension Google Keep helps people to take notes. The extension Grammarly helps people to get rid of all the typing errors they make while writing an articles. This extensions also fixes all the Grammatical errors and provides better vocabulary and phrasing for the sentences. The extension Stay Focused helps people to avoid getting distracted while researching. Google chrome was extremely powerful in itself but with these extensions added to it, it has become unbeatable.
_________________________________________________________________________________


Reference


_________________________________________________________________________________








Friday, October 7, 2016

                                      Operating System 

The operating system is the most important program that runs on a computer. It is the software that supports a computer's basic functions such as scheduling tasks, executing applications, and controlling peripherals. Every general purpose computer must have an operating system to run other programs and applications. For large  systems, the operating system has even greater responsibilities and powers. It makes sure that different programs and users running at the same time do not interfere with each other.


 What is the classification of Operating Systems?

 TheOperating System can be of different types :
  • Multi-user: It allows two or more users to run programs at the same time. Some operating systems permit hundreds or even thousands of concurrent users.
  • Multi-tasking : It supports running a program on more than one CPU.
  • Multi-processing: It allows more than one program to run concurrently.
  • Multi-threading: It allows different parts of a single program to run concurrently.
  • Real Time: It responds to input instantly.The general-purpose operating systems are not real time. 

What are the functions of operating systems ?

  • Memory Management: Memory management refers to the management of Primary Memory or Main Memory. Main Memory is a large array of words or bytes where each word or byte has its own address.The operating system does the following activities:
            - Keeps track of primary memory
            - In Multiprogramming, the OS decides which process will get me memory and how much
            - allocates the memory when a process requests it to do so.
            - De-allocates the memory when a process no longer needs it or has been terminated.
  • Processor Management:In multiprogramming environment, the OS decides which process gets the processor when and for how much time. This function is called Process Scheduling. An Operating System does the following activities for Processor management:   
          -Keeps track of processor and status of the process. The program responsible for this task is                  known as Traffic Controller
          -Allocate a processor(CPU) to a process
          - De-Allocate processor when a process is no longer required
  • Device Management:An operating System manages device communication via their respective drivers. The Operating System does the following Activities for the Device Management -
           - Keeps track of all devices.Program responsible for this task is known as I/O Controller
           - Decides which process gets the device when and for how much time.
           - Allocates the device in the efficient way.
           - De-allocates devices.
  • File Management: A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions.An operating System does the following activities for file management:
           - Keeps track of information, location, uses, status and etc. The collective facilities are often                  known as file system.
           - Decides who gets the resources.
           - Allocates the resources.
           - De-allocate the resources.
  • Others : The other important Activities include:
            - Security
            - Control over system performances
            - Job accounting 
            - Error detecting aids
            - Coordination between other softwares and users.

________________________________________________________________________________

References

________________________________________________________________________________






Friday, September 30, 2016

                                Metaprogramming 


Metaprogramming is the art of writing a computer program with the ability to treat programs as their data.It means that a program could be design to read, generate, analyze or transform other programs, and even modify itself while running. Metaprogramming is what is done with C++ templates or CommonLisp macros. The code in question usually consists of a template and some instructions and how to fill it. The instructions in Metaprogramming are rather complicated. CommonLisp Macros can transform or generate the code in arbitrarily sophisticated ways.The programs that can be modified at runtime or have incremental compilation  available can be actually used to perform Metaprogramming without generating a source code. The java languages can be used for metaprogramming are  C#, Forth, Frink, Groovy, JavaScript, Lisp, Lua, Perl, PHP, Python, REBOL, Ruby, Smalltalk, and Tcl.

Why is Metaprogramming done ?

  • To get around limitations in the primary development languages. Usually, this sort of thing is done when  there is a management edict to use a particular language. The use of a different language is not allowed but doing MetaProgramming with the development language as the target is politically acceptable. 
  • To encapsulate domain-specific knowledge. These languages are generally more domain-dependent.
  • To allow users to configure and program a system even though it is assumed that the user will not be capable of modifying the program source directly, or might not even have access to that source. 





Is metaprogramming a good idea ?

The answer to the problem of whether Metaprogramming is a good idea or not depends on how domain-specific the meta-language is and on how complicated it is. The domain-specific meta-languages are more justifiable and simpler, and simpler is better.
_______________________________________________________________________________


References 

_______________________________________________________________________________



Friday, September 23, 2016

                         Turing Machine

Turing machines are the original idealized model of a computer invented by Alan Turing in 1936. They were initially called a-machines, which referred to the automatic machine. They are equivalent to modern electronic computers at a certain theoretical level, but differ in many details.Turing machines are simple abstract computational devices intended to help investigate the extent and limitations of what can be computed.They are finite state machines with the ability to read and write data to a tape with an unlimited supply of paper. There are formulations of Turing machine, but essentially the machine reads a symbol from the tape, which is used as an input to the finite state machine.
 The turing machine consists of a tape, a head, a state register and a finite table of instructions. A tape is divided into cells, one next to the other. Each cell contains a symbol from some finite alphabet. The alphabet contains a special blank symbol which is denoted by '0' and one or more other symbols. The tape is assumed to be arbitrarily extendable to the left and to the right.The head is the part of the machine that can read and write symbols on the tape and move the tape left and right one (and only one) cell at a time. In some models the head moves and the tape is stationary.state register is the part that stores the state of the Turing machine. Among these is the special start state with which the state register is initialized. The finite table of instructions tells the computer to either erase or write a symbol, move the head and then assume the same or new state.

The initial arrangement of the colors of the cells on the tape correspond to the input given to the computer. This input can contain both "program" and "data". The steps of the Turing machine correspond to the running of the computer. The rules for the Turing machine are analogous to machine-code instructions for the computer.Given the particulars, each part of the rule specifies what "operation" the machine should perform. The remarkable fact is that certain Turing machines are universal with the appropriate input. They can be made to perform any ordinary computation.
___________________________________________________________________________

Reference



___________________________________________________________________________


Friday, September 16, 2016

                    Programming  Video Games 

One of the Industries that has taken over the world is the Video game Industry. The video game industry targets the audience between the age group of 18 -34. This field is all about Computer Science programming and Designing. Game programming is a small part of this industry but is the most important part of this industry. It is that part of the industry which deals with the software development of the video games. Software Development of the video games is defined as " the process of computer programmingdocumenting,testing, and bug fixing involved in creating and maintaining applications and frameworks resulting in a software product. "

The choice of Computer Language used for programming is not only  a matter of mere choice or preference but it also depends on a lot of other factors like whether the language is supposed to be object oriented, whether it has minimal CPU overhead ,  whether it has familiar syntax or whether it is easily portable and more. Sometimes the domain specific features are also taken into account such as interfacing with the operating system, and resilience to reverse engineering for online video games.Many games are not written in only one specific language but are a combination of two or more programming languages such as C, C++, Java. An example of such a game engine is Unity which includes C,C++, and C# .The most commonly used Computer languages for video game programming are Assembly, Java , C, C++ and Javascript.
People who want to be game programmers are required to have substantial skills in software engineering as well as specialization in one of the fields such as simulationcomputer graphicsartificial intelligencephysicsaudio programming, and inputProgrammers often closely follow the game design document. As the game development progresses, the design document changes as programming limitations and new capabilities are discovered and exploited.The formal quality assurance testing process, performed by professional game testers, begins well into game development. High-budget titles may begin testing with the first playable alpha, while low-budget and casual games might not enter testing until a release candidate is ready. The programmers' task is to fix errors and bugs as such are discovered by the QA teams
_________________________________________________________________________________

Reference 


_________________________________________________________________________________