The wages of sin: Re-creating the Stored Procedure API in C#
Join the DZone community and get the full member experience.
Join For Freethis time, this is a review of the sharp commerce application. again, i have stumbled upon the application by pure chance, and i have very little notion about who wrote it. the problem is that this system seems to be drastically more complicated than it should be.
in this case, i want to look at the type of api that is exposed:
if this reminds you of the bad old days of having only stored procedure api available, that is not by chance. far worst than that, however, is the call paths where this is used.
iemailtemplaterepository.get(emailtemplatelookup) is implemented aspublic emailtemplate get(emailtemplatelookup emailid)
{
return get((int)emailid);
}
and is only used in:
-
emailservice.get(emailtemplatelookup)
whose implementation is:
public emailtemplate getemail(emailtemplatelookup template)
{
return emailtemplaterepository.get(template);
}
icategoryrepository.getparentcategories
is only used from:
-
categoryservice.getparentcategories
which is implemented as:
public ienumerable<category> getparentcategories()
{
ienumerable<category> categories = categoryrepository.getparentcategories();
return categories;
}
icurrencyrepository.getenabledcurrencies
is only used from:
-
currencyservice.getenabledcurrencies
which is implemented as:
public ienumerable<currency> getenabledcurrencies()
for that matter, let us take a look at the entire currencyservice class, shall we?
{
return currencyrepository.getenabledcurrencies();
}
public class categoryservice : icategoryservice
{
private readonly icategoryrepository categoryrepository;
public categoryservice(icategoryrepository categoryrepository)
{
this.categoryrepository = categoryrepository;
}
public ilist<category> getcategories()
{
return categoryrepository.getall();
}
public category getcategory(int id)
{
return categoryrepository.get(id);
}
public void saveorupdate(category categorymodel)
{
categoryrepository.saveorupdate(categorymodel);
}
public void delete(category category)
{
categoryrepository.delete(category);
}
public ienumerable<category> getparentcategories()
{
ienumerable<category> categories = categoryrepository.getparentcategories();
return categories;
}
}
to be honest, i really don’t see the point .
now, just a hint on the next few posts, there are places where i think wrapping the usage of the nhibernate api was a good idea, even if i strongly disagree with how this was done.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Which Is Better for IoT: Azure RTOS or FreeRTOS?
-
What ChatGPT Needs Is Context
-
Replacing Apache Hive, Elasticsearch, and PostgreSQL With Apache Doris
-
Never Use Credentials in a CI/CD Pipeline Again
Comments