| Facade Pattern |
Article Index for Facade |
Website Links For Facade |
Information AboutFacade Pattern |
The facade is an Object-oriented Design Pattern . Facades are very common in Object-oriented Design . For example, the Java standard library contains dozens of classes for parsing font files and rendering text into geometric outlines and ultimately into pixels. However, most Java programmers are unaware of these details, because the library also contains facade classes ( Font and Graphics) that offer simple methods for the most common font-related operations.EXAMPLES Java The output of the following example which hides parts of a complicate calendar API behind a more userfriendly facade is: ''Date: 1980-08-20'' ''20 days after: 1980-09-09''
class UserfriendlyDate { GregorianCalendar gcal; public UserfriendlyDate(String isodate_ymd) { String {Link without Title} a = isodate_ymd.split("-"); gcal = new GregorianCalendar(Integer.valueOf(a {Link without Title} ),
} public void addDays(int days) { gcal.add(Calendar.DAY_OF_MONTH, days); } public String toString() { return new Formatter().format("%1-%1-%1", gcal); } }
class FacadePattern { public static void main(String {Link without Title} args) { UserfriendlyDate d = new UserfriendlyDate("1980-08-20"); System.out.println("Date: "+d); d.addDays(20); System.out.println("20 days after: "+d); } } EXTERNAL LINKS
|
|
|