separation-of-concerns

How can I eliminate the dependency from of a ListView's onItemClick/getView and its row types?

血红的双手。 提交于 2019-12-11 18:05:23
问题 As a simplified example, consider a ListView that can contain both sub-categories and book titles. If a book title is clicked, a new activity should start that shows the cover image. If a sub-category is clicked, a new list of books and categories is displayed. A Row interface is defined as follows. interface Row { void onClick(); void draw(View v); } I would like to know how to prevent a dependency from the ListView 's ArrayAdapter as well as from the implementer of onItemClickListener on

ASP.Net MVC How to separate view models from DB models?

偶尔善良 提交于 2019-12-11 14:24:33
问题 I can't quite decide how to go about separating my view models from my DB models. I'm using an ActiveRecord pattern for my DB access. Meaning I get a User class instance for each User row in the database. In WebForms I'm used to use these as my model objects, implementing most of the business logic directly on my ActiveRecords. I realize this isn't exactly 3-tiered design, and I'd really like to improve upon it, especially in MVC, where separation of concerns is empathized. So I'd think the

In CakePHP, where would I put a method that performs a check on the Session User?

久未见 提交于 2019-12-11 13:54:15
问题 Background: I have a method levelCheck() which compares the current user's level to a few parameters, and returns a true or false. I need to be able to access this method from any controller, and I would also like to put a call to it inside a helper for use on menus, etc. Question: Due to Cake's flexibility, I can call almost anything from almost anywhere with Cake. Where is the correct place to put this? In a custom Session (extended)? In the AppController? A new component dealing with the

SQL Injection who should handle it? [closed]

我们两清 提交于 2019-12-11 10:04:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . In terms of separation of concerns, I would like to know your opinion about whether the concern of handling SQL Injection Attacks is a concern of System A or System B, let me explain: System A - You where asked to implement an Web Interface, responsible to determine

Architectural conundrum

别等时光非礼了梦想. 提交于 2019-12-11 07:39:11
问题 The worst thing when working on a one man project is the lack of input that you usually get from your coworkers. And because of the lack of that you tend to make obvious mistakes. After going down that road for some time I would need some help from the community. I started a little home-brew project that should turn into a portal of some sorts. And the main thing that is bothering me is the persistence layer that i have concocted. It should be completely separated from the presentation layer

Keeping IClientValidatable outside the model layer

安稳与你 提交于 2019-12-11 05:41:14
问题 I'm using Data Annotations to validate my model classes. I wrote a couple of custom attributes as well. Ultimately, the model is pushed to a web interface built in ASP.NET MVC, but I want to keep a clean separation of concerns, so the model classes has its own assembly (which will also be used by console apps). Having to use the IClientValidatable interface (which is a web concern) in the model layer breaks the loose coupling I'm aiming for. Any ideas on how to fix this? Thanks. 回答1: You can

Does user input go to the controller or model?

荒凉一梦 提交于 2019-12-11 02:59:36
问题 Right now I have my model split out, but my controller and views are still combined in a 12k line file. I've been looking to create a true MVC system for this, splitting out the views, but while looking for stuff to split out, I've noticed my controller is doing a lot of work that might belong in a model. For example, let's say I have... if (isset($_POST['write'])) { $obj = $objManager->get($_POST['id']); $obj->setFoo($_POST['foo']) ->setBar($_POST['bar']); $objManager->write($obj); echo ...

Is it bad practice for an angular directive to request data

怎甘沉沦 提交于 2019-12-10 17:53:44
问题 Consider for example a currentUser directive. I could let the controller use a service to get the data about the current user, provider it to the directive and let the directive render some "hello {user.name}" template. Alternatively I could have the directive have a dependency on some currentUserService and in the directive's controller ask for currentUserService.getCurrentUser. Is one of the two significantly better then the other for any reason? I tend to go with the first option but not

Separating Tkinter UI concerns from Logic in Python app

感情迁移 提交于 2019-12-10 09:41:54
问题 This is my first app ever. It is working well but I would like to separate the UI concerns like getting input and creating labels, from the translation logic. I would then like to remove the output from the previous translation, i.e., only showing one translation on the screen at a time. How can I separate the translation logic from my Tkinter GUI? from Tkinter import * import tkMessageBox def start(): inputg = input.get() if len(inputg) >= 2 and inputg.isalpha(): new_word_out = Label(text=

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

别来无恙 提交于 2019-12-10 04:11:53
问题 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