tag:blogger.com,1999:blog-64663049016179156202024-02-07T09:27:35.060-08:00Geeky CatGeeky Cat's IT Den...a plethora of self-tried examples and viewsSherna Jayhttp://www.blogger.com/profile/07834400267247395337noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6466304901617915620.post-57168181947055099412011-12-26T04:13:00.000-08:002013-02-22T23:48:46.162-08:00CDAC DAC Course Center Mumbai<div dir="ltr" style="text-align: left;" trbidi="on">
----------------A center dedicated to students needs and keeps getting better with every batch.<br />
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">Today my first Project at 3-i Infotech went live! Thank you <a href="http://www.vidyanidhi.com/" target="_blank">VITA</a> for making me capable of experiencing this day.</span><br />
<br />
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">VITA, Vidyanidhi Infotech Academy is in Juhu, Andheri (west). Do check out the website <a href="http://www.vidyanidhi.com/" target="_blank">here</a>. </span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">It's been a life changing experience doing my post graduate Diploma in Advanced Computing at VITA. To start with I must say the environment created by VITA for their students is simply commendable. You ask what you require for better studies and they will provide it to you.</span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;"> I've never seen such a responsive management. They ensure that each module is conducted by trainers from the Software Industry. The technical guidance from such faculty got me truly ready for the IT Industry. Along with the academics we were also trained in enhancing our Aptitude Skills. Various Interview Sessions are held in order to prepare us for the AIM which is to get us placed. </span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">Despite a grueling 12 hr training daily ( 8 am to 8 pm) we still found time to have fun…. Bhel Parties, festivals, Birthday Celebration and of course a Trip at the end of the course which gave us memories to be cherished for life. </span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">Last but not the least I must say that the team at VITA is the heart and soul of VITA. They have guided me to where I stand now. For me VITA is <span style="color: #c00000;">Vital Ingredient Towards Accomplishment</span>.</span></div>
<div class="MsoNoSpacing">
<br />
<div class="MsoNoSpacing">
<span style="color: #0070c0; font-family: "Calibri","sans-serif"; font-size: 13pt;">------------------------------------------------------------------<b style="mso-bidi-font-weight: normal;">Abhishek Gorale</b></span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span style="color: #0070c0; font-family: "Calibri","sans-serif"; font-size: 13pt;"> </span></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Calibri","sans-serif"; font-size: 13pt;">Batch:<span style="color: #0070c0;"> February 2011 </span></span></b></div>
<div class="MsoNoSpacing">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh1CmEvmRgDyXmxiUh3HxUqMQ_9D0zso82PFWaSnpWnN0lnD-8WtWeiQOx0W6d4EnZK5Gi_kdEbpMp0K_6bfh3lG2qaCrH4tPyIO4whbJwY17-mvqV-s3MuQLWLQbXrNPScBXSnU-5buTV/s1600/Abhishek+Gorale%2528Modified%2529+pic.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh1CmEvmRgDyXmxiUh3HxUqMQ_9D0zso82PFWaSnpWnN0lnD-8WtWeiQOx0W6d4EnZK5Gi_kdEbpMp0K_6bfh3lG2qaCrH4tPyIO4whbJwY17-mvqV-s3MuQLWLQbXrNPScBXSnU-5buTV/s400/Abhishek+Gorale%2528Modified%2529+pic.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: small;">A day with the VITA FAMILY</span></td></tr>
</tbody></table>
<div class="MsoNoSpacing">
<br /></div>
<span style="font-family: "Calibri","sans-serif";"> </span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div style="color: #a64d79;">
<b>P.S.: </b></div>
<div style="color: #a64d79;">
<b>------- This is an original and genuine review about <a href="http://www.vidyanidhi.com/" target="_blank">VITA(Vidyanidhi Info Tech Academy)</a>,a certified C-DAC ACT, in JUHU Mumbai.Comments/Queries and suggestion may please contact</b></div>
<div style="color: #a64d79;">
<b>meowconnect@gmail.com.</b></div>
<br />
<br /></div>
Sherna Jayhttp://www.blogger.com/profile/07834400267247395337noreply@blogger.com0tag:blogger.com,1999:blog-6466304901617915620.post-14423810108940263832011-08-08T07:07:00.000-07:002011-08-08T07:07:13.607-07:00OOPS....Interview Preparation<div dir="ltr" style="text-align: left;" trbidi="on"><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">OOPS..yu did it again!!!!</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Object Oriented Programming is a dreaded topic for interviews in the IT field</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Here's a simple go thru with examples and explaination to help you out.</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Fundamental concepts of OO Language which a language has to follow,in order to be a truly OO language. </span></b></div><div style="color: #674ea7; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">• OBJECT<br />
• CLASS<br />
• ABSTRACTION<br />
• ENCAPSULATION<br />
• DATA HIDING / INFORMATION HIDING<br />
• INHERITANCE<br />
• POLYMORPHISM</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"></span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Lets take a brief look into these concepts. </span></b></div><div class="MsoNormal" style="color: #674ea7; font-family: "Trebuchet MS",sans-serif; text-align: justify;"><span style="font-size: small;"><u><b>Objects: </b></u></span></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;">Object is the basic unit of object-oriented programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.</span></b></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;"> </span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><br />
</span></b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdB9EQocSDXVBaLwUkXFSP2tOHBJR4nI9Bi4INeFsdw7g4N7v-SH97TstO39S1Ymi-inMe1svkLFdpo3tLfzBEEc95_FsjgS-cst0l_fR6F_lkWYejEKyWLp031aVgdWiL6G42qDEIQEod/s1600/img1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdB9EQocSDXVBaLwUkXFSP2tOHBJR4nI9Bi4INeFsdw7g4N7v-SH97TstO39S1Ymi-inMe1svkLFdpo3tLfzBEEc95_FsjgS-cst0l_fR6F_lkWYejEKyWLp031aVgdWiL6G42qDEIQEod/s320/img1.JPG" width="320" /></a></div><b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;"><br />
</span></b></div><div style="color: #3d85c6; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;">An Object is a collection of data members and associated member functions also known as methods. </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; text-align: justify;"><b><span style="font-size: small;"><br />
</span></b></div><div class="MsoNormal" style="color: #674ea7; font-family: "Trebuchet MS",sans-serif; text-align: justify;"><u><b><span style="font-size: small;">Classes: </span></b></u></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;">Classes are data types based on which objects are created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represent a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects becomes functions of the class and is referred to as Methods.</span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; text-align: justify;"><b><span style="font-size: small;"> <br style="font-family: "Trebuchet MS",sans-serif;" /><span style="font-family: "Trebuchet MS",sans-serif;"> </span></span></b></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;">For example consider we have a Class of <i>Cars </i>under which <i>Santro Xing</i>, <i>Alto </i>and <i>WaganR </i>represents individual Objects. In this context each <i>Car </i>Object will have its own, Model, Year of Manufacture, Colour, Top Speed, Engine Power etc., which form Properties of the <i>Car </i>class and the associated actions i.e., object functions like Start, Move, Stop form the Methods of <i>Car</i> Class.</span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; text-align: justify;"><b><span style="font-size: small;"><br />
</span></b></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-bottom: 3.75pt; text-align: justify;"><b><span style="font-size: small;">No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created. </span></b></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; line-height: 14.4pt;"><b><span style="font-size: small;">In the software world, though you may not have realized it, you have already used classes. For example, the <i>TextBox </i>control, you always used, is made out of the <i>TextBox </i>class, which defines its appearance and capabilities. Each time you drag a <i>TextBox </i>control, you are actually creating a new instance of the <i>TextBox </i>class.</span></b></div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; line-height: 14.4pt;"><br />
</div><div class="MsoNormal" style="background: none repeat scroll 0% 0% white; color: #3d85c6; font-family: "Trebuchet MS",sans-serif; line-height: 14.4pt;"><b><span style="font-size: small;"></span><span style="font-size: small;">Example: Car object</span></b><br />
<b><span style="font-size: small;">– State</span></b><br />
<b><span style="font-size: small;">• Current Speed • Current Gear • Engine State (Running, Not Running)</span></b><br />
<b><span style="font-size: small;">– Behavior (Acts on the object and changes state)</span></b><br />
<b><span style="font-size: small;">• Slow down • Accelerate • Stop • Switch Off Engine • Start Engine</span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD6qy9-Fhcm1kM5Gh0qq0y9aF9f8VAeesSSPXlZzv8WdPzMfiAsavSUUy1-tUowSZ6yXna2FtGwieDPHfCle5TWyDNG-IpKs7n-ryWcscrzA0Ixv2DlgOxWVin0jfbsn2760QRmQIQoFTN/s1600/img2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD6qy9-Fhcm1kM5Gh0qq0y9aF9f8VAeesSSPXlZzv8WdPzMfiAsavSUUy1-tUowSZ6yXna2FtGwieDPHfCle5TWyDNG-IpKs7n-ryWcscrzA0Ixv2DlgOxWVin0jfbsn2760QRmQIQoFTN/s320/img2.JPG" width="320" /></a></div><b><span style="font-size: small;"><br />
</span></b><br />
<br />
<u style="color: #674ea7;"><b><span style="font-size: small;">Abstraction</span></b></u><b><span style="font-size: small;">:</span></b><b><span style="font-size: small;"> </span></b><br />
<b><span style="font-size: small;">Abstraction means hiding complex details of creation(logic and functions) and just implement/call them without bothering about how they work?.Abstraction focuses the outside view of an object/concept. As an example, consider the vector in standard library. You want to create a vector with a given size (constructor), enlarge or grow the vector (push_back), accesing to elements (operator[]) and ... It is less<br />
important to know ,how vector is internally implemented. You may use vector<br />
for years, but you probably don't know how vector is implemented.</span></b><br />
<br />
<div style="color: #45818e;"><b><span style="font-size: small;">Real Time Example: TV Remote Control </span></b></div><div style="color: #45818e;"><b><span style="font-size: small;">We use it for switch on , switch off , increase or decrease volume , select a particular channel etc. without bothering how it works internally.</span></b></div><div style="color: #45818e;"><br />
</div><b><span style="font-size: small;">Abstraction in real life means "showing only what is necessary and hiding whatever unnecessary". C++ implements this by putting a seperation between properties of datatypes which are visible and the associated implementation details which are hidden.<br />
Eg: </span></b><br />
<div style="color: #45818e;"><b><span style="font-size: small;">--- A touch screen at railway station or ATM machine<br />
In these devices we just use the touch screen application to satisfy our needs, we dont see what is happening inside its software. </span></b></div><div style="color: #45818e;"><b><span style="font-size: small;">--- A class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to <a href="http://en.wikipedia.org/wiki/Interface_%28computer_science%29" title="Interface (computer science)">interface</a> with them, i.e., send messages to them, receive messages from them etc.</span></b></div><div style="color: #45818e;"><br />
</div><b><span style="font-size: small;"><u style="color: #674ea7;">Encapsulation</u>:</span></b><br />
<b><span style="font-size: small;">Encapsulation means combining both data and function that operates on that data into a single unit i.e. class.Encapsulation is the mechanism that binds together the code and the data it manipulates, and keeps both safe from outside interference and misuse. A car’s dashboard hides the complexity and internal workings of its engine.<br />
Data Hiding</span> <span style="font-size: small;"> means to make data invisible to external functions to minimize accidental modification/change of important data.</span></b><br />
<b><span style="font-size: small;">Some other common definitions <br />
1. Insulation of data from direct access by the program.when we put data and methods in a context,say,a class , we have achieved encapsulation but when we use public/private/protected keywords, we acheive Information hiding.Following is the best example of all the three<br />
<br style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;" /><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> <span style="color: #a64d79;">class employee /* </span></span></span><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; font-size: small;">Encapsultaion*/<br />
{<br />
private: <br />
char name[20];<br />
int age;<br />
float salary;<br />
<br />
public: /*</span><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; font-size: small;">Data Hiding, Following functions access data */ <br />
void getemployee<br />
{<br />
cout<< "Enter name";<br />
cin>>name;<br />
cout<<"Enter Age";<br />
cin>>age;<br />
cout<< "Enter Salary";<br />
cin>>salary;<br />
} <br />
void showemployee<br />
{<br />
cout<<"\n Name"<<name;<br />
cout<<"\n Age"<<age;<br />
cout<<"\n Salary"<<salary;<br />
}<br />
};<br />
void main()<br />
{<br />
/*Abstraction:- working defined in employee class*/<br />
<br />
employee e1;</span><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; font-size: small;"><br />
e1.getemployee(); // abstraction<br />
e1.showemployee(); // abstraction<br />
}</span></b><br />
<br />
<b><span style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; font-size: small;"> </span></b> </div><div style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><u style="color: #674ea7;">Method</u>:-</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">An object's abilities. In language, methods are verbs. <code style="color: #a64d79;">Lassie</code>, being a <code style="color: #a64d79;">Dog</code>, has the ability to bark. So <code style="color: #a64d79;">bark()</code> is one of <code>Lassie</code>'s methods. She may have other methods as well, for example <code style="color: #a64d79;">sit()</code> or <code style="color: #a64d79;">eat()</code> or <code style="color: #a64d79;">walk()</code>. Within the program, using a method usually affects only one particular object; all <code>Dog</code>s can bark, but you need only one particular dog to do the barking.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><u style="color: #674ea7;">Message Passing</u>:-</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">“The process by which an object sends data to another object or asks the other object to invoke a method” .</span></b><br />
<b><span style="font-size: small;"> <span style="color: #45818e;">E.g. the object called </span><code style="color: #45818e;">Student</code><span style="color: #45818e;"> may communicate with </span><code style="color: #45818e;">Course</code><span style="color: #45818e;"> object to know how many courses are there by invoking </span><code style="color: #45818e;">Course's</code><span style="color: #45818e;"> 'getCount' method. </span></span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><u style="color: #674ea7;">Inheritance</u>: </span></b><br />
<b><span style="font-size: small;">Defining new classes from the existing one. The new class will get all the methods and properties of the existing class. The new class known as sub class / child class / derived class. The existing class known as super class / parent class / base class.<br />
Inheritance is implied by “is-a” or “kind-of” relationship. Inheritance is basically used for reuse the code and focus to make generic kind of thing rather than specific one.<br />
Some other common definitions<br />
1. An object can acquire the properties of another object. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">As an example you can say that both IOException and SecurityException are of type Exception. They have all characteristics and behaviors of an Exception, That mean the IOException is a specialized kind of Exception. A SecurityException is also an Exception. As such, we expect it to share certain characteristic with IOException that are generalized in Exception, but to differ in those characteristics that are specialized in SecurityExceptions. In other words, Exception generalizes the shared characteristics of both IOException and SecurityException, while IOException and SecurityException specialize with their characteristics and behaviors. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">In OOP, the specialization relationship is implemented using the principle called inheritance. </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><u style="color: #674ea7;">Polymorphism</u>:</span></b><br />
<b><span style="font-size: small;"> Ability to acquire different forms. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Static or compile-time Polymorphism / early binding</span></b><br />
<b><span style="font-size: small;"> Static Polymorphism is the use of one method signature, or one operator such as "+", to perform several different functions depending on the implementation. The "+" operator, for example, may be used to perform integer addition, float addition, list concatenation, or string concatenation. Any two subclasses of Number, such as Integer and Double, are expected to add together properly in an OOP language. The language must therefore overload the addition operator, "+", to work this way. This helps improve code readability.</span></b><br />
<div style="font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Runtime or dynamic Polymorphism / late binding</span></b></div></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">An Object is in different forms and in each form its exhibit the same functionality but the implementation is different.</span></b><b><span style="font-size: small;">Single Form behaving differently in different Situations.</span></b><br />
<b><span style="font-size: small;"></span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-left: 7.65pt; text-indent: -7.65pt;"><b><span style="font-size: small;">Example:-</span></b><br />
<b><span style="font-size: small;">1. </span></b><b style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Man</span></b><b><span style="font-size: small;">: Man at Home act as husband/son, in Office acts as an Employee, in Public acts as a Good Citizen.</span></b><br />
<b><span style="font-size: small;">2. Output Device (parent class) Functionality :- <u>display()</u></span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-left: 7.65pt; text-indent: -7.65pt;"><b><span style="font-size: small;">-- Monitor form , overrides “display()” for display on the console.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-left: 7.65pt; text-indent: -7.65pt;"><b><span style="font-size: small;">-- Printer form , overrides “display()” for display on the paper.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-left: 7.65pt; text-indent: -7.65pt;"><b><span style="font-size: small;">-- LCD form, overrides “display()” for display on the screen.</span></b><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVt6JHbNOF9xjx9yHSZ54wi0KHaZATPmx9EGT2P-jCeSl8jIQjWilDf39f4tElFWYo1K18O2LzXL81R1VU_XpWGFVSFYZMEpj4LhyphenhyphenImn77O2YbZTPgDxU9_qiHGWtyk7W_ZRZW2j_bb2Ty/s1600/img3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVt6JHbNOF9xjx9yHSZ54wi0KHaZATPmx9EGT2P-jCeSl8jIQjWilDf39f4tElFWYo1K18O2LzXL81R1VU_XpWGFVSFYZMEpj4LhyphenhyphenImn77O2YbZTPgDxU9_qiHGWtyk7W_ZRZW2j_bb2Ty/s320/img3.JPG" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjay4rROPFY_LGoYs_R6wRvdzC5JHYZjP-dj7MfdfaxlnTZH7BdBZiL1WQHfkW4CI-K2N0_KmDFvTqQVIN-7AHQ9k9k0OtQMyZkcS7AD9Ublz735mp6ZC0G_ymcGHWPhfp9iIp5wf9-cYPA/s1600/img4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="184" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjay4rROPFY_LGoYs_R6wRvdzC5JHYZjP-dj7MfdfaxlnTZH7BdBZiL1WQHfkW4CI-K2N0_KmDFvTqQVIN-7AHQ9k9k0OtQMyZkcS7AD9Ublz735mp6ZC0G_ymcGHWPhfp9iIp5wf9-cYPA/s320/img4.JPG" width="320" /></a></div><div style="font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">•<span style="font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span>References are all the same, but objects are not</span></b></div></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"></span></b><b><span style="font-size: small;">•<span style="font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span>Method invoked is that associated with the OBJECT, NOT with the reference.</span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">In <span style="color: #45818e;">Compile Time Polymorphism</span> Here compiler knows which object , you are working with. Overloading is a compile time polymorphism. In Overloading method should have same name with different arguments. Simple example of overloading is if you have scenario in which you want to add 2 numbers or characters or strings or doubles. You can have 4 methods with the same name “add” , but with different arguments.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">In <span style="color: #45818e;">Run Time Polymorphism</span>, Here compiler doesn’t know to which object parent class pointer or reference referring to . It is known during runtime only. Overriding or inheritance-based polymorphism are kind of polymorphism. Simple and very common is, if you have a class shape which is inherited to Triangle, Square and Circle classes. Shape class has a virtual method name as “Draw” which will definitely inherited to all inherited class. All sub classes i.e. Triangle, Square and Circle can override “Draw”. Now, if you declare a pointer or reference of shape class and initialize it with any of the inherited class it will call the method of inherited class. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Some other common definitions<br />
1. One name many forms.<br />
2. One interface multiple methods / ways.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #674ea7; font-family: "Trebuchet MS",sans-serif;"><u><b><span style="font-size: small;">Association , Aggregation and Composition</span></b></u></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">In <span style="text-decoration: none;">Object-oriented programming</span>, Association defines a relationship between classes of objects which allows one object instance to cause another to perform an action on its behalf. It means "sending a <span style="text-decoration: none;">message</span> (message passing)", "invoking a <span style="text-decoration: none;">method</span>" or "calling a <span style="text-decoration: none;">member function</span>" to the controlled object.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">For a given association between object A and object B, there can be three possible categories .</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><ol start="1" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;" type="1"><li class="MsoNormal"><b><span style="font-size: small;"><b style="color: #45818e;">One to One</b>. Exactly one instance of Class A is associated with exactly one instance of Class B and vice versa. Example: A department has exactly one Head and One Head can lead only one department .</span></b></li>
<li class="MsoNormal"><b><span style="font-size: small;"><b style="color: #45818e;">One to Many</b> : One instance of Class A can have many instance of Class B. From perspective of Class B, there can be only one Class A Example : A department employees many Professors, but a professor works only for one department </span></b></li>
<li class="MsoNormal"><b><span style="font-size: small;"><b style="color: #45818e;">Many to Many</b> : For a given instance of Class A there can be many instance of Class B and From Class B perspective there can be many instances of Class A. Example : A student enrolls in many courses and a course has many students .</span></b></li>
</ol><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">An aggregation is a specific type of composition where no ownership between the complex object and the subobjects is implied. When an aggregate is destroyed, the subobjects are not destroyed.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> <span style="color: #45818e;"> For example, consider the math department of a school, which is made up of one or more teachers. Because the department does not own the teachers (they merely work there), the department should be an aggregate. When the department is destroyed, the teachers should still exist independently (they can go get jobs in other departments).</span></span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Because aggregations are just a special type of compositions, they are implemented almost identically, and the difference between them is mostly semantic. In a composition, we typically add classes to the composition using either normal variables or pointers where </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">the allocation and deallocation process is handled by the </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">composition class itself.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><pre style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Let’s take a look at our Teacher and Department example in more detail.</span></b></pre><pre style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">#include <string> </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">using namespace std; </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class Teacher </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{ </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">private: </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> string m_strName; </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">public: </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> Teacher(string strName) </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> : m_strName(strName) </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> { </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> } </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> string GetName() { return m_strName; } </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}; </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class Department </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{ </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">private: </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> Teacher *m_pcTeacher; // This dept holds only one teacher </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">public: </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> Department(Teacher *pcTeacher=NULL) </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> : m_pcTeacher(pcTeacher) </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> { </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> } </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}; </span></b></pre><pre style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">int main() { // Create a teacher outside the scope of the Department Teacher *pTeacher = new Teacher("Bob"); // create a teacher { // Create a department and use the constructor parameter to pass the teacher to it. Department cDept(pTeacher); } // cDept goes out of scope here and is destroyed // pTeacher still exists here because cDept did not destroy it delete pTeacher; }
</span></b></pre><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">In this case, pTeacher is created independently of cDept,and then passed into cDept’s constructor. Note that the department class uses an initialization list to set the value of m_pcTeacher to the pTeacher value we passed in. When cDept is destroyed, the m_pcTeacher pointer destroyed, but pTeacher is not deallocated, so it still exists until </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">it is independently destroyed.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">To summarize the differences between composition and aggregation:</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><span style="color: #674ea7;">Compositions</span>:</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Typically use normal member variables Can use pointer values if the composition class automatically handles allocation/deallocation </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Responsible for creation/destruction of subclasses </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><span style="color: #674ea7;">Aggregations</span>:</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Typically use pointer variables that point to an object that lives outside the scope of the aggregate class.Not responsible for creating/destroying subclasses.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">It is worth noting that the concepts of composition and aggregation can be mixed freely within the same class. It is entirely possible to write a class that is responsible for the creation/destruction of some subclasses but not others. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><span style="color: #45818e;">For example, our Department class could have a name and a teacher. The name would probably be added to the department by composition, and would be created and destroyed with the department.</span> On the other hand, the teacher would be added to the department by aggregate, and created/destroyed independently.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">While aggregates can be extremely useful in some cases, they are also potentially dangerous. As noted several times, aggregates are not responsible for deallocating their subobjects when they are destroyed. Consequently, if there are no other pointers or references to those subobjects when the aggregate is destroyed, those subobjects will cause a memory leak. It is up to the programmer to ensure that this does not happen. This is generally handled by ensuring other pointers or references to those subobjects exist when the aggregate is destroyed.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> <span style="color: #674ea7;">Composition</span> : Defines a strong-coupled relationship between two entities, where the one entity is part of another, and both need each other for their existence. e.g. Human body and the Heart. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"><span style="color: #674ea7;">Aggregation </span>: Defines a weak-coupled relationship between two entities, where one entity could be part of another, but either can exist without the other, independantly. e.g. Department and employee. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div style="color: #674ea7; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Coupling and Cohesion</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"><u style="color: #674ea7;">Coupling</u>:</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> Coupling is the <span style="color: #a64d79;">degree</span> to which one class knows about another class. If the only knowledge that class A has about class B, is what class B has exposed through its interface, then class A and class B are said to be loosely coupled... That is a good thing. If on the other hand, class A relies on parts of class B that are not part of class B's interface, then the coupling between the classes is tighter... not a good thing. In other words, if A knows more than it should about the way in which B was implemented, then A and B are tightly coupled.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">If class A knows non-API stuff about class B, and class B knows non-API stuff about class A... this is Really Bad. If either class is ever changed, there's a chance that the other class will break.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> Following is the example of tight coupling, which has been enabled by <i style="color: #45818e;"><u>poor encapsulation</u></i>.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Trebuchet MS",sans-serif;"><br />
</div><div style="color: #a64d79; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class DoTaxes</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> float rate;</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> float doColorado()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> SalesTaxRates str=new SalesTaxRates();</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> rate=str.salesRate; // bad</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> // instead of this , there should be a method call.</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class SalesTaxRates</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> public float salesRate;//should be prv</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> public float adjustedSalesRate;</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> public float getSalesRate(String region)</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> salesRate=new DoTaxes().doColorado();</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> return adjustedSalesRate;</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #674ea7; font-family: "Trebuchet MS",sans-serif;"><u><b><span style="font-size: small;">Cohesion</span></b></u></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> While coupling has to do with how classes interact with each other, cohesion is all about how a single class is designed. The term <i>"cohesion" is used to indicate the degree to which a class has a single, well-focused purpose</i>. Cohesion is a subjective concept. The more focused a class is, the higher its cohesiveness - a good thing. The key benefit of high cohesion is that such classes are typically much easier to maintain (and less frequently changed) than classes with low cohesion. Another benefit of high cohesion is that classes with a well-focused purpose tend to be more reusable than other classes. </span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">e.g.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class BudgetReport</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> void connectToRdbms()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> void generateBudgetReport()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> void saveToFile()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> void print()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Now imagine your manager comes along and says, "Do u know that accounting application we're working on? The clients just decided that they're also going to want to generate a revenue projection report, and they want to do some inventory report also. They do like our reporting features, however, so make sure that all of these reports will let them choose a database, choose a printer and save generated reports to data files.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">Rather than putting all the printing code into one report class, we probably would have been better off with the following design right from the start:</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif; margin-left: 1in; text-indent: 0.5in;"><br />
</div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class BudgetReport</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> Options getReportingOptions()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> void generateBudgetReport(Options o)</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><br />
</div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class ConnectToRDBMS</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> DBconnection getRDBMS()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">} </span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><br />
</div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class PrintStuff</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> PrintOptions getPrintOptions()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><br />
</div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">class FileSaver</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">{</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> SaveOptions getFileSaveOptions()</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> {</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> }</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;">}</span></b></div><div style="color: #a64d79; font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"> </span></b></div><div class="MsoNormal" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif; margin-left: 1in; text-indent: 0.5in;"><br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><div class="MsoNoSpacing" style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;">This design is much more cohesive. Instead of one class that does everything, we've broken the system into four main classes, each with a very specific, or cohesive, role. Because we've built these specialized, reusable classes, it'll be much easier to write a new report, since we've already got the database connection class, the printing class, and the file saver class, and that means they can be reused by other classes that might want to print a report.</span></b></div><div style="font-family: "Trebuchet MS",sans-serif;"><b style="color: #3d85c6;"><span style="font-size: small;"> </span></b></div><pre style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b><span style="font-size: small;"> </span></b></pre></div>Sherna Jayhttp://www.blogger.com/profile/07834400267247395337noreply@blogger.com0tag:blogger.com,1999:blog-6466304901617915620.post-37768050548432918332011-04-30T05:53:00.000-07:002011-04-30T05:53:05.376-07:00HTML..first step<div dir="ltr" style="text-align: left;" trbidi="on"><div style="color: purple; font-family: "Trebuchet MS",sans-serif;"><br />
<b>A basic introduction to HTML:</b><br />
<br />
</div> <b style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><span style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;">HTML was derived from SGML i.e.<span style="color: #8e7cc3;"> </span></span><span style="color: #c27ba0;">Standard General Markup Language</span>.</b><br />
<div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b> Its is pretty pretty easy to learn and use it as well. You just require a normal notepad</b>(or editplus in case yu a geek)<b> and any </b>(mind yu any!!!)<b> internet browser.HTML is so flexible that, using just this one language, your web page is executable from any browser.</b><br />
</div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b> HTML is nothing but </b><b><span style="color: #c27ba0;">Hyper Text Markup Language</span>, as in its a language which uses <i style="color: #c27ba0;">Hyper text Transfer Protocol</i> to transfer the contents of your HTML web page on the internet. </b><br />
</div><div style="color: #3d85c6; font-family: "Trebuchet MS",sans-serif;"><b> It uses simple tags to describe to content of your web page. These tags are enclosed within a </b><b>"<span style="color: #a64d79;"><</span>" and a </b><b>"<span style="color: #a64d79;">></span>" . Every <span style="color: #c27ba0;">OPENING</span> tag has a corresponding <span style="color: #c27ba0;">CLOSING</span> tag. Certain tags have properties aka <i>attributes</i> that we use to style the content enclosed in the tags. E.g.: <span style="color: #741b47;"><b></span>,<span style="color: #741b47;"><title>....</title></span>. We shall dig into Tag details a bit later.</b><br />
<br />
<b> Lets see a simple example of an HTML page.Follow these steps humbly and correctly:</b></div><div style="font-family: "Trebuchet MS",sans-serif;"><ol style="color: #3d85c6; text-align: left;"><li style="color: #45818e;"><b>Open a blank notepad.</b></li>
<li><b><span style="color: #45818e;">Copy the following code as it is. You may change the text part enclosed within the tags</span><br />
<html><br />
<head><title> My first HTML page </title></head><br />
<body><br />
Welcome to the world of HTML...Check the topmost bar on your browser window.You shall see the text that you typed between the title tag. Adios<br />
</body><br />
</html></b> </li>
<li><b> <span style="color: #45818e;">Save the file as "First.html" or as "First.htm".</span></b></li>
<li style="color: #45818e;"><b> Open the drive where you have saved the file,notice that a file with a same name and a different icon simliar to your browser. Double click the file(open it the way you do to any file on your system) and whoa, its your own HTML page.</b></li>
</ol><div style="color: #3d85c6;"><b> Cheers to your first page hehe,now lets get into tag details in the next post and style your page. Till the next post,take care..!!! </b></div><ol style="text-align: left;"></ol><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div><div style="font-family: "Trebuchet MS",sans-serif;"><br />
</div></div>Sherna Jayhttp://www.blogger.com/profile/07834400267247395337noreply@blogger.com0