mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
docs: new diagrams for template view and throttling
This commit is contained in:
@@ -21,18 +21,22 @@ Separate the structure and static parts of a webpage (or view) from its dynamic
|
||||
|
||||
## Detailed Explanation of Template View Pattern with Real-World Examples
|
||||
|
||||
### Real-World Example
|
||||
Real-World Example
|
||||
|
||||
> Think of a blog website where each post page follows the same layout with a header, footer, and main content area. While the header and footer remain consistent, the main content differs for each blog post. The Template View pattern encapsulates the shared layout (header and footer) in a base class while delegating the rendering of the main content to subclasses.
|
||||
|
||||
### In Plain Words
|
||||
In Plain Words
|
||||
|
||||
> The Template View pattern provides a way to define a consistent layout in a base class while letting subclasses implement the specific, dynamic content for different views.
|
||||
|
||||
### Wikipedia Says
|
||||
Wikipedia Says
|
||||
|
||||
> While not a classic Gang of Four pattern, Template View aligns closely with the Template Method pattern, applied specifically to rendering webpages or views. It defines a skeleton for rendering, delegating dynamic parts to subclasses while keeping the structure consistent.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Template View Pattern in Java
|
||||
|
||||
Our example involves rendering different types of views (`HomePageView` and `ContactPageView`) with a common structure consisting of a header, dynamic content, and a footer.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Reference in New Issue
Block a user