Is velocity templates good for evaluating conditions? [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am thinking about externalizing some conditions instead of implementing them in java so that I can easily change them later as needed.
For example, I need to check if certain keys exist in a given map and if the values of certain keys in a map equal to something.
I was thinking about using spring's expression language, but since we are already using velocity templates, I thought maybe it is a good candidate.
Any idea? Thanks.

You can easily use the #if/#else, #foreach and other condition functionality of velocity to do business logic as part of the velocity template rendering.
However I usually try to separate business logic from rendering in velocity for a number of reasons:
Complexity: The Velocity template can become hard to read, especially
if the target output itself requires complex resulting layout. If you
add additional business logic to the mix, it quickly becomes
impossible to read for anybody else (or for yourself after a few
months of not looking at it constantly)
Testability: It's harder to test Velocity templates, there's
better support for unit/integration testing of Java code
Functionality: Velocity is not a full programming language by
design, so you will miss some things sooner or later and a macro
simply is not a function, e.g. variables by default have global
scope, ... You are bound to run into some of these if you make
your templates big and complex.

Related

Abstraction, an OOPs vs non-OOPs concept [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am reading OOPS concepts and got stuck on Abstraction. I am not able to fully understand the concept. As I am feeling that it doesn't belongs to OOPS only. It was also used in C. But how
java abstraction different from C language abstraction. I know it is not a good question
for this forum but i am not able to get the perfect answer.
abstraction means to hide or to separate the complex details of one part of code to other part. say, you have to use a method that does complex calculation, and gives some result. So instead of writing your method inline, its better to write it in a method that just expose the signature (params and return type). in that way your caller (of method) remains unaware of complex code behind the method.
in general, when you use library function in c/c++ or APIs in java, it is also an abstraction.
So indeed, abstraction is not only OOP, but a general concept can be applied anywhere (even beyond the programming).

What language can be recommended for text mining/parsing? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I'm doing some text mining in web pages. Currently I'm working with Java, but maybe there is more appropriate languages to do what I want.
Example of some things I want to do:
Determine the char type of a word based on it parts (letter, digit, symbols, etc.) as Alphabetic, Number, Alphanumeric, Symbol, etc.(there is more types).
Discover stop words based on statistics.
Discover some gramatical class (verb, noun, preposition, conjuntion) based on statistics and some logics.
I was thinking about using Prolog and R (I don't know much about these languages), but I don't know if they are good for this or maybe, another language more appropriate.
Which can I use? Good libs for Java are welcome too.
python.!
They have a HELL-LOTTA libraries in this area.
but, i've got no knowledge about prologue and R.. but definitely py is LOT better than java in text mining, and AI stuff...
I highly recommend Perl. It has a lot of text-processing features, web search and parsing, and a large etc. Take a look at the available modules (>23.000 and growing) at CPAN.
I think Apache Solr and Nutch provides you the framework for that and on top of that you can extend it for your requirements.
Java has some basic support, but nothing like the above two products, they are awesome!
HTML Unit might give you some good APIs for fetching web pages, and traversing over elements in DOM by XPath. I have used it for sometime to perform simple to more complex operations.

Best java API for distance functions [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am new to this kind of computing. I don't know what are the existing distance functions that are helpful to calculate the distance between to double sets(arrays). Can some one suggest me at-least 10 distance functions so that i can select few among them which suits best for my problem domain. I just want to calculate the distance between two sets for my scientific approach to the problem domain. I also want to know whether i have to implement them manually or any java API that covers most distance functions? Suggestions can help me to minimize my effort and save my time..:)
Providing you with code is not really going to help. What you need to do is to read up on the mathematics of the the various measures of distance, and figure out which is most appropriate based on that knowledge.
You could start by reading the Wikipedia page on Distance and the linked pages and resources.
Only when you've decide on an appropriate measure do you need to go looking for code. In a lot of cases, it is probably simplest to implement the measure yourself.
Alternatively, if you want us to provide sensible suggestions of measures that are appropriate to your problem domain, tell us what the problem domain is.
Are we talking about statistical distance between two samples? If so, there is an abundance of methods, each one suiting a different problem.
If your problem domain is simple, subtracting the sample means (averages) could suffice. For more complex data, the Earth Movers' Distance is common, though newer and more robust methods (such as kernel functions) are available.
Coding is the least of your problems. You must provide a more accurate definition of your problem before I can further assist you.

Which algorithms are worth to learn or recall on preparation to Java developer interview? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I know that is Collections.sort() method in Java but I think quicksort is worth to remember and try.
My work target is general Java: web, database access, integration, not game developer, scientific application or another one that depends on advanced algorithms.
Which algorithms should I learn to pass without stress Java developer interview?
Fizz Buzz
I usually don't care, if a developer knows the basic algorithms by heart. I do care, if he is capabale of understanding requirements and translating them in correct, testable and understandable pieces of code.
Ah, and I do care if he knows how to implement the most common design patterns. And he should know when and how to use collections, threads and - String#split - it's amazing how many "developers" don't know how to read and process a simple csv file.
Although I fully agree with Joachim comment, I would go for : collection selection. This is not an algorithm per se, but rather a good view of which collection is good for which purpose :
sorted content with constant lookup time ? TreeSet !
mapped data with memorization of insertion order ? LinkedHashMap !
using that, and some knowledge of design patterns behind collections, you will far too often reply to algorithms questions using the knuth answer (or the subtle variation : as long as Sun developpers implemented it correctly, I only have to choose wisely).

performance tuning for JSF [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Can any one list out the tips to tune JSF WebApp # its best.
JSF RichFace
Never put logic into your getters.
They are called multiple times and
should only return something already
populated by another method. For
example if you are chaining drop-downs
together use an a4j:support tag on the
first one with an action attribute
that loads the data which is then
retrieved when you reRender the second
one.
Use the ajaxSingle="true" unless
you actually want to send the whole
form back to the server.
Don't use a
rich component if you only need a
normal one. For example don't use
rich:dataTable unless you are making
use of some of the features that it
has over and above h:dataTable.
Consider using immediate=true
attributes on elements where you do
not need validation Avoid displaying
large tables to user.
Use pagination
Do not over complicate EL expressions,
code them in Java in backing bean
JSF BestPractices
Performance Tuning
Moving to Stateless JSF would offer a great performance boost. Now it's possible to use JSF entirely stateless. See this blog & this issue. A payoff is that you can't create views dynamically (e.g. by binding, JSTL tags, etc), nor manipulate it after creation.
A Stateless JSF operation mode
would be incredibly useful for high-load applications and
architectures:
http://industrieit.com/blog/2011/11/stateless-jsf-high-performance-zero-per-request-memory-overhead/#comment-4
This has previously been suggested by Jacob:
http://weblogs.java.net/blog/jhook/archive/2006/01/experiment_goin.html
This would help JSF ditch the stigma of "slow and memory hog," and
help keep up with current tech trends (stateless architectures.)

Categories

Resources