Wednesday, March 6, 2013

Naming Conventions


It's common to use a variable naming convention to distinguish between fields, arguments, and local variables.
Within the body of a method, all of these types of variables can appear. Many find naming conventions to be a helpful aid in getting a rapid understanding of a method's implementation. These conventions have only one purpose : to pour understanding into the brain of the reader as quickly as possible.

To understand a method, you need to understand its data. An important part of understanding data is understanding where it is defined - as a field, argument, or local variable. Naming conventions which distinguish these cases usually allow the reader to understand an implementation more quickly, since they no longer need to scan the class to determine where items are defined.

Some different styles are :

field : fBlah, _blah, blah_, this.blah, m_blah, myBlah
argument : aBlahBlah, pBlah
local variable : blahBlah
constant : BLAH_BLAH
As well, some use a naming convention for type names, to distinguish between interfaces and regular classes :
interface : IBlahBlah
class : BlahBlah, CBlahBlah
Note that this 'I' and 'C' convention is fundamentally different from the other conventions mentioned above. This convention is visible to the caller, while the other naming conventions, being confined to the implementation, are not.
The example code on this site usually follows these conventions :

field : fBlahBlah
argument : aBlahBlah
local variable : blahBlah
constant : BLAH_BLAH
class : BlahBlah
interface : BlahBlah (same as class)
The return value of a method is sometimes given a conventional name as well.

THE BENEFITS OF OOP


 OOP offers several benefits to the program designer and the user. Object-orientation contributes to the solutions of many problem associated with the development and quality of software products. The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost. The principal advantages are:

Through inheritance, we can eliminate redundant code and extend the use of existing classes.

·        We can built programs from standard working modules that communicate with one another rather than, having to start writing the code from scratch. This leads to saving of development time and higher productivity.

·        The principle of data hiding helps the programmers to built secure program that can’t be invaded by code in other parts of the program.

·        It is possible to have multiple objects to coexist without any interference.

·        It is possible to map objects in the problem domain to those objects in the program.

·        It is easy to partition the work in a project based on objects.

·        The data-centered design approach enables us to capture more details of the model in an implementable form.

·        Object-oriented systems can be easily upgraded from small to large system

·        Message passing technique for communication between objects make the interface descriptions with external system much simpler.

·        Software complexity can be easily managed.

oops concepts in java with realtime examples


OOPS Concepts are mainly 4 
 1.Abstraction
 2.Encapsulation
 3.Inheritance 
 4.Polymorphism
Abstraction:-Hiding non-essential features and showing the
essential features
              (or)
Hiding unnecessary data from the users details,is called
abstraction.
Real Time example:1.TV Remote Button 
in that number format and power buttons and other buttons
there.just we are seeing the buttons,we don't see the
button circuits.i.e buttons circuits and wires all are
hidden.so i think its good example.

Encapsulation:It is a process of binding or wrapping the data and the
codes that operates on the data into a single entity. This
keeps the data safe from outside interface and misuse. One
way to think about encapsulation is as a protective wrapper
that prevents code and data from being arbitrarily accessed
by other code defined outside the wrapper.
Real Time Example:  
1.Ink is the important component in pen but it is hiding
by some other material 
2.Medical Tablet
i.e one drug is stored in bottom layer and another drug is
stored in Upper layer these two layers are combined in
single Tablet.

Inheritance:The new classes, known as derived classes, take over (or
inherit) attribute and behavior of the pre-existing classes,
which are referred to as base classes (or Parent classes).
It is intended to help reuse existing code with little or no
modification.
Real Time Example:
1. Father and Son Relationship

Polymorphism:Single Form behaving differently in different Situations. A single 
function or single operator has different characters in different places. 
Real Time Example:
1.A girl plays a role of daughter at home and a manager at
office.
2. Person
Person in Home act is husband/son,
       in Office acts Employer.
       in Public Good Citizen.