Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently I am having an sample application that use to render a photo with and without watermark. I have two versions of the application: One with Decorator applied and the other one is without Decorator (kindly see the code below).

I am struggling at what is the disadvantages in my own implementation. Any explanation would be appreciated.

C#
public interface IRender
{
    void Render();
}
 
public class Photo
{
    IRender iRender;
    public void SetRender(IRender iRenderParam)
    {
        iRender = iRenderParam;
    }
 
    public void RenderPhoto()
    {
        iRender.Render();
    }
}
 
public class NormalRender : IRender
{
    public void Render()
    {
        Console.WriteLine("Normal Render");
    }
}
 
public class WaterMarkRender : IRender
{
    private void RenderWaterMark()
    {
        Console.WriteLine("Render WaterMark");
    }
    public void Render()
    {
        RenderWaterMark();
    }
}
 
public class Program
{
    static void Main(string[] args)
    {
        Photo photo = new Photo();
        photo.SetRender(new NormalRender());
        photo.RenderPhoto();
 
        photo.SetRender(new WaterMarkRender());
        photo.RenderPhoto();
 
        Console.ReadLine();
    }
}


What I have tried:

I have inspected my own implementation and cannot figure it own the differences
Posted
Comments
BillWoodruff 29-Jul-16 23:12pm    
What makes you think there might be "disadvantages" in your code ?
Ehsan Sajjad 31-Jul-16 7:52am    
i think there is nothing wrong in the code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900