Use of design??
-
Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
//Process XML File
}
}class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
//Process CSV File
}
}class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
//Process Excel File
}
}On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
-
Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
//Process XML File
}
}class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
//Process CSV File
}
}class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
//Process Excel File
}
}On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
I think that would be the, "I don't know the Abstract Factory Pattern Pattern".
-
I think that would be the, "I don't know the Abstract Factory Pattern Pattern".
hi Thanks for the update... do not misunderstand my intention.. i am not asking about design patterns, but what is the exact use of this kind of design?
My small attempt...
-
hi Thanks for the update... do not misunderstand my intention.. i am not asking about design patterns, but what is the exact use of this kind of design?
My small attempt...
You might as well read up on that pattern while you wait for more responses.
-
Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
//Process XML File
}
}class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
//Process CSV File
}
}class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
//Process Excel File
}
}On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
-
Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
//Process XML File
}
}class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
//Process CSV File
}
}class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
//Process Excel File
}
}On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
-
In some manage system, this design pettern can be used. For example, according to the type of the login account to new the object. The normal user, manager.
That's not a design pattern... but it almost is.
-
Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this
My small attempt...
-
Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this
My small attempt...
True, except maybe for 2. You may want to use plug-ins if you want a lot of flexibility.
-
That's not a design pattern... but it almost is.
-
Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
//Process XML File
}
}class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
//Process CSV File
}
}class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
//Process Excel File
}
}On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
The main advantage is that you can treat XML and CSV files in the same way. By processing both types as BaseFileClass, you can use the same code for handling both subclasses. This is a type of code reuse. It also makes the higher-level processing simpler, since it's independent of the details of your derived classes.
-
Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this
My small attempt...
A design should be evaluated based on how well it solves the problem. Without stating the exact problem you are trying to solve you can't know the advantages of one design over another. You also don't give an alternative design. Without an alternative to compare it against it has no advantage or disadvantage. What is the advantage of an orange? If the problem to solve is driving a nail and the alternative is a hammer there is no advantage. If the problem to solve is vitamin C intake and the alterntiave is a multi-vitamin, the advantages are taste and refreshment.