Click here to Skip to main content
15,887,083 members
Home / Discussions / C#
   

C#

 
GeneralRe: Plugable Interface Pin
Dirso30-Jul-08 13:58
Dirso30-Jul-08 13:58 
QuestionLanguage Pin
bfis10813729-Jul-08 10:59
bfis10813729-Jul-08 10:59 
AnswerRe: Language Pin
nelsonpaixao29-Jul-08 12:38
nelsonpaixao29-Jul-08 12:38 
AnswerRe: Language Pin
Christian Graus29-Jul-08 12:38
protectorChristian Graus29-Jul-08 12:38 
AnswerRe: Language Pin
DaveyM6929-Jul-08 12:52
professionalDaveyM6929-Jul-08 12:52 
Questionclickonce register COM problem Pin
steve_rm29-Jul-08 7:54
steve_rm29-Jul-08 7:54 
AnswerRe: clickonce register COM problem Pin
paas29-Jul-08 8:01
paas29-Jul-08 8:01 
QuestionA design decision - how to instantiate and call BLL classes? Pin
Pawel Krakowiak29-Jul-08 6:19
Pawel Krakowiak29-Jul-08 6:19 
We've ran into some minor issues (fortunately nothing that can't be refactored) with a design for DAL and BLL in a project. We have a set of repository and service classes that deal with different domain model entities and so on.

We are looking to have a common (standardized) way of accessing those classes from client code. This is an ASP.NET web application. I was the first one to start the design and I instantiate my services as private static read only fields in each page whenever I need to use a particular service class' functionality, in example:

public partial class NewAsset : System.Web.UI.Page
{
    private static readonly _catalogService = new CatalogService();

    protected void Page_Load(object sender, EventArgs e)
    {
        Asset asset = _catalogService.FetchById(3);
    }
}


The other developer created however a "master" class for the services and exposes them as public properties, so he has something like:

public class Service
{
   private static CatalogService _catalogService;
   
   public static CatalogService Catalog
   {
       get
       {
           _catalogService = _catalogService ?? new CatalogService();
           return _catalogService;
       }
   }
}


Then in a page:

public partial class NewAsset : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Asset asset = Services.Catalog.FetchById(3);
    }
}


My approach will create more objects, although there's always one per page. The second approach would always use a single object instance, but somehow I don't like how he used properties for that. The service classes are not singletons themselves, there's no real factory pattern (unless something like this with properties could be considered as one..), it seems weird but at the same time I can't tell for sure that it's bad. I know where he comes from, as he doesn't have to instantiate the single services in each page...

Do you think that one way is better than the other? If so, then why?
AnswerRe: A design decision - how to instantiate and call BLL classes? Pin
led mike29-Jul-08 6:38
led mike29-Jul-08 6:38 
GeneralRe: A design decision - how to instantiate and call BLL classes? Pin
Pawel Krakowiak29-Jul-08 21:09
Pawel Krakowiak29-Jul-08 21:09 
GeneralRe: A design decision - how to instantiate and call BLL classes? Pin
led mike30-Jul-08 6:03
led mike30-Jul-08 6:03 
GeneralRe: A design decision - how to instantiate and call BLL classes? Pin
Pawel Krakowiak30-Jul-08 6:29
Pawel Krakowiak30-Jul-08 6:29 
GeneralRe: A design decision - how to instantiate and call BLL classes? Pin
led mike30-Jul-08 6:43
led mike30-Jul-08 6:43 
QuestionC# Topmost without focus Pin
Zocrates29-Jul-08 6:00
Zocrates29-Jul-08 6:00 
AnswerRe: C# Topmost without focus Pin
led mike29-Jul-08 7:27
led mike29-Jul-08 7:27 
AnswerRe: C# Topmost without focus Pin
Paul Conrad29-Jul-08 7:45
professionalPaul Conrad29-Jul-08 7:45 
GeneralRe: C# Topmost without focus Pin
Zocrates29-Jul-08 8:03
Zocrates29-Jul-08 8:03 
GeneralRe: C# Topmost without focus Pin
Paul Conrad29-Jul-08 8:11
professionalPaul Conrad29-Jul-08 8:11 
GeneralRe: C# Topmost without focus Pin
Zocrates29-Jul-08 8:18
Zocrates29-Jul-08 8:18 
GeneralRe: C# Topmost without focus Pin
Paul Conrad29-Jul-08 8:22
professionalPaul Conrad29-Jul-08 8:22 
GeneralRe: C# Topmost without focus Pin
led mike29-Jul-08 8:31
led mike29-Jul-08 8:31 
GeneralRe: C# Topmost without focus Pin
Zocrates29-Jul-08 8:54
Zocrates29-Jul-08 8:54 
GeneralRe: C# Topmost without focus Pin
led mike29-Jul-08 9:08
led mike29-Jul-08 9:08 
GeneralRe: C# Topmost without focus Pin
Zocrates29-Jul-08 10:22
Zocrates29-Jul-08 10:22 
GeneralRe: C# Topmost without focus Pin
led mike29-Jul-08 10:34
led mike29-Jul-08 10:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.