separation-of-concerns

Which validation tags are appropriate for the model?

For proper separation of concerns on a domain/business assembly/layer it seems to me that a good practice would be to go ahead and system.ComponentModel.DataAnnotations mark up my fields in the domain assembly. Since most of these validations/annotations would be useful no matter what project type I wanted this domain to be usable in: W...

Performance implications with 'clean code'

At my workplace we're planning a major refactor on our core product, a web application with several 'modules'. I quoted that because that's one of our main concerns: modules are not really modules, the whole thing is monolithic. The application is written in PHP with smarty templating and using Pear for accessing a MySQL database. We're ...

When can a design pattern make your software worse?

When can a design pattern make your software worse? I have seen a program where they used the facade pattern between the GUI and logic. They considered that no objects may be transported over this, so only primitive types were used which made it difficult to code. ...

Taking baby-steps in applying a better design

In wanting to get some hands-on experience of good OO design I've decided to try to apply separation of concerns on a legacy app. I decided that I wasn't comfortable with these calls being scattered all over the code base. ConfigurationManager.AppSettings["key"] While I've already tackled this before by writing a helper class to enca...

Are WPF related properties inside a ViewModel a violation of MVVM best practices?

Here is an example case to elaborate: I am dynamically creating a simple Bar Graph using an ItemsControl in my View and binding the items to a collection of BarViewModels (each containing percentage a value) in my BarGraphViewModel. Each bar should have a different color. The colors should be chosen from a collection e.g. {Color1, Color...

question of design / structure of application and separation of concerns

Hi all, So this question is a sort of follow on from here (http://stackoverflow.com/questions/1914097/how-to-deal-with-multiple-event-args). That question led me onto thinking about this but is different enough to warrant its own thread. I am creating a game (for fun and learning purpose) and would like to know if I am using good sta...

Object Construction at Client or Business Layer?

Something I've noticed from looking at multiple .NET starter kits is that business object construction is often handled at the client level. Then, the business object is passed to the business layer for manipulation, serialization to the database, etc. Shouldn't this code be abstracted to the business layer, so that the client only needs...

ViewModels and rendering

In several sample projects, I've seen ViewModels being used to convert data objects into strings, for use in the View. The ViewModel will typically have a constructor that receives one parameter - a data object. The constructor will then populate various properties of the ViewModel (mostly strings and ints). This prevents any complex l...

Where to apply logic for a sidebar control in ASP.NET MVC

Take the example of wanting to have a "Latest news items" sidebar on every page of your ASP.NET MVC web site. I have a NewsItemController which is fine for pages dedicating their attention to NewsItems. What about having a news sidebar appear on the HomeController for the home page though? Or any other controller for that matter? My fir...

PHP MVC view looping

I have a template for a "blog preview" - which is basically just a thumbnail, title, and short excerpt of said blog in a nice concise structure built for repetition in a list. As hinted above, I intend to pull the top 10 blogs on my site from the DB in my model, transfer them to the controller, which will supply them as for the view. In...

Most Correct way to redirect page with Model-View-Presenter Pattern

What is the best way to call a Response.Redirect in the Model-View-Presenter pattern while adhering to correct tier separation? ...

When to use JavaScript template engines?

Here is an example of JavaScript template from Ben Nadel's demo single page long-lived AJAX application taken from: [source] <script id="contact-list-item-template" type="application/template"> <li class="contact clear-fix"> <div class="summary"> <a class="name">${name}</a> </div> ...

Approaching refactoring

I have a very data-centric application, written in Python / PyQt. I'm planning to do some refactoring to really separate the UI from the core, mainly because there aren't any real tests in place yet, and that clearly has to change. There is some separation already, and I think I've done quite a few things the right way, but it's far fro...

How do you keep your Domain Logic seperate from DB/Persistence Logic with Linq-2-Sql?

I'm trying to get at the best way to seperate the concerns of my domain logic and my persistence logic. I'm using Linq-2-Sql for the data access and I've been following the NerdDinner tutorial. If you look at page 40, you can see they are using partial classes to business rules to their Linq generated classes. To me, that feels wrong (is...

ASP.NET: Code behind or no code behind?

Why would anyone want to not use a code behind file so that server sided code is separated from markup? Wasn't that supposed to be one of the advantages of .NET over classic ASP? Personally, I think mixing code with markup makes the code a lot harder to understand. I hate to see those darn <% %> (server sided blocks) inter-spliced in ...

Best Design Pattern for HttpRequestDispatcher?

Hello, What's the best design pattern to use for an HTTP Request Dispatcher that has to do a "GET" or a "POST", return an output stream, parse the output stream, and then display the parsed results on an interface? Currently, I have an HttpRequestDispatcher.java in which a UI Class is defined in its constructor, and in the threaded run...

Where to put restrictions on entities when separating Business layer from Data Layer

I am attempting to create the the business and data layers for my big ASP.NET MVC application. As this is the first time for me attempting a project of this scale I am reading some books and trying to take good care at separating things out properly. Usually my applications mix the business logic and data access layers, and multiple bu...

Does this really violate MVC Separation of Concerns

Simple question. I must be totally wrong but I thought worth asking this question. Is accessing ViewData[“Message”] within the View correct according to separation of concerns described in MVC? For example, in Controller: ViewData[“Message”] = “Display this message”; Within View we call <%= ViewData[“Message”] %> The alternativ...

How to map View Model back to Domain Model in a POST action?

Every article found in the Internet on using ViewModels and utilizing Automapper gives the guidelines of the "Controller -> View" direction mapping. You take a domain model along with all Select Lists into one specialized ViewModel and pass it to the view. That's clear and fine. The view has a form, and eventually we are in the POST act...

How can I keep separation of concerns when using a grid in the presentation layer (esp. .NET)?

In a three-tier model (presentation-business-data access layers), I can consistently keep my lower layers agnostic of the upper layers. For example my data access layer never knows how it is presented or what busines rules are operated on it. My business rules are agnostic of how they're presented. But I must pray to Demeter for forgiv...