When developing Java EE applications how do I separate Business Logic so it can be reused?
I inherited an application that is mostly Model 1. Business logic is located in JSPs, Servlets and DAO code.
I want to separate the business logic but I am confused by all of the frameworks etc. that exist.
I am looking into Hibernate with JPA ...
Using deflate() I was unable to open the zipped file using WinZip. Are the gz() the only ones compatable with WinZip? or is there some sort of mode I must call deflate() with?
Thanks.
...
What is the proper/preferred way to allocate memory in a C API?
I can see, at first, two options:
1) Let the caller do all the (outer) memory handling:
myStruct *s = malloc(sizeof(s));
myStruct_init(s);
myStruct_foo(s);
myStruct_destroy(s);
free(s);
The _init and _destroy functions are necessary since some more memory may be alloc...
I guess I'll try to explain my question through 2 code snippets:
// snippet 1
class FooBar
{
private int value;
public int DetermineSomeResult()
{
PerformSomeCalculationOnValue();
PerformSomeMoreStuffOnValue();
return value;
}
public int GetCachedValue()
{
return value;
}
}
The fir...
I want to encapsulate every resource from the client application with only one web service which can use my classlib.
I'm confused to access to other resources (web services, databases...) from the class library.
Because i think ClassLib should only have classes to reach objects within hierarchy, calculate some things etc.
If i set dat...
Hi,
Have you had any case when RAII wasn't the best method for resource management?
Just couriosity...
Thanks.
...
How would I design the tables for a matching system doing something like this:
We have X products which can have Y properties. The number of properties can vary from product to product and two products doesn't have to have any similar properties.
My number one goal is to take one product and find the most similar product.
Normally I w...
I've consolidated many of the useful answers and came up with my own answer below
For example, I am writing a an API Foo which needs explicit initialization and termination. (Should be language agnostic but I'm using C++ here)
class Foo
{
public:
static void InitLibrary(int someMagicInputRequiredAtRuntime);
static void TermLi...
For those of you who are not familiar with D string mixins, they're basically compile-time evals. You can take any compile time string (whether a literal or generated by template metaprogramming or compile time function evaluation) and compile it as code. If you use a simple string literal, it's basically compiler-automated copy-paste....
Earlier, I asked a question on how to call a static member's member functions so as to initialize it before making actual use of the static object. Then, I realized that I was perhaps making use of the static member in a wrong way, which led to this question:
Given a particular class, MyClass, in how many ways can we design our code so ...
int sysReturn = system("\"C:\\Program Files\\WinZip\\winzip32\" -a C:\\LOG\\test.zip C:\\LOG\\LOG_7-20-2010_17_8_48_834.csv");
Everything seems to work - as in it creates test.zip
However, it opens the WinZip GUI (that shows how much has been compressed, etc while my program is running.)
How can I skip that part where it doesn't ope...
Hi,
I want to design an app that needs user to input few things like start date, end date, bunch of other options and some text comments for which I am planning to use pickers to select the data that will slide up modally. I will need to move the view up and down to make sure that the element being filled stays in focus when the pickers...
Hi everyone,
I recently had my code reviewed by a senior developer in my company. He criticized my design for using too many classes. I am interested to hear your reactions.
I was tasked to create a service which produces an xml file as a result of manipulating 3 other xml files. Let's name these aaa.xml, bbb.xml and ccc.xml. The ser...
I was looking at a blog about good API design link text
In one of the example sections titled 'Reinventing the Socket', it showed a design of how to enforce certain rules and prerequisite on the client code that uses it. eg. the client must call bind() before it can call connect(), and it must be connected before it's allowed to send() ...
Hi,
I have an HTML interface developed using the usual suspects and I have a list of check boxes, which are segments / groups which the user can run a report on.
These segments need to be created on the server, so generally would not be available until the next day after creating them. My issue is that I need a graceful way to di...
When designing an XML structure I sometimes find myself wanting to use similar patterns across multiple element types that appear in the same instance document.
For example, the Head-Body pattern can often be useful if you want to keep data and meta data (data about the data) separate, and sometimes it makes sense for multiple types of ...
I'm looking to buy professional looking site templates. I love coding but design is not my forte. I also am working on a site for my company and I'd like for my users to be able to log in and edit the content instead of me doing it for them (CMS?). Templates that work in php and asp.net are preferred.
Anyone have a best kept secret w...
I am working on a component for merging arbitrary tokens with text in order to generate e-mails. I am going to be using nvelocity for the merging process, so I have defined the following interface:
public interface ITemplateEngine
{
string Merge(string template, IDictionary<string, object> data);
}
Now, in my scenario, the impleme...
I have a server listening on a port for request. When the request comes in, it is dispatched to a singleton class Singleton. This Singleton class has a data structure RootData.
class Singleton {
void process();
void refresh();
private:
RootData mRootData;
}
In the class there are two functions: process: Work with the mRo...
I'm working on a project where I have a few related bugs that are fairly minor in terms of loss of functionality. They are basically minor but annoying aesthetic problems, and based on loss of functionality should be fixed eventually, but not as a top priority. However, these bugs are caused by a fundamental, baked-in design flaw that ...