decoupling

Refactoring and Decoupling Rails controllers: can they call eachother?

[亡魂溺海] 提交于 2019-12-11 18:07:34
问题 I have the following situation in a Ruby on Rails app: user fills in a form (a comment), gets to see an omniauth page where she can choose the authentication method (openId, Twitter, Facebook and the likes). omniauth is filled in, on success user returns, gets a session and the initial form data is processed (comment is published). I all works, except that I have my logic spread around in, what I consider, an ugly way; the SessionsController now creates the comment on successfull

Can Angular 2 parse links received from external CMS to be resolved as internal

独自空忆成欢 提交于 2019-12-11 02:57:44
问题 We are working on a decoupled project with Drupal as our backend and Angular as our front-end. Everything is nearing completion but certain (dynamic, as in created in Drupal) pages require links to different pages of the angular app. For example: An editor creates an FAQ question in Drupal with an answer containing a link to the Pricing page of the angular app. (Q: How much does this service cost? A: Check out our [pricing] page) User on frontend opens FAQ page Angular loads our FAQ page

Dependency Injection and .NET Attributes

微笑、不失礼 提交于 2019-12-08 18:33:24
I have a couple of method attributes which do some logging. Our logging code sits behind an interface (ILog) and I'd like it if the attributes were only dependent upon that interface as opposed to an implementation. This isn't really about testability or dependency inversion so much as it is about keeping the coupling of components clean. An example would be where we have a web (Mvc) specific attribute as follows: HandleExceptionAttribute : FilterAttribute, IExceptionFilter { public void OnException(ExceptionContext context) { LogFactory.CreateInstance().Info("message here", "log entry type");

C++: How to get decoupled polymorphic behavior

China☆狼群 提交于 2019-12-08 12:48:41
问题 In a Qt project in C++, I am writing an interface for dynamically loaded plugins using QtPlugin. This interface should allow plugins to register their different parameters, and while a plugin is loaded the main program should display appropriate GUI controls representing each parameter. For instance, a parameter could be an int between 0 and 20 a represented by a QLabel and a QSlider in a box, or a color value represented by a QColorDialog. Here's the catch: I tried a standard OOP approach (?

Dependency Injection and .NET Attributes

旧时模样 提交于 2019-12-08 05:02:52
问题 I have a couple of method attributes which do some logging. Our logging code sits behind an interface (ILog) and I'd like it if the attributes were only dependent upon that interface as opposed to an implementation. This isn't really about testability or dependency inversion so much as it is about keeping the coupling of components clean. An example would be where we have a web (Mvc) specific attribute as follows: HandleExceptionAttribute : FilterAttribute, IExceptionFilter { public void

Is it bad practice to echo javascript with php

独自空忆成欢 提交于 2019-12-07 14:01:23
问题 I have a php application that makes use of a Listener class, which basically just sets up an ajax request with jquery (example below). But for some reason, echoing the javascript just seems inelegant. Is it better practice to build a singleton class for the javascript to be passed to (which could introduce coupling) or to just echo the script like I'm doing now? Here's a code snippet of what I'm doing. <?php $script = " <script> $(document).ready(function(){ $('".$trigger."').".$action."

How to deal with temporal coupling?

…衆ロ難τιáo~ 提交于 2019-12-07 06:12:08
问题 I'm struggling because of this: My classes have some methods that have temporal coupling. This is, some method MethodA has to be invoked first to "initialize" the data that MethodB needs to work properly. I usually make the temporal coupling explicit by passing the offending dependency to "MethodB" as argument , like in this snippet: private class SomeClass { private string field; private int count; public SomeClass() { MethodA(); MethodB(field); } private void MethodA() { field = "Something"

Avoiding coupling with Strategy pattern

ⅰ亾dé卋堺 提交于 2019-12-07 05:47:40
问题 I am attempting to apply the Strategy pattern to a particular situation, but am having an issue with how to avoid coupling each concrete strategy to the context object providing data for it. The following is a simplified case of a pattern that occurs a few different ways, but should be handled in a similar way. We have an object Acquisition that provides data relevant to a specific frame of time - basically a bunch of external data collected using different pieces of hardware. It's already

IoC and managing interfaces

和自甴很熟 提交于 2019-12-06 08:33:29
Say I had a business object library which was using IoC to implement a data access library. Where should I define the Data Access Interface? Which library does it belong? Or should it be in a separate library just for interfaces? I would define the interfaces within the business domain. Then the implementations of the interfaces would be in a library that references the business domain (and is referenced by whatever the application context is, or by an IoC library which is referenced by the application context). Then swapping out one implementation with another is just a matter of creating

How to deal with temporal coupling?

半世苍凉 提交于 2019-12-05 11:18:44
I'm struggling because of this: My classes have some methods that have temporal coupling. This is, some method MethodA has to be invoked first to "initialize" the data that MethodB needs to work properly. I usually make the temporal coupling explicit by passing the offending dependency to "MethodB" as argument , like in this snippet: private class SomeClass { private string field; private int count; public SomeClass() { MethodA(); MethodB(field); } private void MethodA() { field = "Something"; } private void MethodB(string str) { count = str.Length; } } Although it makes things explicit I feel