separation-of-concerns

Is it okay to store a domain entity's mutable properties as a value object?

微笑、不失礼 提交于 2019-12-05 04:31:43
There are certain parts of my UserEntity that I would like to be able to change and pass around, and there are certain parts that should remain constant. For example, I NEVER want to change my UserEntity's id, but things like email or password may change often, and can be used by other objects outside of the UserEntity as well. One instance of this would be when creating a UserEntity. Since a UserEntity cannot exist without an id, my controller could create a UserData object that would standardize the UserEntity properties. After the mapper creates an entity in the db, it would create a new

Creating Views in PHP - Best Practice [closed]

 ̄綄美尐妖づ 提交于 2019-12-05 04:20:41
I am working on a website with 2 other developers. I am only responsible to creating the views. The data is available in an object, and I have getters to read the data then create XHTML pages. What is the best practice to do this, without using any template engine? Thanks a lot. If you don't want to use a templating engine, you can make use of PHP's basic templating capabilities. Actually, you should just write the HTML, and whenever you need to output a variable's value, open a PHP part with <?php and close it with ?> . I will assume for the examples that $data is your data object. For

MVC: Are Models and Entity objects separate concepts?

女生的网名这么多〃 提交于 2019-12-04 23:02:25
问题 I asked here a while ago for some help in understanding MVC, since I'm very new to the topic. I thought I had a decent understanding of it, and this is documented in a blog post I wrote recently on the subject. My understanding basically boils down to this: Controller: Determines what needs to be done to fulfill a request, and utilizes whatever models it needs to collect/modify as needed. It's basically a manager for a given process. Views: Presentation only. Once a controller collects what

Persistence encapsulated via the domain, or persistence via the Repository?

送分小仙女□ 提交于 2019-12-04 19:58:14
If my Domain Model is not supposed to know/care about the Repository, then how does some behaviour like .UpdateOrder(...) , that encapsulates a CRUD-Update, interface with the Repository? Through a Domain Service? Ok, then my Repository has an effective CRUD-Update that's used in conjunction with my .UpdateOrder(...) . That's fine. But i don't want someone to use the Update method on the Repository, i want them to go through the behaviour on the Entity (use UpdateOrder() instead). I'd prefer that in likeness to the way my Domain Model satisfies invariants - by it's design (private set

How to tell Ninject to bind to an implementation it doesn't have a reference to

与世无争的帅哥 提交于 2019-12-04 11:17:02
问题 I'm using NinjectMVC3 in my ASP.NET MVC3 project. I have 3 layers Foo.Web Foo.Services Foo.Data Foo.Web references Foo.Services but not Foo.Data. One of my services looks like this public class FooService : IFooService { private readonly IFooRepository _fooRepository; public FooService(IFooRepository fooRepository) { _fooRepository = fooRepository; } // ... } NinjectMVC3 executes this bootstrapping method in the Foo.Web startup private static void RegisterServices(IKernel kernel) { kernel

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

房东的猫 提交于 2019-12-04 03:34:44
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, Color2, ..} The collection itself is constant but the number of bars will depend on the circumstances. A simple solution would be to create a simple BarViewModel like so: public class BarViewModel { public int Percentage { get; set; } public SolidColorBrush Stroke {

MVC: Are Models and Entity objects separate concepts?

好久不见. 提交于 2019-12-03 14:48:34
I asked here a while ago for some help in understanding MVC, since I'm very new to the topic. I thought I had a decent understanding of it, and this is documented in a blog post I wrote recently on the subject. My understanding basically boils down to this: Controller: Determines what needs to be done to fulfill a request, and utilizes whatever models it needs to collect/modify as needed. It's basically a manager for a given process. Views: Presentation only. Once a controller collects what it needs, it creates a specific type of view, hands it the information, and says "show this to the user

What does N-tier Architecture mean nowadays?

回眸只為那壹抹淺笑 提交于 2019-12-03 14:22:55
In a traditional sense, N-tier means separating the application into "tiers" and putting each "tier" on different servers. This was done for at least 3 reasons: Maintenance: a) Code Maintenance: Easier to do bug fixes and feature additions. b) Hardware Maintenance: Taking one server down does not disrupt service from other tier. Performance: One server was often not fast enough to handle web requests, business logic computations, and database/file access at the same time. Scalability: Specifically horizontal scalability a) Fault Tolerance: Ability to have more than 1 physical server per tier

How to tell Ninject to bind to an implementation it doesn't have a reference to

北慕城南 提交于 2019-12-03 08:05:24
I'm using NinjectMVC3 in my ASP.NET MVC3 project. I have 3 layers Foo.Web Foo.Services Foo.Data Foo.Web references Foo.Services but not Foo.Data. One of my services looks like this public class FooService : IFooService { private readonly IFooRepository _fooRepository; public FooService(IFooRepository fooRepository) { _fooRepository = fooRepository; } // ... } NinjectMVC3 executes this bootstrapping method in the Foo.Web startup private static void RegisterServices(IKernel kernel) { kernel.Bind<IFooService>().To<FooService>(); kernel.Bind<IFooRepository>().To<FooRepository>(); // Foo.Web doesn

Doing dependency injection using monad stacks

浪子不回头ぞ 提交于 2019-12-01 17:33:32
I'm trying different approaches to do what is sometimes known as dependency injection. For this I've elaborated a simple example of a weather app, where we want to fetch the weather data (from a web-service or from a hardware device), store the weather data (could be a database or simply a file), and report it (either print it to screen, or speak the weather). The idea is to write a program that uses some fetch , store , and report functions, whose implementations can vary. I've managed to separate concerns and abstract away from the implementations of retrieval, storage, and reporting using