Facade design pattern in java 2013

View previous topic View next topic Go down

Facade design pattern in java 2013

Post by Admin on Sun Sep 15, 2013 4:05 am

2013 2013 2013 <div dir="ltr" style="text-align: left;" trbidi="on">Facade is design pattern in java that helps to re design a poorly structured API into a well defined API. It provides a simpler interface to the client, but internally it interacts with complex components and get a job done for the client. It hides a complexity behind exposing a simpler interface to the client.<br><br> Consider a scenario, of an Employee Hiring consultancy that collects all the information of an employee going to join in some company. The information includes personal details, last employment details, last drawn salay, expected salary, desired location.<br>Now, lets say, there are different complex interfaces, one that returns employee personal information, one give employee past experience details and so on.<br>So, in this case, if a client need a complete list of information of one particular employe, there needs to give a call to lots of other interface.<br><br> Here comes the importance of facade design patterns which creates a facade interface which contains a simplified interface, but internally it makes a call to all other complex interface to get collection of all employee details.<br><br></br><table><tr><td><iframe src = 'http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-137629438443982743&affid=kumarbhati' frameborder = 0, height=250, width = 300 > </iframe></td><td><iframe src="http://origin-img.shaadi.com/shaadi-rewards/get-banner.php?ptnr=kg9vc&banner_type=rectangles&banner_size=250x250&ad_type=iframe" width="250" height="250" scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe></td></tr></table> </br><b>Employee.java</b> - POJO for basic properties of employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class Employee {<br /><br /> // Personal details<br /> private int id;<br /><br /> private String name;<br /><br /> private String address;<br /><br /> private String fatherName;<br /><br /> private String maritalStatus;<br /><br /> private String motherName;<br /><br /> // Employment details<br /> private double yearsOfExperience;<br /><br /> private double lastDrawnSalary;<br /><br /> private String lastCompanyName;<br /><br /> private boolean bgvDone; // Background verification done during hiring<br /><br /> public int getId() {<br /> return id;<br /> }<br /><br /> public void setId(int id) {<br /> this.id = id;<br /> }<br /><br /> public String getName() {<br /> return name;<br /> }<br /><br /> public void setName(String name) {<br /> this.name = name;<br /> }<br /><br /> public String getAddress() {<br /> return address;<br /> }<br /><br /> public void setAddress(String address) {<br /> this.address = address;<br /> }<br /><br /> public String getFatherName() {<br /> return fatherName;<br /> }<br /><br /> public void setFatherName(String fatherName) {<br /> this.fatherName = fatherName;<br /> }<br /><br /> public String getMaritalStatus() {<br /> return maritalStatus;<br /> }<br /><br /> public void setMaritalStatus(String maritalStatus) {<br /> this.maritalStatus = maritalStatus;<br /> }<br /><br /> public String getMotherName() {<br /> return motherName;<br /> }<br /><br /> public void setMotherName(String motherName) {<br /> this.motherName = motherName;<br /> }<br /><br /> public boolean isBgvDone() {<br /> return bgvDone;<br /> }<br /><br /> public void setBgvDone(boolean bgvDone) {<br /> this.bgvDone = bgvDone;<br /> }<br /><br /> public double getYearsOfExperience() {<br /> return yearsOfExperience;<br /> }<br /><br /> public void setYearsOfExperience(double yearsOfExperience) {<br /> this.yearsOfExperience = yearsOfExperience;<br /> }<br /><br /> public double getLastDrawnSalary() {<br /> return lastDrawnSalary;<br /> }<br /><br /> public void setLastDrawnSalary(double lastDrawnSalary) {<br /> this.lastDrawnSalary = lastDrawnSalary;<br /> }<br /><br /> public String getLastCompanyName() {<br /> return lastCompanyName;<br /> }<br /><br /> public void setLastCompanyName(String lastCompanyName) {<br /> this.lastCompanyName = lastCompanyName;<br /> }<br /><br /> public String toString() {<br /> StringBuffer stringBuffer = new StringBuffer();<br /> stringBuffer.append("Employee Personal Details : \n\n");<br /> stringBuffer.append("Employee Id : " + this.getId());<br /> stringBuffer.append("\nEmployee Name : " + this.getName());<br /> stringBuffer.append("\nEmployee Address : " + this.getAddress());<br /> stringBuffer.append("\nEmployee Father Name : " + this.getFatherName());<br /> stringBuffer.append("\nEmployee Mother Name : " + this.getMotherName());<br /> stringBuffer.append("\nEmployee Marital Status : " + this.getMaritalStatus());<br /><br /> stringBuffer.append("\n\nEmployee Experience Details : \n\n");<br /> stringBuffer.append("\nEmployee Years of experience : " + this.getYearsOfExperience());<br /> stringBuffer.append("\nEmployee Last drawn salary : " + this.getLastDrawnSalary());<br /> stringBuffer.append("\nEmployee last company name : " + this.getLastCompanyName());<br /> if (this.isBgvDone())<br /> stringBuffer.append("\nEmployee Background verification done : Yes");<br /> else<br /> stringBuffer.append("\nEmployee Background verification done : No");<br /> return stringBuffer.toString();<br /> }<br /><br />}<br /><br /></pre> <b>EmployeeExperience.java</b> - Java class fetch the experience details of an employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeeExperience {<br /><br /> public void getExperieceDetails(Employee employee) {<br /> <br /> // Get the employee ID from employee object and perform DB operation to get past<br /> // experience details from DB table<br /> <br /> employee.setYearsOfExperience(5.2);<br /> employee.setLastDrawnSalary(45000);<br /> employee.setLastCompanyName("Cognizant");<br /> employee.setBgvDone(true);<br /> }<br />}</code><br /></pre> <b>EmployeePersonalDetails.java</b> - Java class fetch the personal details of an employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeePersonalDetails {<br /><br /> public void getPersonalDetails(Employee employee) {<br /> <br /> // Get the employee ID from employee object and perform DB operation to get personal<br /> // details from DB table<br /> <br /> employee.setName("Manish");<br /> employee.setAddress("Mumbai");<br /> employee.setFatherName("Sanjay");<br /> employee.setMaritalStatus("Married");<br /> employee.setMotherName("Asha");<br /> employee.setName("Kumar");<br /> }<br />}</code><br /></pre> <b>EmployeeFacade.java</b> - Facade class that will be exposed to client. Internally it performs complex operations <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeeFacade {<br /><br /> public void getEmployeeDetails(Employee employee) {<br /> new EmployeePersonalDetails().getPersonalDetails(employee);<br /> new EmployeeExperience().getExperieceDetails(employee);<br /> }<br />}<br /></code><br /></pre> <b>FacadeMain.java</b> - Java class to test the facade implementation <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class FacadeMain {<br /><br /> public static void main(String args[]) {<br /> EmployeeFacade employeeFacade = new EmployeeFacade();<br /> Employee employee = new Employee();<br /> employee.setId(128);<br /> employeeFacade.getEmployeeDetails(employee);<br /> System.out.println(employee.toString());<br /> }<br />}</code><br /></pre> <br /><table border="0" id="amazon_body_ads_com" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B00DVFLJDS" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=B0075SUHWG&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=B006P88VSE&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=0316206849&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table> <table border="0" id="amazon_body_ads_in" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=8173666024&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=0006479901&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=1847370292&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=9350042096&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table> <table border="0" id="amazon_body_ads_uk" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B000C1ZDTU" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007VBGTX8" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B009SJCW3C" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B009VK73FA" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td></tr></tbody></table> <table border="0" id="amazon_body_ads_ca" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007HCCOD0" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007FXPWCQ" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007XZM6VG" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B00834SJS0" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table></br> <script>//<![CDATA[ var tokens = document.domain.split('.'); var domain = tokens[tokens.length - 2]; if(tokens[tokens.length - 1]=="uk") { document.getElementById("amazon_body_ads_uk").style.display=""; } else if(tokens[tokens.length - 1]=="com") { document.getElementById("amazon_body_ads_com").style.display=""; } else if(tokens[tokens.length - 1]=="in") { document.getElementById("amazon_body_ads_in").style.display=""; } else if(tokens[tokens.length - 1]=="ca") { document.getElementById("amazon_body_ads_ca").style.display=""; } else{ document.getElementById("amazon_body_ads_com").style.display=""; } //]]></script></div><br> 2013 2013 2013 <br><div dir="ltr" style="text-align: left;" trbidi="on">Facade is design pattern in java that helps to re design a poorly structured API into a well defined API. It provides a simpler interface to the client, but internally it interacts with complex components and get a job done for the client. It hides a complexity behind exposing a simpler interface to the client.<br><br> Consider a scenario, of an Employee Hiring consultancy that collects all the information of an employee going to join in some company. The information includes personal details, last employment details, last drawn salay, expected salary, desired location.<br>Now, lets say, there are different complex interfaces, one that returns employee personal information, one give employee past experience details and so on.<br>So, in this case, if a client need a complete list of information of one particular employe, there needs to give a call to lots of other interface.<br><br> Here comes the importance of facade design patterns which creates a facade interface which contains a simplified interface, but internally it makes a call to all other complex interface to get collection of all employee details.<br><br></br><table><tr><td><iframe src = 'http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-137629438443982743&affid=kumarbhati' frameborder = 0, height=250, width = 300 > </iframe></td><td><iframe src="http://origin-img.shaadi.com/shaadi-rewards/get-banner.php?ptnr=kg9vc&banner_type=rectangles&banner_size=250x250&ad_type=iframe" width="250" height="250" scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe></td></tr></table> </br><b>Employee.java</b> - POJO for basic properties of employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class Employee {<br /><br /> // Personal details<br /> private int id;<br /><br /> private String name;<br /><br /> private String address;<br /><br /> private String fatherName;<br /><br /> private String maritalStatus;<br /><br /> private String motherName;<br /><br /> // Employment details<br /> private double yearsOfExperience;<br /><br /> private double lastDrawnSalary;<br /><br /> private String lastCompanyName;<br /><br /> private boolean bgvDone; // Background verification done during hiring<br /><br /> public int getId() {<br /> return id;<br /> }<br /><br /> public void setId(int id) {<br /> this.id = id;<br /> }<br /><br /> public String getName() {<br /> return name;<br /> }<br /><br /> public void setName(String name) {<br /> this.name = name;<br /> }<br /><br /> public String getAddress() {<br /> return address;<br /> }<br /><br /> public void setAddress(String address) {<br /> this.address = address;<br /> }<br /><br /> public String getFatherName() {<br /> return fatherName;<br /> }<br /><br /> public void setFatherName(String fatherName) {<br /> this.fatherName = fatherName;<br /> }<br /><br /> public String getMaritalStatus() {<br /> return maritalStatus;<br /> }<br /><br /> public void setMaritalStatus(String maritalStatus) {<br /> this.maritalStatus = maritalStatus;<br /> }<br /><br /> public String getMotherName() {<br /> return motherName;<br /> }<br /><br /> public void setMotherName(String motherName) {<br /> this.motherName = motherName;<br /> }<br /><br /> public boolean isBgvDone() {<br /> return bgvDone;<br /> }<br /><br /> public void setBgvDone(boolean bgvDone) {<br /> this.bgvDone = bgvDone;<br /> }<br /><br /> public double getYearsOfExperience() {<br /> return yearsOfExperience;<br /> }<br /><br /> public void setYearsOfExperience(double yearsOfExperience) {<br /> this.yearsOfExperience = yearsOfExperience;<br /> }<br /><br /> public double getLastDrawnSalary() {<br /> return lastDrawnSalary;<br /> }<br /><br /> public void setLastDrawnSalary(double lastDrawnSalary) {<br /> this.lastDrawnSalary = lastDrawnSalary;<br /> }<br /><br /> public String getLastCompanyName() {<br /> return lastCompanyName;<br /> }<br /><br /> public void setLastCompanyName(String lastCompanyName) {<br /> this.lastCompanyName = lastCompanyName;<br /> }<br /><br /> public String toString() {<br /> StringBuffer stringBuffer = new StringBuffer();<br /> stringBuffer.append("Employee Personal Details : \n\n");<br /> stringBuffer.append("Employee Id : " + this.getId());<br /> stringBuffer.append("\nEmployee Name : " + this.getName());<br /> stringBuffer.append("\nEmployee Address : " + this.getAddress());<br /> stringBuffer.append("\nEmployee Father Name : " + this.getFatherName());<br /> stringBuffer.append("\nEmployee Mother Name : " + this.getMotherName());<br /> stringBuffer.append("\nEmployee Marital Status : " + this.getMaritalStatus());<br /><br /> stringBuffer.append("\n\nEmployee Experience Details : \n\n");<br /> stringBuffer.append("\nEmployee Years of experience : " + this.getYearsOfExperience());<br /> stringBuffer.append("\nEmployee Last drawn salary : " + this.getLastDrawnSalary());<br /> stringBuffer.append("\nEmployee last company name : " + this.getLastCompanyName());<br /> if (this.isBgvDone())<br /> stringBuffer.append("\nEmployee Background verification done : Yes");<br /> else<br /> stringBuffer.append("\nEmployee Background verification done : No");<br /> return stringBuffer.toString();<br /> }<br /><br />}<br /><br /></pre> <b>EmployeeExperience.java</b> - Java class fetch the experience details of an employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeeExperience {<br /><br /> public void getExperieceDetails(Employee employee) {<br /> <br /> // Get the employee ID from employee object and perform DB operation to get past<br /> // experience details from DB table<br /> <br /> employee.setYearsOfExperience(5.2);<br /> employee.setLastDrawnSalary(45000);<br /> employee.setLastCompanyName("Cognizant");<br /> employee.setBgvDone(true);<br /> }<br />}</code><br /></pre> <b>EmployeePersonalDetails.java</b> - Java class fetch the personal details of an employee <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeePersonalDetails {<br /><br /> public void getPersonalDetails(Employee employee) {<br /> <br /> // Get the employee ID from employee object and perform DB operation to get personal<br /> // details from DB table<br /> <br /> employee.setName("Manish");<br /> employee.setAddress("Mumbai");<br /> employee.setFatherName("Sanjay");<br /> employee.setMaritalStatus("Married");<br /> employee.setMotherName("Asha");<br /> employee.setName("Kumar");<br /> }<br />}</code><br /></pre> <b>EmployeeFacade.java</b> - Facade class that will be exposed to client. Internally it performs complex operations <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class EmployeeFacade {<br /><br /> public void getEmployeeDetails(Employee employee) {<br /> new EmployeePersonalDetails().getPersonalDetails(employee);<br /> new EmployeeExperience().getExperieceDetails(employee);<br /> }<br />}<br /></code><br /></pre> <b>FacadeMain.java</b> - Java class to test the facade implementation <pre style="font-family:arial;font-size:12px;border:1px solid #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"><br />package com.designpatterns.facade;<br /><br />public class FacadeMain {<br /><br /> public static void main(String args[]) {<br /> EmployeeFacade employeeFacade = new EmployeeFacade();<br /> Employee employee = new Employee();<br /> employee.setId(128);<br /> employeeFacade.getEmployeeDetails(employee);<br /> System.out.println(employee.toString());<br /> }<br />}</code><br /></pre> <br /><table border="0" id="amazon_body_ads_com" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl-20&o=1&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B00DVFLJDS" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=B0075SUHWG&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=B006P88VSE&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?t=javacodeimpl-20&o=1&p=8&l=as1&asins=0316206849&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table> <table border="0" id="amazon_body_ads_in" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=8173666024&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=0006479901&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=1847370292&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://ws-in.amazon-adsystem.com/widgets/q?t=javacodeimpl-21&o=31&p=8&l=as1&asins=9350042096&ref=tf_til&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr&MarketPlace=IN&ServiceVersion=20070822&WS=1&ID=8042_ProductLink&Operation=GetProductLink&" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table> <table border="0" id="amazon_body_ads_uk" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B000C1ZDTU" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007VBGTX8" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B009SJCW3C" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-eu.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-21&o=2&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B009VK73FA" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td></tr></tbody></table> <table border="0" id="amazon_body_ads_ca" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 384px; display:none;"><tbody><tr height="20" style="height: 15.0pt;"> <td height="20" style="height: 15.0pt; width: 72pt;" width="96"><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007HCCOD0" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007FXPWCQ" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B007XZM6VG" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td><td>&nbsp;&nbsp;</td><td><iframe src="http://rcm-na.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=javacodeimpl00-20&o=15&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=B00834SJS0" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td> </tr></tbody></table></br> <script>//<![CDATA[ var tokens = document.domain.split('.'); var domain = tokens[tokens.length - 2]; if(tokens[tokens.length - 1]=="uk") { document.getElementById("amazon_body_ads_uk").style.display=""; } else if(tokens[tokens.length - 1]=="com") { document.getElementById("amazon_body_ads_com").style.display=""; } else if(tokens[tokens.length - 1]=="in") { document.getElementById("amazon_body_ads_in").style.display=""; } else if(tokens[tokens.length - 1]=="ca") { document.getElementById("amazon_body_ads_ca").style.display=""; } else{ document.getElementById("amazon_body_ads_com").style.display=""; } //]]></script></div><br>2013 2013 2013 <br> <a href="http://www.matrixar.com/" title="Matrix ">المصفوفة : أجمل الخلفيات والصور</a>

Admin
Admin

Posts : 64122
Join date : 2013-02-22

View user profile http://prowebsites1.forumaroc.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum