Why we use Strategy Facade in Java projects [closed] - java

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!)

Related

MicroService path /api/v1/ or /v1/api/ [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 5 years ago.
Improve this question
I'm building a MicroSerive and I was planning to publish services using this URI naming convention:
https://host:port/api/v1/service1
https://host:port/api/v1/service2
https://host:port/api/v2/service1
https://host:port/api/v2/service2
But I've also seen URIs named like this (ie vx and api 'swapped'):
https://host:port/v1/api/service1
https://host:port/v1/api/service2
https://host:port/v2/api/service1
https://host:port/v2/api/service2
In my opinion, the first approach is better. Are there any reasons to go for the second approach?
Technically it doesn't matter
But within an overall REST approach the URL should be easily readable and comprehensible by a humain.
using your first approach is the correct form as it's easily readable as
The Api of Version 1 that exposes ...

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.

Performance : ArrayBlockingQueue vs manaul implementation with List [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 8 years ago.
Improve this question
I need a thread-safe Queue and my question is that are there any performance difference between the queue I implement using List and wait/notify (simplest implementation) and classes such ArrayBlockingQueue and etc.?
The question is too vague to be answerable. Here is my advice:
If there is a standard class that does the job, use it in preference to rolling out your own.
Profile your code on realistic inputs to see where the bottlenecks are.
Optimize as appropriate.

How to list all methods in a Java class with regex [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
is there any way to search all methods in Java class with regex?
(public|protected|private|static|\s) +[\w\<\>\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;])
With this you can, but search before ask, because i only have used the search to find this answer ^^.
I think you're looking for reflection - see this tutorial for help. Only through reflection can you access information about loaded classes - unless you're thinking of loading in the .java file and analyzing its text.

Categories