Great JOKES: JAVA OO design
3 posters
Page 1 of 1
Great JOKES: JAVA OO design
class java{
public static void main(String[] args){
System.out.println("We all now very much familiar about Java Object oriented Design which is invented by the intelligent monkeys working at Sun Microsystems.");
}
}
by the way.. Java may seem to you a kind of joke while you are doing simple program with OOD. Okay now lets see a example;
Now Im going write a program with java as well as object oriented Design which will print a single line;
that is "Hell world";
and here is method name toString who is responsible for returning the Helloworld for the specified language;
Now lets write a another class named HelloWorldContstructor whose works is to consctruct Hello world;
Now we'll write our main class. I named it HelloWorldMain;
Here is main method. now If we run this program and wirte arabic in command Line.. it will print مرحبا العالم ;
Nice Jokes... to write simple Hello world we need 55 line code in object oriented desingn... ;
where we can write simple Hello World program in C with simple 4 line coding .. lets see some other Hello World program with various programming language;
Okay now We will see the loose coupling of java I mean object oriented design;
I know we everybody are very much familer on this because we already know the
spring framework ..;
Loose couping is a designing issue. Couping issuse comes when an object is dependent on others;
When an obeject cant work without another, we will say that they are tightly coupled;
But when two object can work independently, we will refer them loose coupled. More precisely, for say, A object is dependent on B. But somehow B become changed., so We need to change the A. But if the system is loose coupled then there is no need to change A. It will continue to work without modification.
Now see the example -
and if you run it, output remain same as before and that is "Hello World";
if you need source code CLICK HERE
For more about it, I suggest you to google it. Im very much sure you'll enjoy tons of information about OOD of java..
Cheers
public static void main(String[] args){
System.out.println("We all now very much familiar about Java Object oriented Design which is invented by the intelligent monkeys working at Sun Microsystems.");
}
}
by the way.. Java may seem to you a kind of joke while you are doing simple program with OOD. Okay now lets see a example;
Now Im going write a program with java as well as object oriented Design which will print a single line;
that is "Hell world";
- Code:
package com.rokon;
public class HelloWorld1 {
private String countryLang;
private String[] hellowWorldArray = { "Hello World", "¡Hola, mundo",
"Bonjour tout le monde", "مرحبا العالم", "नमस्ते दुनिया",
"أهéل َلٍ êüَىï" };
private String[] language = { "English", "Spanish", "French", "Arabic",
"Hindi", "Greek" };
public HelloWorld1(String countryLang) {
this.countryLang = countryLang;
}
public String toString() {
if (countryLang.equalsIgnoreCase(language[0]))
return hellowWorldArray[0];
else if (countryLang.equalsIgnoreCase(language[1]))
return hellowWorldArray[1];
else if (countryLang.equalsIgnoreCase(language[2]))
return hellowWorldArray[2];
else if (countryLang.equalsIgnoreCase(language[3]))
return hellowWorldArray[3];
else if (countryLang.equalsIgnoreCase(language[4]))
return hellowWorldArray[4];
else if (countryLang.equalsIgnoreCase(language[5]))
return hellowWorldArray[5];
else
return "nothing found";
}
}
and here is method name toString who is responsible for returning the Helloworld for the specified language;
Now lets write a another class named HelloWorldContstructor whose works is to consctruct Hello world;
- Code:
package com.rokon;
public class HelloWorldContstructor {
private HelloWorld1 theHeloWorld;
public HelloWorldContstructor(String conLen) {
theHeloWorld = new HelloWorld1(conLen);
}
public String toString() {
return theHeloWorld.toString();
}
}
Now we'll write our main class. I named it HelloWorldMain;
- Code:
package com.rokon;
public class HelloWorldMain {
public static void main(String[] args) {
try {
HelloWorldContstructor tHWC = new HelloWorldContstructor(args[0]);
} catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}
Here is main method. now If we run this program and wirte arabic in command Line.. it will print مرحبا العالم ;
Nice Jokes... to write simple Hello world we need 55 line code in object oriented desingn... ;
where we can write simple Hello World program in C with simple 4 line coding .. lets see some other Hello World program with various programming language;
In C
#include
int main(void) {
puts("Hello, World!");
}
In C++
#include
int main(void) {
std::cout << "Hello, World!\n";
}
In python and perl
print "Hello, World!"
In ruby
puts "Hello, World!"
Okay now We will see the loose coupling of java I mean object oriented design;
I know we everybody are very much familer on this because we already know the
spring framework ..;
Loose couping is a designing issue. Couping issuse comes when an object is dependent on others;
When an obeject cant work without another, we will say that they are tightly coupled;
But when two object can work independently, we will refer them loose coupled. More precisely, for say, A object is dependent on B. But somehow B become changed., so We need to change the A. But if the system is loose coupled then there is no need to change A. It will continue to work without modification.
Now see the example -
- Code:
package com.rokon.loosecoupling;
public class Message {
private String message;
Message(String message) {
this.message = message;
}
public void pirnt(Printer printer) {
printer.print(this);
}
public String toString() {
return message;
}
}
- Code:
package com.rokon.loosecoupling;
public interface Printer {
void print(Message message);
}
- Code:
package com.rokon.loosecoupling;
public abstract class AbstractPrinterFactory {
public static AbstractPrinterFactory getFactory() {
return new SystemOutPrinterFactory();
}
public abstract Printer getPrinter();
}
- Code:
package com.rokon.loosecoupling;
public class SystemOutPrinterFactory extends AbstractPrinterFactory {
public Printer getPrinter() {
return new SystemOutPrinter();
}
}
- Code:
package com.rokon.loosecoupling;
public class HelloWorld {
public static void main(String[] args) {
Message message = new Message("Hello World");
AbstractPrinterFactory factory = SystemOutPrinterFactory.getFactory();
Printer printer = factory.getPrinter();
message.pirnt(printer);
}
}
and if you run it, output remain same as before and that is "Hello World";
if you need source code CLICK HERE
For more about it, I suggest you to google it. Im very much sure you'll enjoy tons of information about OOD of java..
Cheers
Last edited by bit0112-rokon on Sun Apr 04, 2010 2:44 pm; edited 4 times in total (Reason for editing : TLD used)
Similar topics
» Design Pasttern - Strategy Pattern Implemented in Java
» Java Tutorial: Using Two Java Reference Keywords, this and super
» Jokes
» Jokes and Fun
» দে লাথি!! (jokes)
» Java Tutorial: Using Two Java Reference Keywords, this and super
» Jokes
» Jokes and Fun
» দে লাথি!! (jokes)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford