Decreasing coupling and cohesion by facade pattern [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
For my Software Design class, I have to find out if it is possible to decrease coupling and decrease cohesion at the same time by using the Facade pattern?
As you all probably know, when there is low coupling, the cohesion of the classes is high and vice-versa.
To me, this is a contradictory state, but I still think it is possible but can't find the enough evidence to support this.
My answer is this. The reason for this is that if we give some instructions to the classes that are cohesive they would not function in the same manner if there were no instructions. Given that, let say that we have the same facade with the instructions that have the capability to receive attributes from the classes that have low or high coupling. If this is true, the classes wouldn't be so dependent to each other and the coupling would be also decreased. In that way we have a facade which in the same time decreases coupling and cohesion of the classes.

Related

is there a preferable relationship between classes? Why? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
is there really a preferable relationship between classes ? or it depends on the software we have ?
I know that we have is-a and has-a relationships in classes relations but, is there a one relation that is Confident and it most preferable between software-designers.
The only preferred relationship between classes is independence. Because independence means guranteed separation of concerns and freedom to evolve. (Joke)
But unfortunately independence is not very useful: Lots of lonesome classes will only help to solve lots of little isolated problems. If you really want to make something useful, you'll have to relate the right classes. And then, the only thing that matters is what relationship helps you to best address your needs. Sometimes it's inheritance (is-a), sometimes it's composition (has-a). It all depends on the context.
What your "doctor" probably meant was to prefer composition over inheritance. This is a useful advice. But it is a simple rule of thumb: it is not a universal truth.

What is better to design or discover interface [closed]

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 7 years ago.
Improve this question
Let's say you have some issue to develop. And as recommended practice it is good idea to use interfaces ( I don't mean GUI, I mean interface or abstract class ). And you can apply two ( I'm pretty sure, but for now I noticed I apply two ) ways:
Design interfaces upfront and then implement them.
Implement classes and then on basics of classes discover interface.
Personally I prefer second option, but during discussions with other developers I noticed that somebody prefers first approach. I can say that I prefer second approach for the following reasons:
I can faster write code
I avoid unnesessary code ( something that I never will use )
Interfaces in that case are more binded to "real" life
For me it is more convenient.
I'd like to hear other advices why somebody prefers option 1 or option 2.
As usually I code in C#, but AFAIK java also have idea of interfaces

HOW DO YOU CHOOSE WHICH DESIGN PATTERN TO USE? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How would you decide which design pattern to use?
I am asked the above question in at-least 2 different interviews .Apparently I am not the only one.Somebody else posted the same question on glassdoor.
http://www.glassdoor.com/Interview/How-would-you-decide-which-design-pattern-to-use-QTN_47521.htm
Any thoughts/suggestions/comments on how to answer that question ?
Well in fact it is overwhelming. There is no simple answer or chosen design patterns. I will begin to apply the "separation of concern" design principle. One class/set of functions only do one thing. That will help to reduce the complexity. Then you can apply structural design patterns. To begin, you can just use delegation.
Before thinking DP, think separation of concern to divide your code in small understandable parts. Then use some DP to link them all.
Do not go looking for situations where to use design patterns, look for code that can be optimised. When you have code that you think is not structured correctly. try to find a design pattern that will solve the problem.
Design patterns are meant to help you solve structural problems, do not go design your application just to be able to use design patterns.

Concurrent queues performance [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Java 7 offers a wide range of different implementations of concurrent queues, namely:
java.util.concurrent.ArrayBlockingQueue<E>
java.util.concurrent.ConcurrentLinkedQueue<E>
java.util.concurrent.LinkedBlockingDeque<E>
java.util.concurrent.LinkedBlockingQueue<E>
Has anyone found any performance characteristics i.e. which one of those seem to be the fastest? I want to use one of the implementations for performance-critical section of my code.
There's no possible way to say which is the "fastest". That question doesn't make much sense. Fastest for what? You'd have to provide at least some amount of requirements. Garbage collection will have an effect. Caching behavior comes into play too and depends on data access patterns.
After determining that your performance requirements are not being met, and concretely identifying the container operations as a bottleneck via proper profiling and benchmarking, it is up to you to test and benchmark your own code in your own specific situations.
The concurrent collections generally exhibit the same high level performance characteristics as their vanilla counterparts.

Why we use Strategy Facade in Java projects [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
What is the use of Strategy Facade in Java projects?
Please help on this.
Its a design pattern
A facade is an object that provides a simplified interface to a larger body of code
The strategy pattern (also known as the policy pattern) is a software design pattern, whereby an algorithm's behaviour can be selected at runtime.
Get Design Patterns: Elements of Reusable Object-Oriented Software, it changed my mind (and I learnt a lot!)

Categories