coupling

Does passing an aggregate object instead of a long argument list of objects reduce data coupling

此生再无相见时 提交于 2020-01-05 20:27:54
问题 I read that data coupling can be reduced by "not passing unnecessary arguments" Say there is a makeCake method which requires many instance variables in the Ingredients class as parameters: makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream) And instead of this, just pass the whole Ingredients Object makeCake(ingredients) and access the variables within the makeCake method.. Is this counted as reducing coupling between the class which calls

Does passing an aggregate object instead of a long argument list of objects reduce data coupling

ぐ巨炮叔叔 提交于 2020-01-05 20:27:16
问题 I read that data coupling can be reduced by "not passing unnecessary arguments" Say there is a makeCake method which requires many instance variables in the Ingredients class as parameters: makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream) And instead of this, just pass the whole Ingredients Object makeCake(ingredients) and access the variables within the makeCake method.. Is this counted as reducing coupling between the class which calls

Does passing an aggregate object instead of a long argument list of objects reduce data coupling

笑着哭i 提交于 2020-01-05 20:27:14
问题 I read that data coupling can be reduced by "not passing unnecessary arguments" Say there is a makeCake method which requires many instance variables in the Ingredients class as parameters: makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream) And instead of this, just pass the whole Ingredients Object makeCake(ingredients) and access the variables within the makeCake method.. Is this counted as reducing coupling between the class which calls

Does passing an aggregate object instead of a long argument list of objects reduce data coupling

梦想与她 提交于 2020-01-05 20:27:07
问题 I read that data coupling can be reduced by "not passing unnecessary arguments" Say there is a makeCake method which requires many instance variables in the Ingredients class as parameters: makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream) And instead of this, just pass the whole Ingredients Object makeCake(ingredients) and access the variables within the makeCake method.. Is this counted as reducing coupling between the class which calls

Does passing an aggregate object instead of a long argument list of objects reduce data coupling

二次信任 提交于 2020-01-05 20:27:03
问题 I read that data coupling can be reduced by "not passing unnecessary arguments" Say there is a makeCake method which requires many instance variables in the Ingredients class as parameters: makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream) And instead of this, just pass the whole Ingredients Object makeCake(ingredients) and access the variables within the makeCake method.. Is this counted as reducing coupling between the class which calls

Unit testing: how to test methods with a lot of underlying objects and business logic

和自甴很熟 提交于 2019-12-23 18:11:06
问题 I am really new to unit testing, and I can't figure out the proper way to do it for my case, though I spent crazy amount of time on research. My code base is huge (~3 years of work), very coupled unfortunately, hard to test and no unit testing has ever been done on it. So for instance, when trying to test a collection class ProductCollection , more specifically, the bool MoveElementAtIndex(Product productToMove, int newIndex) of it, I am encountering the following problems: first I have to

Most efficient way to build a random permutations list

谁都会走 提交于 2019-12-22 17:52:22
问题 For a given Collection<Object> aCollection , How do I build an ArrayList<OrderedCouple<Object>> with all possible permutations of couples in aCollection (except self-coupling). For instance, say aCollection is a Set<Team> containing teamA , teamB and teamC , and OrderedCouple is instead a class Game<Team> which constructor receives two team, the host and the guest as arguments. I want to build an ArrayList of all possible Game s between Team s. that is, the ArrayList will be the group {new

Decoupling vs YAGNI

你。 提交于 2019-12-21 04:42:46
问题 Do they contradict? Decoupling is something great and quite hard to achieve. However in most of the applications we don't really need it, so I can design highly coupled applications and it almost will not change anything other than obvious side effects such as "you can not separate components", "unit testing is pain in the arse" etc. What do you think? Do you always try to decouple and deal with the overhead? 回答1: It seems to me decoupling and YAGNI are very much complementary virtues. (I

How to solve the violations of the Law of Demeter?

我是研究僧i 提交于 2019-12-17 22:03:59
问题 A colleague and I designed a system for our customer, and in our opinion we created a nice clean design. But I'm having problems with some coupling we've introduced. I could try to create an example design which includes the same problems as our design, but if you forgive me I'll create an extract of our design to support the question. We're developing a system for the registration of certain treatments for a patients. To avoid having a broken link to image I'll describe the conceptual UML

What is the difference between loose coupling and tight coupling in the object oriented paradigm?

元气小坏坏 提交于 2019-12-16 19:49:36
问题 Can any one describe the exact difference between loose coupling and tight coupling in Object oriented paradigm? 回答1: Tight coupling is when a group of classes are highly dependent on one another. This scenario arises when a class assumes too many responsibilities, or when one concern is spread over many classes rather than having its own class. Loose coupling is achieved by means of a design that promotes single-responsibility and separation of concerns. A loosely-coupled class can be