Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Roshan Lal

Ranch Hand
+ Follow
since Nov 13, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roshan Lal

Originally posted by Jothi Shankar Kumar Sankararaj:
Guys,

Suppose I have a scenario like this where I have a webapp with some servlets and I have run the application by starting tomcat. Now I make some small changes to my servlet and how can I redeploy it without stopping Tomcat?? Is there any facility in the Eclipse IDE for this???

I'm using Lomboz Eclipse IDE with the sysdeo plugin for Tomcat!



With sysdeo plugin it is very easy.
In the Preference->Tomcat choose Context files instead of Server.xml.
And in your applications context file, use docbase=<path of your docroot> (it can be the path of your docroot in source project) and reloadable=true. All your changes are immediatley effective without restarting tomcat.

HTH
Roshan

Originally posted by Ilja Preuss:
It sounds to me like you have a one-to-one mapping of document types to Java classes? Perhaps it is time to give up that correlation?

It seems to me like you are feeling the pain of mixing a business decision (should there be a new document type) with a technical decision (should there be a new class). If it makes sense to the users to introduce a new document type, but it doesn't make sense technically to introduce a new class, it sounds to me like the most reasonable thing to do is finding a way to introduce a new document type without having to introduce a new class.

How does that sound to you?



You are quite right, Ilja. Technically it does not make much sense to introduce a new type but for business people it probably does. The comment
"finding a way to introduce a new document type without having to introduce new class" is interesting. I'll look into it.

Thanks again
Roshan

Originally posted by Frank Carver:
Can you not just extend the old class with the new one?



That way you get all the fields and behaviour of the old class with a new name, but with no duplicated coding.

Or have I missed the point?



Thanks Frank for your comment. I suspect they will change their mind and may want to remove some of the data members in the new type which are present in the existing type, that is the main reason for not inheriting from the existing type.

This requirement is in very preliminary stage. I am going to meet them in person in couple of days and hope to find more reasons they are asking for a new type. The current reason given, "only for tracking purpose", does not look good enough.

Thanks
Roshan

Originally posted by Ilja Preuss:
Why do those customers know about the classes at all? What kind of interface are they using to your system?



They create documents of different types using different templates. Using a web interface they select desired document type (for each type there is a pre-defined template) so they have to know the document type. Using the template they create their document (the content) and upload/checkin them. To later search these document they have to fill-in the meta-data about these documents e.g state (draft, reviewed, approved), reviewer, review-date, end client firm name, end client firm size, dozens of such fields. So far, the number and types of these meta-data fields are different for different documents types.
Now they want to have another document type which differs from an existing document type only in type-name, that is where I am having doubts. The only reason they say they want to have such a document type and not use an existing one with identical meta-data fields, is for tracking purpose. The documents of this new type would be sent to their client firms, the documents created using existing type is not sent to the client firms.
Of course it is possible to add another meta-data boolean field in existing document type saying sent to their client or not. They prefer a new type over having added another flag. I'm debating whether it is good idea at all to have two document types with identical meta-data. These meta-data fields are member fields in our class so if we go by our users' request, we would have to store these meta-data in a class which is identical to an existing one except different name.
Good Morning Everyone,

A new requirement has just come up to us, from our internal customers. It says to create new types which are identical to some existing ones except the names. Now, these classes are just data classes, no behaviour. Basically, they correspond to MS Word templates. The data members of the classes are fields in the word templates.

The first question I asked why such a new type is needed which differs from the existing one only in name .They said these new types are just "for tracking purposes". The documents (objects) corresponding to the existing type (word template), they use for their own purpose but the new documents(in the new type/template) would be sent to the end customer (external customers).

We are scheduled to have a meeting to discuss these. However, I would like to have others' opinions on this whether having two types differ only in name is ever a good idea. If other poeple came across such issues.
The only thing I'm currently inclined to decide is not to inherit the new class from existing one, even if the data members are identical, allowing the possibility of removing or changing attribute types.

Thanks
Roshan

Originally posted by Stefan Wagner:
Are groups of 1 element possible groups? X (A)



Yes, they are.
12 years ago

Originally posted by Lear nable:

Also, take a loop at Set Cover Problem




Lear,

I'm searching the web. Yes, looks like my problem is somewhat similar to Set Cover/Set Packing problem. So far, I have not found an implementation though.
12 years ago

Originally posted by Lear nable:


How do you color groups? Does it serve any practical purpose?



Lear,

There are business rules whereby groups can be in different "color"/catagories. The "color" word is used for
illustrated purpose only.
There is practical purpose for assigning these catagories.
This is one of the parameter in maximization function for the
arrangements.

Thanks
Roshan
12 years ago

Originally posted by Stefan Wagner:
I would start with smallest groups, because they tend to have the smallest intersections.

When I understood correctly, a supergroup of 8 Groups with a total of 16 elements is better than a supergroup of one group with 15 elements.

Then I would try to reach the maximal number of elements.
Then I would try to replace groups with larger groups of the same elements.
X (A, B) + Y (C, D) -> Z (A, B, C, D)

This would still be a hard job, and I guess it is not guaranteed to find the best combination.

It reminds me of the backpacker problem.

Are groups of 1 element possible groups? X (A)



Thanks Stefan.
1. The input groups are unsorted, if we start with smallest then
we have to sort them first.
2. "a supergroup of 8 Groups with a total of 16 elements is better than a supergroup of one group with 15 elements". Yes, any arrangement with more total member is better.

I guess, the harder part is finding the intersecting sets efficiently as there could be hundreds of sets.

A naive solution could be like this.

Set findBestArrangement(Group[] groups) {
Set best = = new HashSet();;
for (int i=0; i < groups.length; i++) {
Set arrangement = new HashSet();
Group g = groups[i];
arrangement.add(g);
for (int j=0; j < groups.length; j++) {
if (i != j) {
Group g1 = groups[j];
if (!g.intersects(g1)) {
arrangement.add(g1);
}
}
}
if (arrangement.compareTo(best) > 0) {
best = arrangement;
}
}
return best;
}

We may improve upon this, say by storing the intersecting groups found so
far and so may have to sacrifice some memory for speed.

Thanks everybody for your input
Roshan
12 years ago


If I understand correctly, an optimal and valid arrangement is one in which all 15 members are included, there is NO duplication of members, and better groups prefered over worse groups. Is that correct? By "no duplication", do you mean "minimize duplication"?


You are right, Lear.
But to be considered "best" it doesn't have to have all
the members in it. In many cases, it is not even possible to have an arrangement which will cover all the members.
Best here simply will mean there is no other better arrangement. That
is, if there are 15 members and we could make only 3 arrangements with
10, 12, 13 total members then the arrangement with 13 is best.

Absolutely no duplication. Even if a single member is common amongs
groups inside the arrangement, the whole arrangement is invalid.

I'll do more search on Set Cover problem. That wiki link just gives definition.
12 years ago
Hi everybody,

I have a problem on which some pointers can be very useful
and would appreciate some help.

The problem can be formulated like this:

There are members like, A,B,C...L, M, N,O (15 members).

These members are grouped together by some criteria and we get
get groups(sets) like (A,B), (C,D), (J,K,L), (B,D,I), (B,C,D), (A,K)
,(J,K,M,N,O) and so forth. There will be dozens and in worse cases
hundreds of such groups.

These groups have some properties which makes a group better than the other. First is the size. The larger size group is better.
Second, color.can be be green or yellow. If
there are two groups the same size say G(A,B) and Y(A,B) then G(A,B) is considered better than Y(A,B).

The goal is to combine these groups into arrangements(set of groups)
and find the best arrangement so that in an arrangement of groups,

i)none of the member in the combined group arrangement is repeated
ie [Y(A,B), G(B,C)] is invalid arrangement becuase B appears twice here.

ii) an arrangement with larger number of member is considered better
ie Y(A,B,C) is superior to G(A,B).

iii) if two arrangement have same number of members, then the one with
fewer group is considered better. eg [Y(A,B,C,D)] is better than [Y(A,B), G(C,D)].


Finding the best arrangement is proving to be an expensive operation.


My initial logic would be:
a) remove all the yellow groups who have a corresponding
sized green group as they are guarnteed to be inferior in the presence of green
group. That is if both G(A,B) and Y(A,B) exist keep only G(A,B)

b)Then partition groups into two categories the ones which don't have any of its member in any other groups and the others which may have at least one of its member present in any other group.

c) Then for each group which have at least of one of its member in common with others, we generate an arrangement by adding that group and all the disjoint groups. Compare this arrangement with the last one and keep the better one.

I hope I'm making the problem understandble. Any help, suggestion is
highly appreciated.

Thanks
Roshan
12 years ago
I used JMeter. Liked it.

-Roshan
12 years ago
Stan,

Thank you very much for your comments. Your comments revalidate some of my thoughts.

Currently we have only browser based clients for our site (Org1). The webapp does remember the input entered by the user for the session duration. Depending on the data, the system determines eligibility of the person for various assistance programs.

Kind of page-flow we have could be like this:
a user enters enters age on the first form.
If the age is not old enough then no need to ask further question
like if the person is receiving medicare or not, which will affect old-age assistance determination. And so forth.

Now if were to provide webservice to the non-browser client then that client needs pass xml request and get back the result, per the xml schema we will create. The other orgs will use our schema
to send the xml request would have to provide this information like person is receiving medicare or not unnecessarily, for persons which could not possibly have received medicare becuase they are not age-qualified.

So set of input data elements needed to determine
the eligibilities can vary depending ob values of other data.

So our implementation choices could be:
1) Require that org2 (and org3,org4... in not so distant future) send the xml request to supply superset of data some of which will not be used in eligibility determination.

2) Require minimal data first and if the system determines that some additional info could possibly lead the applicant to become eligible to some programs then in the reponse instead of sending eligibility determination we send message to supply more data and send request again.

3) The other agencies' worker enters data in his GUI and then clicks on a button/link which will open a new browser window for our application session where the user entered data is already pre-populated in our session and then the user continues interacting with our application as usual.

I'm not quite sure which one is better. None of these look perfect.
With choice 1, though on some level looks cleaner, we have redundancy.
Also, we may need to provide customized schema for org2 (and org3..in future).

With choice 2, on average, there will more than one invocation per one logical request. Doesn't look good.

Choice 3 does not look that attractive either. It merely is then existing application plus some data pre-populated. Also, with choice 3, the results are only displayed in the browser nothing gets sent back as would be possible with other choices. With the choice 1 or 2, the sent back results via webservice could potentially be used for further processing in those organizations.


I'm not sure whether I conveyed the problem clearly.
But if it did make some sense, which one looks better to you?

Regards
Roshan

Scenario:
Organizations org1, org2 provide distinct types of assitance
to needy people. When a user apply for assitance to org1.com site, then
he is asked questions to determine whether or not he is eligible for
the assitance grant. Now in the questionair process, some questions are
only asked depending on the answers to prior questions so as not to ask unnecessary questions. This is how it works now.

The new requirement comes in that when org2 receives paper application for
assistance and the worker at org2 does the data entry in org2 he should enquire org1 site if the person is eligible for assitance from org1 also. It is required that the data already entered in the org2 system be used to enquire the org1 site for the person's eligibility so that the org2 worker
does not have to enter the data again on the site of org1.com.

We are thinking of providing the org1.com functionality as webservice which
org2 can invoke. The problem here is the org1.com website customizes questions based on answers to prior questions in form filling process,
but the webservice is not interactive and to give the correct response
back it will likely need to have superset of questions answered some of which would not have necessarily been asked if the user directly went to the website.

I'll appreciate any pointers on this.

Thanks you
Roshan

Originally posted by Paul Sturrock:
I doubt if there would be any performance implications one way or the other. Placing constants in an Interface is supposedly frowned upon, but again I can't really see a reason why.



It is frowned upon basically for not using Interfaces for its intended purpose, but for side effect.
That is for convenience it provides that you don't have to
fully qualify the constants as compared to if they were in a class.

Typically we use interfaces so that the clients can work with interfaces rather than the classes implementing them, giving the flexibility of changing the implementations without having to change client code.

HTH

-Roshan
13 years ago