Class design help

  • Thread starter Thread starter SamIAm
  • Start date Start date
S

SamIAm

Hi

I am looking at implementing a Facade architecture in my system. i.e
MyBusinessFacdeSystem and multiple MyBusinessObjects
I want the MyBusinssObject class to only be created by the
MyBusinessFacdeSystem class.
i.e
using System;

namespace FacadeTest.MyFacade
{
/// <summary>
/// Summary description for MyFacadeSystem.
/// </summary>
public class MyFacadeSystem
{
private MyBusinessObject_MyBusinessObject = null;

public MyFacadeSystem()
{
_MyBusinessObject= new MyBusinessObject();
}

public MyBusinessObjects MyBusinessObjectsBLL
{
get
{
return _MyBusinessObjects;
}
}

}
}

How do I set the accessability if the MyBusinessObject class i.e.:
using System;

namespace FacadeTest.MyFacade
{
/// <summary>
/// Summary description for MyBusinessObject .
/// </summary>
internal class MyBusinessObject
{
public MyBusinessObject ()
{
}

public string SomeMethod(){
return "Hello";

}
}
}




Hope that is clear,



S
 
Hi Sam

Everything you had was correct except for the modifier for the constructor
for MyBusinessObject. You need to make the modifier Internal so only your
facade can create it. To really ensure only the facade is creating it then
you could also pass in a parameter to the construtor or test the caller :)

Mark
 
Mark

Thanks for the reply. What should I set the modifier to? I have set it to
internal, is that ok?

Thanks again,

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top