Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can one class set a property to be seen by another c
Message
 
 
À
27/02/2013 13:16:56
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01566989
Message ID:
01567066
Vues:
23
>>>Why is the application class holding database properties? What you're wanting to do is called tight-coupling is not a good idea as it makes one class rely too much on the other.
>>>
>>I see. Do you suggest to not have database a property of the application class but rather main class use both classes independently? I still want to have a reference to either one or 2 classes, so I can pass invoke information around.
>
>I think what you are looking for is something like this:
    public class Application
>    {
>        private DataBase dataBase;
>
>        public Application()
>        {
>            dataBase = new DataBase(this);
>        }
>    }
>
>    public class DataBase
>    {
>        private Application application;
>        public DataBase(Application app)
>        {
>            application = app;
>        }
>    }
But, in general I agree with Craig. For this type of thing you should be using something like Prism or MEF....

What you showed isn't a cyclic reference? Application has database and Database has application?

I need to research on what is Prism or MEF, I am not familiar.

Also, after looking a bit closer into the project I found AppInfo static class (it's from another project which is referenced in this one) and I am wondering if I am doing something which we already have partially implemented.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform