Multiple method or different class for a ComboBox loading?
"Foysal" <[email protected]>
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone. I am new in this group. I use layer architecture in my
work. I am in a situation described below:
DAO: Company (Company object: has Id and Name)DAL: CompanyGateway
(Queries are handled in here)BLL: CompanyManager (Business logics are
checked in here)UI: CompanyUI (User Interface)
I have a combo in UI which loads company names into it. Generally, we
write a GetAllCompanies() method in CompanyGateway class. But sometimes
we need to fetch different data for different combo in a project. So, we
need to write different methods for each DAO objects in separate Gateway
classes.
But if i want to create a method ( LoadCombo() )in a separate class (
suppose: ComboLoader.cs) where i will give the table name or other
specific parameters and the method's only responsibility is to return a
data table for loading the combo, how it sounds?
I am giving the code snippet for your better understanding. I am using
C# as the language.
========================================================================\
=========
public DataTable ComboLoader(string tableName) {
string selectQuery = "SELECT * FROM [" + tableName + "]";
SqlDataAdapter adapter=new
SqlDataAdapter(selectQuery,DBConnector.SqlConnectionObj);
DataTable dataTable=new DataTable(); try {
DBConnector.OpenSqlConneciton(); adapter.Fill(dataTable);
} catch (Exception exception) {
throw new Exception("Data could not retrived from database.",exception);
} finally {
DBConnector.CloseSqlConnection(); } return
dataTable; }
========================================================================\
======
I will create different overloading method depending on the conditions
of the query i want to execute.
Thanks in advance.
Sincerely,Foyzul Karim
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/refactoring/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/refactoring/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/