n-tier-architecture

Where should data validation occur?

吃可爱长大的小学妹 提交于 2019-11-30 06:51:37
I've read conflicting philosophies on where data validation should happen and it's just confusing me more. Some say it should only be in the database. Others say that the validation rules should be mirrored in other layers like the bll or ui. Where should the data validation live? Should rules be split across multiple layers? What are some of the actual best practices (as opposed to theory, head in the clouds type stuff) regarding when and where to validate data in an application running on top of a database. My 2 cents: Data validation should occur in two locations: The point where data is

How would I know if I should use Self-Tracking Entities or DTOs/POCOs?

╄→гoц情女王★ 提交于 2019-11-30 05:29:53
What are some questions I can ask myself about our design to identify if we should use DTOs or Self-Tracking Entities in our application? Here's some things I know of to take into consideration: We have a standard n-tier application with a WPF/MVVM client, WCF server, and MS SQL Database. Users can define their own interface, so the data needed from the WCF service changes based on what interface the user has defined for themselves Models are used on both the client-side and server-side for validation. We would not be binding directly to the DTO or STE Some Models contain properties that get

Where does Web API fit in a typical n-tier architecture?

社会主义新天地 提交于 2019-11-30 02:04:11
Usually when i layout an n-tier architecture for a project I have the following layers: Domain (domain model, repository contracts) Data (repositories working on top of domain model) Service (aggregates repos, caching, validation) Presentation (the mvc app) Where would ASP.NET MVC 4 Web API fit into this considering that it will be used by the actual application and outside clients? Is it part of the service layer or does it use the service layer and sits at the same level with the MVC app? There could be 2 approaches: You decide to consume your Web API from the MVC application through HTTP

Using DTO to transfer data between service layer and UI layer

感情迁移 提交于 2019-11-29 20:31:12
I've been trying to figure this out for days but there seems to be very little info on this particular subject with ASP.NET MVC. I've been Googling around for days and haven't really been able to figure anything out about this particular issue. I've got a 3 layer project. Business, DAL and UI/Web layer. In the DAL is dbcontext, repository and unit of work. In the business layer is a domain layer with all the interfaces and the EF models. In the business layer there is also a service layer with DTOs for the EF models and a generic repository service that accesses the repository. This picture

Exception handling in n-tier applications?

谁都会走 提交于 2019-11-29 20:18:45
What is the suggested approach or best practice for handling exceptions in tiered applications? Where should you place try/catch blocks? Where should you implement logging? Is there a suggested pattern for managing exceptions in n-tiered applications? Consider a simple example. Suppose you have a UI, that calls a business layer, that calls a data layer: //UI protected void ButtonClick_GetObject(object sender, EventArgs e) { try { MyObj obj = Business.GetObj(); } catch (Exception ex) { Logger.Log(ex); //should the logging happen here, or at source? MessageBox.Show("An error occurred"); } } /

Unity 3 and Error “The type name or alias ”xxxxx“ could not be resolved. Please check your configuration file and verify this type name.”

假装没事ソ 提交于 2019-11-29 19:08:17
问题 Is there any way to resolve this problem with Unity 3 ? I have made all that is possible to bypass this message error, but I can't resolve; I have already did everything I've seen in googles searches. I am almost giving up and trying another DI solution. My configuration file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" /> <

Generating identities for entities in DDD

早过忘川 提交于 2019-11-29 19:06:17
问题 Edit To further clarify my initial problem, I rewrote the question with more 'DDD'-termini, common patterns and discussion arguments. The orginal version can be found under revisions. Where and how are identities for entities / aggregate roots being generated inside the domain when correctly applying DDD? I need to assign unique identities to my entities, either upon creation or persisting. Those identities can come in several styles Computed (based on the characteristics of an entity, hence

Where to set a UTC datetime value in n-tier application: Presentation Layer, Domain, or Database?

 ̄綄美尐妖づ 提交于 2019-11-29 11:46:19
This seems like it should be an obvious question, but I have had some issues finding a good answer. I am building an n-tier application that needs to be UTC time sensitive. Values can be updated and when they are timestamps are recorded. This includes transactions in the database where updates or inserts will impact datetime columns. To give some context I am using SQL 2008 R2 + with DATETIMEOFFSET(2) for most of my datetime columns. I am considering putting the updates for timestamps into the Stored Procedures so that they do not need to be passed through the network. This will save bandwidth

EF4 Independent Associations - Why avoid them?

 ̄綄美尐妖づ 提交于 2019-11-29 07:15:02
I saw this comment on MSDN ( link and link ): "Note that Independent Associations should often be avoided since things like N-Tier and concurrency becomes more difficult." I'm new to EF4 and I'm building an n-Tier web app. This sounds like an important pitfall. Can someone explain to me what this means? I think it's personal preference. Originally, EF was created to only use indep. associations and aligned with a more classic ERM approach. However, most of us devs are so dependent on FKs that it made life very complex. So MS gave us FKs in EF4 which meant not only having the FK as a property

What's the naming convention for classes in the DataAccess Project?

◇◆丶佛笑我妖孽 提交于 2019-11-29 06:50:34
I usually name by classes in the Business project as Manager.cs, like BaseManager.cs, CommentsManager.cs, ProfileManager.cs, etc... How do you name your classes in the DataAccess project? Do you call it CommentsDA, CommentsDB, or what? Just curious...BTW, I'm using .NET C#. John K Naming Conventions between Software Layers I used to separate class naming conventions for each kind of software layer like you're asking about. However in the .NET world upon realizing each layer is it's own assembly, and assemblies are often replaceable with assemblies implementing same interface/s, I found the