architectural-patterns

Active Records vs. Repository - pros and cons?

自作多情 提交于 2019-11-30 14:56:57
问题 Using ActiveRecord you might define a class like this: class Contact { private String _name; public String Name { get { return _name; } set { if (value == String.IsNullOrWhiteSpace()) throw new ArgumentException(...); else _name = value; } } public Boolean Validate() { ... /* check Name is unique in DB */ } public Boolean Save() { ... } public static List<Contact> Load() { ... } } Whilst this is nice and simple, I've found my classes become very bloated with a big mix of logic going on! Using

Active Records vs. Repository - pros and cons?

♀尐吖头ヾ 提交于 2019-11-30 13:01:24
Using ActiveRecord you might define a class like this: class Contact { private String _name; public String Name { get { return _name; } set { if (value == String.IsNullOrWhiteSpace()) throw new ArgumentException(...); else _name = value; } } public Boolean Validate() { ... /* check Name is unique in DB */ } public Boolean Save() { ... } public static List<Contact> Load() { ... } } Whilst this is nice and simple, I've found my classes become very bloated with a big mix of logic going on! Using a layered/domain design you might define the same class like: class Contact { [Required

Is MVC a Design Pattern or Architectural pattern

瘦欲@ 提交于 2019-11-29 19:14:44
According to Sun and Msdn it is a design pattern. According to Wikipedia it is an architectural pattern In comparison to design patterns, architectural patterns are larger in scale. (Wikipedia - Architectural pattern ) Or it is an architectural pattern that also has a design pattern ? Which one is true ? MVC is more of an architectural pattern, but not for complete application. MVC mostly relates to the UI / interaction layer of an application. You're still going to need business logic layer, maybe some service layer and data access layer. That is, if you're into n-tier approach. Why does one

Transactions in the Repository Pattern

非 Y 不嫁゛ 提交于 2019-11-28 16:12:23
How do I encapsulate the saving of more than one entity in a transactional manner using the repository pattern? For example, what if I wanted to add an order and update the customer status based on that order creation, but only do so if the order completed successfully? Keep in mind that for this example, orders are not a collection inside the customer. They are their own entity. This is just a contrived example, so I don’t really care whether orders should or should not be inside the customer object or even in the same bounded context. I don’t really care what underlying technology will be

Does Presenter in Model-View-Presenter create views?

大憨熊 提交于 2019-11-28 03:29:09
How are Views created in MVP? Does the Presenter always create them (in addition to View in case of subviews)? Or is it a separate third-party component or App or something that creates them? Let's also add that I'm probably going to do this on Dojo Toolkit/ExtJS (JavaScript that is). So, I have these code lines: var v = new MyApp.view.User(); var p = new MyApp.presenter.User(); where should both lines go exactly? Does the presenter instantiate the view, or vice-versa? And what instantiates the first instance? Marijn It depends ... The main goal of MVP is to separate complex decision logic

Transactions in the Repository Pattern

我的梦境 提交于 2019-11-27 09:36:44
问题 How do I encapsulate the saving of more than one entity in a transactional manner using the repository pattern? For example, what if I wanted to add an order and update the customer status based on that order creation, but only do so if the order completed successfully? Keep in mind that for this example, orders are not a collection inside the customer. They are their own entity. This is just a contrived example, so I don’t really care whether orders should or should not be inside the

Does Presenter in Model-View-Presenter create views?

China☆狼群 提交于 2019-11-27 00:10:06
问题 How are Views created in MVP? Does the Presenter always create them (in addition to View in case of subviews)? Or is it a separate third-party component or App or something that creates them? Let's also add that I'm probably going to do this on Dojo Toolkit/ExtJS (JavaScript that is). So, I have these code lines: var v = new MyApp.view.User(); var p = new MyApp.presenter.User(); where should both lines go exactly? Does the presenter instantiate the view, or vice-versa? And what instantiates

MVCS - Model View Controller Service

て烟熏妆下的殇ゞ 提交于 2019-11-26 23:47:12
I've been using MVC for a long time and heard about the " Service " layer (for example in Java web project) and I've been wondering if that is a real architectural pattern given I can't find a lot of information about it. The idea of MVCS is to have a Service layer between the controller and the model , to encapsulate all the business logic that could be in the controller. That way, the controllers are just there to forward and control the execution. And you can call a Service in many controllers (for example, a website and a webservice), without duplicating code. Service layer can be

MVCS - Model View Controller Service

穿精又带淫゛_ 提交于 2019-11-26 08:47:30
问题 I\'ve been using MVC for a long time and heard about the \" Service \" layer (for example in Java web project) and I\'ve been wondering if that is a real architectural pattern given I can\'t find a lot of information about it. The idea of MVCS is to have a Service layer between the controller and the model , to encapsulate all the business logic that could be in the controller. That way, the controllers are just there to forward and control the execution. And you can call a Service in many