Design Patterns Series 20 - Double Buffer, Recycle Bin, and MVC Patterns

In this post we will explore the last three patterns in our design patterns list, Double Buffer Pattern, Recycle Bin Pattern, and Model/View/Controller (MVC) Pattern.

Double Buffer Pattern :

Double Buffering is used to avoid screen flicker when you are displaying graphics. The idea is that you perfrom your multi-step graphics creation off-screen in a buffer and then flash the results on the screen when they're complete. The process is called Double Buffering because the screen display buffer is one buffer and the buffer in which the images are prepared is the second buffer.

Use a Double Buffer when generating revised datasets for an asynchronous processor. When the new data is complete and self consistent, redirect the asynchronous processor to the alternate buffer.

Recycle Bin Pattern :

If your code uses many objects and the object-creation process is time - and resource - intensive, you might want to use the Recycle Bin Pattern. The idea is that when you're done with an object, you toss it into the recycle bin, and when you need an object of the same kind again, you can grab it out of the recycle bin.

You can store freed resources in a local bin so that subsequent requests for these resources can reuse the ones in the bin. A client requests resources through the bin. The bin will reuse an existing one if available or create a new one if necessary. The recycle bin may request more resource than actually needed to optimize performance. When the use of the resource is complete, it should be returned to the bin.

Model/View/Controller (MVC) :

The Model/View/Controller, or MVC, represents a good design insight : separating the code used for presentation from that which works on and handles data.

  • Model : Implements the data crunching of the application. This is the core code that does the application's internal work. The Model does not know anything about the view or the controller - you just pass it data and it goes from there, returning its result.

  • View : Implements the presentation layer that interacts with the user. When the user starts interacting with an online application, the web page(s) they see are part of view. TheView also takes data supplied to it (usually from the controller) and displays it.

  • Controller : Acts as the boss of the application and it is responsible for routing data to the right model and view components. The Controller oversees the model and the view by reacting to the data the user sends.

The MVC Pattern is "A tried of three modules linked by Observer Pattern , all residing within RepresentationLayer. The View drives a presentation within GUILayer, and elements within the View observe the Model. Elements within the Controller observe the View and the Model, and elements within the Model observe the Controller. The Model fronts data objects within the LogicLayer. This pattern decouples changes to how data are manipulated from how they are displayed or stored, while unifying the code in each component."

Now we explored most famous design patterns and in the next and last post in this series we will know how to create our own design pattern.


Popular posts from this blog

Android : How to change progress bar color at runtime programmatically?

ASP.Net MVC : Conditional Validation using ValidationAttribute

How to fire RowCommand event of nested GridView?