CSC/ECE 517 Fall 2012/ch2b 2w39 ka: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 43: Line 43:


==Proxy Pattern==
==Proxy Pattern==
brief overview
Sometimes we need the ability to control the access to an [http://en.wikipedia.org/wiki/Object_(computer_science) object]. For example if we need to use only a few methods of some costly objects we'll [http://www.geom.uiuc.edu/~daeron/docs/javaguide/java/anatomy/creating.html initialize] those objects when we need them entirely. Until that point we can use some light objects exposing the same interface as the heavy objects. These light objects are called proxies and they will instantiate those heavy objects when they are really need and by then we'll use some light objects instead.
===Intent===
===Intent===
Provide a surrogate or placeholder for another object to control access to it” is the intent provided by GoF<ref>[http://c2.com/cgi/wiki?GangOfFour<i>"Gang of four"</i>]</ref>
Provide a surrogate or placeholder for another object to control access to it” is the intent provided by GoF<ref>[http://c2.com/cgi/wiki?GangOfFour<i>"Gang of four"</i>]</ref>

Revision as of 16:08, 17 November 2012

Introduction

Describe what Design pattern is and what are we going to discuss in this article.

Decorator Pattern

brief overview

Intent

Problem

Solution

Example

Implementation

Ruby

brief explanation and Sample Code:

     type the code here

Java

brief explanation and Sample Code:

     type the code here

Adapter Pattern

brief overview

Intent

Problem

Solution

Example

Implementation

Ruby

brief explanation and Sample Code:

     type the code here

Java

brief explanation and Sample Code:

     type the code here

Proxy Pattern

Sometimes we need the ability to control the access to an object. For example if we need to use only a few methods of some costly objects we'll initialize those objects when we need them entirely. Until that point we can use some light objects exposing the same interface as the heavy objects. These light objects are called proxies and they will instantiate those heavy objects when they are really need and by then we'll use some light objects instead.

Intent

Provide a surrogate or placeholder for another object to control access to it” is the intent provided by GoF<ref>"Gang of four"</ref>

Problem

Solution

Example

Implementation

Ruby

brief explanation and Sample Code:

     type the code here

Java

brief explanation and Sample Code:

     type the code here

Composite Pattern

brief overview

Intent

Problem

Solution

Example

Implementation

Ruby

brief explanation and Sample Code:

     type the code here

Java

brief explanation and Sample Code:

     type the code here

Comparison of the Patterns

Comparison Decorator Adapter Proxy Composite
Supports abc
Supports def
Supports ghi
Supports bla
Supports bla


Conclusion

This article makes an attempt to explain the concept of Reflection in Object Oriented Programming. The article mentions the different approaches to reflection in Ruby and other languages.It mentions the usage of Reflections and the advantages and disadvantages of using Reflection. A follow up to this article would be to study the concept of Metaprogramming.

References

<references />

Additional Reading