Click here to Skip to main content
15,902,032 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
QuestionWhat language is this? Pin
sczii5-May-12 15:15
sczii5-May-12 15:15 
AnswerRe: What language is this? Pin
Deka Prikarna A.6-May-12 0:25
Deka Prikarna A.6-May-12 0:25 
GeneralRe: What language is this? Pin
jschell7-May-12 8:46
jschell7-May-12 8:46 
GeneralRe: What language is this? Pin
Deka Prikarna A.10-May-12 0:36
Deka Prikarna A.10-May-12 0:36 
AnswerRe: What language is this? Pin
Apocalypse Now11-May-12 22:15
Apocalypse Now11-May-12 22:15 
AnswerRe: What language is this? Pin
kishhr22-Jun-12 9:06
kishhr22-Jun-12 9:06 
Questionproject for you Pin
silverbuyer1-May-12 18:43
silverbuyer1-May-12 18:43 
QuestionDilemma on exposing methods in interface based programming Pin
SSEAR22-Apr-12 23:11
SSEAR22-Apr-12 23:11 
Recently I fell in love with dependency injection and interface based programming. Though, as a beginner, I couldn’t grasp all the advantages of this methodology, I greatly influenced in the discipline we can bring into the project to handle the army of objects.

What I learned that by using interface based programming, components are expose their functionalities only though an interface. At first I designed as like below.

C#
namespace Component1
{
    public interface Interface1
    {
        void Func();
    }

    public class Class1 : Interface1
    {
        public void Func() { }
    }

    public static class IOContainer
    {
        public static void Register<TInterface, TConcrete>() { }

        public static TInterface Resolve<TInterface>() { }
    }
}


One drawback I found here that someone can directly create objects of Class1 and use its functions. This will break the essence of interface based programming. So I redesigned it like below.

C#
namespace Component1
{
    public interface Interface1
    {
        void Func();
    }

    internal class Class1 : Interface1
    {
        public void Func() { }
    }

    public static class IOContainer
    {
        internal static void Register<TInterface, TConcrete>() { }

        public static void Register()
        {
            Register<Interface1, Class1>();
        }

        public static TInterface Resolve<TInterface>() { }
    }
}


This will work fine. So no one can access the implementations from outside the assembly. They have to call Register function and Resolve function to create objects. The component will use only in one discipline. But I fell I lost flexibility. Outsider can't determine which class should resolve at run time. Both methods have their own advantages and disadvantages. Kindly help me to choose a suitable method.

Thanks in advance,
Thomas
AnswerRe: Dilemma on exposing methods in interface based programming Pin
VallarasuS24-Apr-12 5:12
VallarasuS24-Apr-12 5:12 
AnswerRe: Dilemma on exposing methods in interface based programming Pin
jschell28-Apr-12 7:52
jschell28-Apr-12 7:52 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
SSEAR29-Apr-12 20:53
SSEAR29-Apr-12 20:53 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
jschell30-Apr-12 8:00
jschell30-Apr-12 8:00 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
SSEAR1-May-12 20:28
SSEAR1-May-12 20:28 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
jschell2-May-12 10:57
jschell2-May-12 10:57 
AnswerRe: Dilemma on exposing methods in interface based programming Pin
BobJanova30-Apr-12 4:06
BobJanova30-Apr-12 4:06 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
SSEAR1-May-12 21:01
SSEAR1-May-12 21:01 
GeneralRe: Dilemma on exposing methods in interface based programming Pin
jschell2-May-12 11:07
jschell2-May-12 11:07 
QuestionWhen we will stop programming?! PinPopular
Hasan Al-Halabi8-Apr-12 0:25
Hasan Al-Halabi8-Apr-12 0:25 
AnswerRe: When we will stop programming?! Pin
Eddy Vluggen8-Apr-12 0:30
professionalEddy Vluggen8-Apr-12 0:30 
GeneralRe: When we will stop programming?! Pin
Hasan Al-Halabi8-Apr-12 1:14
Hasan Al-Halabi8-Apr-12 1:14 
AnswerRe: When we will stop programming?! Pin
Eddy Vluggen8-Apr-12 1:39
professionalEddy Vluggen8-Apr-12 1:39 
QuestionRe: When we will stop programming?! Pin
Hasan Al-Halabi8-Apr-12 3:25
Hasan Al-Halabi8-Apr-12 3:25 
AnswerRe: When we will stop programming?! Pin
Eddy Vluggen8-Apr-12 8:37
professionalEddy Vluggen8-Apr-12 8:37 
AnswerRe: When we will stop programming?! Pin
Hasan Al-Halabi9-Apr-12 11:52
Hasan Al-Halabi9-Apr-12 11:52 
AnswerRe: When we will stop programming?! Pin
Hermaine18-Apr-12 21:24
Hermaine18-Apr-12 21:24 

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.