Architecture :: Repository Pattern - Pros And Cons?

Jul 8, 2010

This is possibly the worst kind of religious debate -- a religious debate with practical consequences. But it's one that needs to be had, and I can't seem to fit it in my tiny head. Here are the pros and cons of the pattern as I know them:

Pros:

-Encourages DRY (don't repeat yourself) design in that identical queries are written only once per set of query conditions
-Facilitates unit testing by allowing itself to be abstracted into an interface
-Creates an opportunity for business-level validation

Cons:

-Breaks DRY philosophy in that you're generally repeating your database schema
-In a sense breaks separation of concerns, because the query concerns of the controller and view frequently become the concerns of whoever is maintaining the repository
-Determining what should be a repository and what should be returned as a raw associated ORM entity becomes an ambiguous art

To me it seems like all this stuff should be done at the ORM level, but Entity Framework has much fewer hooks than Linq to Sql does, yet Entity Framework tends to be regarded as being more robust, so it seems that this is by design, and that the designers of EF are in fact encouraging another layer. Are there any tools or anything that I could be using for this? Am I missing something?

View 6 Replies


Similar Messages:

Architecture :: Finding Pros And Cons Of Static Classes And Variables (particularly A Db Connection)

Jan 11, 2010

So I started working on my first asp.net application that involves logging in and databases, and soon after i started messing around with a static class. I "discovered" that if you make a variable static, all sessions share that variable (I for some reason was originally assuming that each session had its own copy of that "static" class). Anyway, after discovering this I thought to myself "how could this possibly be useful to me" and thought that itmight be a good idea to make a single static database connection for all of the sessions, rather than storing that as a session variable for each session. Does anybody know what would be the pros and cons of this approach?

View 5 Replies

Architecture :: Data Validation In Repository Pattern?

Dec 21, 2010

I am currently using the 3-tier Repository pattern in my application. Actually it's the first time for me to implement a design pattern at all! i used to put all my code in the so called now presentation layer.

i want to implement data validation, for example, password should not be more than 10 characters and have to contain special characters. Should i put this code in the data access layer? but my data access layer contains methods that take the DTO as a parameter for example

[Code]....

and the same is for other CRUD operations (DELETE and UPDATE), so implementing such validation on the DAL would make me duplicate the code in each and every method that accepts the DataObject as a paramter. Same holds for the business logic layer where i am using it as a proxy between the presentation and the data access layers.

Eventually it has to use the same Data Objects as parameters. This only leaves me with one option which is to do the validation on the Data Object part. But i think this is not the essence of the respository pattern which states that the Data object class should only be a "container" class with no behavior.

View 1 Replies

Architecture :: Check In "project Dll" - Pros And Cons?

Jun 23, 2010

I've debated a bit with a colleague of mine whether or not to check in the "project dll". I haven't found any resources/information on this at all.For example: I have a project Foo with a reference to some external class library which isn't supported by me (maybe some open source or such).

Naturally, the external class library dll is commited to the versioning system. Although the Foo.dll (which I compile everytime) does not, according to me, belong in the versioning system. This because it can currupt releases since it does not force the user to compile after check out. Other than that, I haven't found any good arguments other than this. But I've never seen anyone checking in the "project dll".According to my colleague, the "project dll" is commited every time a change has required compilation (naturally, when the dll is changed, it's commited).

View 2 Replies

Architecture :: Provider Model Versus Repository Pattern

Feb 4, 2011

I am trying to understand the fundamental differences between the Provider Model and Repository Pattern.

I have used the Provider Model in many many situations and am confident with it when designing applications. However, the more examples I encounter on the internet and asp.net evolution I keep coming across "Repository" Interfaces for classes that look like a Provider Model.

I have dug around a bit but all I can see is that they kinda do the same thing, or closely overlap by enforcing an inheriting class to adhere to a "contract" of implemented / abstracted methods etc...is there more to it?

View 1 Replies

C# - What's The Pros And Cons Using Membership

Nov 23, 2010

I'm building a new website and How to use the asp.net membership for the authentication process (login, registration, password recovery, etc..). I saw that everything is stored in an XML file. I would like to know what are the pros and cons using the membership instead of to build something from scratch.

View 6 Replies

Pros And Cons Of Using This Keyword In C#

Mar 5, 2011

Possible Duplicate: When do you use the “this” keyword? In programming you can use the this keyword this.Textbox or just Textbox What is the best practice? Some benefits I can see is that using this makes it easier to see in intellisense and makes it easier to understand that it is a property. Currently I don't use this... I read in some article somewhere that the guy removed all the references, but I don't remember why.

View 4 Replies

MVC :: Pros And Cons Of MVC Framework

Nov 19, 2010

I am a solutions developer in India. I have been working on traditional ASP.net for some time and have been hearing alot about MVC framework. So, i am writing this Post just to have some reviews from you all that what are the major pros and cons of MVC framework. And in which areas/ cases it is suited the most, i mean business websites or commercial websites or Casual Websites. Just to add i am into developing MES portals for Manufacturing companies. So, would want to know is MVC suitable for the same.

View 11 Replies

C# - Pros And Cons Of Using JSON For WCF Service

May 1, 2010

What are the pros and cons of the following 2 cases: Case I: Traditional way: Add service reference in project. Create object and Get data from service on server side and bind to asp.net grid. Case II: Update Service for JSON behavior. Add service reference in project. Call service from javascript to get data. Bind data to jquery grid. Which one is the best approach and why?(Not developer point of view)

View 2 Replies

C# - Javascript Do Postback And Its Pros And Cons

Sep 29, 2010

the information of do postback details.

View 2 Replies

Pros And Cons Of The Login Controls?

Aug 12, 2010

ASP.NET provides a basic set of Login Controls that integrate with the ASP.NET Membership and Forms Authentication providers. I wouldn't mind being able to skip re-inventing the wheel on this kind of functionality, but I'm wary that there may be security, performance or usability reasons to consider rolling my own.

View 2 Replies

Pattern For Retrieving Complex Object Graphs With Repository Pattern With Entity Framework

Oct 13, 2010

We have an ASP.NET MVC site that uses Entity Framework abstractions with Repository and UnitOfWork patterns. What I'm wondering is how others have implemented navigation of complex object graphs with these patterns. Let me give an example from one of our controllers:

[code]....

It's a registration process and pretty much everything hangs off the POCO class Person. In this case we're caching the person through the registration process. I've now started implementing the latter part of the registration process which requires access to data deeper in the object graph. Specifically DPA data which hangs off Legal inside Country.

The code above is just mapping out the model information into a simpler format for the ViewModel. My question is do you consider this fairly deep navigation of the graph good practice or would you abstract out the retrieval of the objects further down the graph into repositories?

View 2 Replies

C# - Web Service VS Aspx Pages - Pros And Cons

Jan 14, 2011

We develop an ASP.Net web application that is hosted on an internal network. Currently, we have some ASPX pages that handle web requests from the client side and interact with our servers. We are starting development on our next major application version, and we are deciding on the architecture. What are the differences between using ASPX pages to handle http requests as compared to using a full blown Web Service (which would most likely be a WCF Service)? In researching this issue, I have come across a few related posts that have been moderately helpful, seen here and here. My understanding of some of the key differences are as follows:

ASPX pages are limited in the kinds of requests they can receive. They are strictly HTTP whereas a WCF service can have multiple endpoints to service a variety of protocols (HTTP, TCP, etc). WCF Services are more concretely defined due to ServiceContracts. This means that if a project makes a reference to the service, they know exactly what to expect in terms of methods, usage and documentation. An ASPX page is more of a free for all in terms of methods contained and requests accepted. However, based on these concepts, my issues are as follows:

The ability to support different protocols is a great feature in terms of future proofing and compatibility, but what real benefit are we seeing if we are currently only using it to interact via HTTP? In line with my previous argument, if we are only interacting with the service over a web, do any of those points really make any difference? An http request doesn't care about any of those finer details or contractual guarantees so long as the method it calls "just works".

Is there anything I am missing? Any key benefit to using a service? Personally, I support the Web Service architecture. I like the idea of having a flexible and well defined system that can support future development. What I am basically looking to get out of this is a way to go to a coworker and say "This should be a service for x y z reasons and we could see a b c improvements for doing so".

View 5 Replies

Whats The Pros/cons With Working With PHP As Opposed To .net Or The Whole .net Framework

Mar 5, 2011

im currently working with php but everyone is telling me that asp.net is so much better and i was just wondering what the real story is

View 2 Replies

Configuration :: Pros / Cons Of Using Static Ip For Website Authentication

Dec 16, 2010

I am building a web application that will not only require a standard user/pass authentication, but users will need to reside at certain locations to authenticate. My initial thought is to have those locations set up with static ips, that I can look for in the request for authentication. I am mostly a programmer and not an expert in http and iis. I am hoping to get some good advice as to what the pros and cons to this approach will be. Also, VPN to the web server is not an option. This web application will be exposed to the web.

View 2 Replies

ADO.NET :: SQL Server Views And The Entity Framework - Pros Vs Cons?

Mar 16, 2011

I was wondering what your thoughts were in regards to utilizing SQL Server Views as objects in the entity framework? It would only be used for reading data versus modifiying it.

View 2 Replies

Security :: Implement Kerberos Authentication - Pros & Cons?

May 7, 2010

how to implement kerberos authentication in asp.net. Pros & Cons of this authentication process.

View 1 Replies

Pros And Cons Of Running Quartz.NET Embedded Or As A Windows Service?

May 20, 2010

I want to add quartz scheduling to an ASP.NET application.It will be used to send queued up emails.What are the pros and cons of running quartz.net as windows service vs embedded.My main concern is how Quartz.NET in embedded mode handles variable number of worker processes in IIS.

View 2 Replies

C# - What Are The Pros/cons Of Choosing Between Static And Instance Data Access Classes In A Web App

Jan 20, 2010

I've read several other questions on this topic (here, here, and here), but have yet to see a great answer. I've developed my fair share of data access layers before and personally prefer to use instance classes instead of static classes. However, it is more of a personal preference (I like to test my business objects, and this approach makes mocking out the DAL easier). I have used static classes to access the database before, but I've always felt a little insecure in the appropriateness of such a design (especially in an ASP.NET environment).

Can anyone provide some good pros/cons with regards to these two approaches to developing data access classes with ADO.NET providers (no ORM), in an ASP.NET application in particular. Feel free to chime in if you have some more general static vs. instance class tips as well.

In particular, the issues I'm concerned about are:

Threading & concurrency
Scalability
Performance
Any other unknowns

View 4 Replies

Pros And Cons Between Using The Control Compared To Old Reliable Table Html Implementation?

May 7, 2010

What are the pros and cons between using the ASP.Net control compared to the old reliable table html implementation. I know that the asp:Table will end up on the returned page as a html table, and from looking into it so far people are saying its easier to work with the asp:Table in the server side code, but I'd love to hear what the stackoverflow community has to say about the matter.

View 3 Replies

Pros/cons Of Reading Connection String From Physical File Versus Application Object

Apr 9, 2010

my ASP.NET application reads an xml file to determine which environment it's currently in (e.g. local, development, production).

It checks this file every single time it opens a connection to the database, in order to know which connection string to grab from the Application Settings.

I'm entering a phase of development where efficiency is becoming a concern. I don't think it's a good idea to have to read a file on a physical disk ever single time I wish to access the database (very often).

I was considering storing the connection string in Application["ConnectionString"].

[code].....

I didn't design the application so I figure there must have been a reason for reading the xml file every time (to change settings while the application runs?) I have very little concept of the inner workings here. What are the pros and cons?

View 2 Replies

MVC :: How Should Use The Service/repository Pattern

Dec 8, 2010

i'm new to asp.net MVC, and I'm trying to understand the service/repository pattern and how to best implement it.

I've followed the MVC Music store tutorial, and it suggests that the public partial class ShoppingCart implements an AddToCart method looking like this:

[Code]....

Now if I would like to use the service/repository pattern in a correct way, should I just replace the row "storeDB.AddToCarts(cartItem)" with something like cartService.AddToCarts(cartItem) and then just save the added row by calling cartService.Save() instead of shopDB.Save()? The methods AddToCart(...) and Save() in cartService then calls the repository that does the actual saving.

View 3 Replies

Can The Repository Pattern Work Well With Webforms

Mar 8, 2011

I've been using MVC for the last year and unfortunately I am stuck adding features to an existing web forms site. The site makes heavy use of inline SQL and it is kind of all over the place. Using an ORM is not going to happen either and wouldn't address the problem of keeping queries all in one place.

Can the Repository Pattern and Service layers also work well with classic asp.net web forms?

View 2 Replies

Splitting Out Membership And Using The Repository Pattern

Feb 15, 2010

I am building an application using asp.net mvc, DI, IoC, TDD as a bit of a learning exercise.

For my data access I am using the repository pattern. Now I am looking at membership and how this can work with the repository pattern. I am currently using a Linq to Sql repository but don't want to be tied to SQL Server for membership.

Secondly, I am looking to split out membership into a number of services:

AuthenticationService - identify the user
AuthorizationService - what can they do
PersonalizationService - profile

The personalization service will be what really defines a "customer" in my application and each customer will have a unique id/username that ties back to the AuthenticationService - thus, allowing me to use the default ASP.NET Membership provider, roll my own or use something like Open ID.

Is this a good approach? I don't want to reinvent the wheel but would rather these important parts of my application follow the same patterns as the rest.

View 2 Replies

C# - Class Encapsulation With Repository Pattern?

Oct 18, 2010

I am sort of using a repository pattern to extract information from a database. I have two classes, report and reportRepository.

The trouble I have is that since reportReposity has to fill in all the details for the report object, all the members in the report have to be publicly accessible.

Is there a way so that I can ensure that only the repository class can access some of the methods of the report class and only it can set some of the properties that other classes cannot, sort of like what friend does in c++. Or is there a completely different way of handling this situation?

I am using C# in ASP.NET 2.0

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved