pattern question ?

T

tomo

I have three separate classes that calculate credit capability od client
depending on loan type. Can I use some design pattern (for example Strategy)
to write it more efficient ? Any suggestion ?




__________ Information from ESET NOD32 Antivirus, version of virus signature database 5153 (20100528) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
A

Arved Sandstrom

tomo said:
I have three separate classes that calculate credit capability od client
depending on loan type. Can I use some design pattern (for example Strategy)
to write it more efficient ? Any suggestion ?

With all due respect, you might have wanted to ask that question before
you wrote code.

Having said that, what do you mean by more efficient? More performant?
Is it not performing well now? Or do you mean more maintainable? How is
it currently causing problems with maintainability? Or do you just want
to be able to hang a Design Patterns label on the code that you wrote?

For all I know, depending on your current implementation, 3 separate
classes each with completely different logic _is_ a good solution. I
have no idea how you are using them in client code.

AHS
 
D

Daniel Pitts

I have three separate classes that calculate credit capability od client
depending on loan type. Can I use some design pattern (for example Strategy)
to write it more efficient ? Any suggestion ?
Yes, Strategy sounds like a good fit for this problem.

I would start by making an interface that the three different classes
and all implement.
 
L

Lew

Daniel Pitts wrote, quoted or indirectly quoted someone who said :
Roedy said:
or classes that extend an abstract class. For rules of thumb on which
way to go, see http://mindprod.com/jgloss/interfacevsabstract.html

Your site makes interfaces sound so weak and useless, and provides some
misinformation regarding them.

For one thing, you say that only classes establish an /is-a/ relationship.
Something that implements an interface /is-a/ that interface.

You go so far as to state that at least for some implementations of an
interface, "[t]o them, your interface is only incidental, something that have
to add on to the their code to be able to use your package." Nothing could be
further from the truth, or more damaging to gaining the full power of
interfaces. There is nothing incidental about implementation of an interface.

Interfaces, in concert with generics, establish contracts and type structures
which force implementations to adhere, in a way that the compiler enforces,
thus preventing slews of bugs.

They provide that type safety and power while maximizing the flexibility to
adjust implementation in a controlled and tightly encapsulated fashion.

They permit code to focus on the type and essential limited range of behaviors
needed for a particular reference, without sacrificing the power of any other
interfaces or parent classes that the run-time type may inherit.

As Joshua Bloch pointed out in /Effective Java/, one should "[p]refer
interfaces to abstract classes" (Item 18 in the second edition).

You should read that chapter.

You make interfaces sound like a red-headed stepchild when they're actually
one of the most singularly powerful features of Java.
 
R

Roedy Green

Your site makes interfaces sound so weak and useless, and provides some
misinformation regarding them.

When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

You want me to prostrate myself and say I have sinned and an utter
idiot, unworthy to fetch you coffee, not just correct the entry.
Being a human, I will try very hard to find ways of avoiding doing
that.
 
R

Roedy Green

Your site makes interfaces sound so weak and useless, and provides some
misinformation regarding them.

When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

I exaggerate a little to say you want me to prostrate myself and
confess I have sinned and an am an utter idiot, unworthy to fetch you
coffee, not merely correct the entry. Being a human, I will try very
hard to find ways of avoiding doing that. You are not trying to
correct information so much as establish dominance. Get stuffed.
 
L

Lew

Roedy Green said:
When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

Good thing I didn't do that, then.
You want me to prostrate myself and say I have sinned and an utter

WTF?

idiot, unworthy to fetch you coffee,  not just correct the entry.

How do you ocnclude that?
Being a human, I will try very hard to find ways of avoiding doing
that.

Interesting. My post was entirely about the content of your site,
which contains some false and misleading information. There weren't
even any personal *remarks* in that post, much less an "attack". The
objective fact is that you provide some incorrect information and an
arguable conclusion is that you fail to properly represent the power
and optimal use of interfaces on your web site.

Every bit of information and comment in my post about your
representation of interfaces is useful to you if you have a commitment
to providing correct, helpful information. But you respond with ad
hominem remarks, fanciful analogy and an ivitation to "get stuffed".
WTF?

As I said, interesting.

In any event, set aside your obvious personal animosity and review
what you wrote, especially in light of the literature on best-practice
use of interfaces in Java (see that chapter in /Effective Java/, for
example), and think objectively if perhaps you might have misled
people somewhat there. What does it matter if I am odious and right,
if I am right?

(With apologies to Sophocles)
 
M

Mike Amling

Roedy said:
When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

In this case, I'm with Lew. We've all seen him make needless personal
attacks, but this was not one of them.
You want me to prostrate myself and say I have sinned and an utter
idiot, unworthy to fetch you coffee, not just correct the entry.
Being a human, I will try very hard to find ways of avoiding doing
that.

If you're deliberately trying to write an example how overstating your
case leads to loss of credibility, you've succeeded.

--Mike Amling
 
A

Arne Vajhøj

When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

You want me to prostrate myself and say I have sinned and an utter
idiot, unworthy to fetch you coffee, not just correct the entry.
Being a human, I will try very hard to find ways of avoiding doing
that.

You have a very unprofessional approach to criticism.

Arne
 
A

Arne Vajhøj

When you overstate your case, and turn it into a personal attack, you
set a barrier to having your ideas entertained and acted on.

I exaggerate a little to say you want me to prostrate myself and
confess I have sinned and an am an utter idiot, unworthy to fetch you
coffee, not merely correct the entry. Being a human, I will try very
hard to find ways of avoiding doing that. You are not trying to
correct information so much as establish dominance. Get stuffed.

He told you what the problems were.

You fix them - after all it is your pages.

Arne
 
C

ClassCastException

Interesting. My post was entirely about the content of your site, which
contains some false and misleading information. There weren't even any
personal *remarks* in that post, much less an "attack". The objective
fact is that you provide some incorrect information and an arguable
conclusion is that you fail to properly represent the power and optimal
use of interfaces on your web site.

Every bit of information and comment in my post about your
representation of interfaces is useful to you if you have a commitment
to providing correct, helpful information. But you respond with ad
hominem remarks, fanciful analogy and an ivitation to "get stuffed".
WTF?

WTF indeed. Nice PKBs here from the both of you.
What does it matter if I am odious and right, if I am right?

Roedy does have a point, though, that people are less willing to read and
accept what you have to say if you are "odious and right" than if you're
non-odious and right.
 
L

Lew

Roedy does have a point, though, that people are less willing to read and
accept what you have to say if you are "odious and right" than if you're
non-odious and right.

Let's see. I took a technical essay about Java and discussed its technical
details, in a forum devoted to the discussion of Java technology.

How odious that is!

Roedy only had a point if he was discussing something that actually was odious.

I find it odious to hawk your web site as though it were the be-all and
end-all of Java information and then put misinformation and bad advice in it.
I find it especially odious for someone to get all snarky when someone else
goes to the trouble to present a technical viewpoint on that bad technical
information in a forum devoted to doing just that. I find it very odious for
someone to present themselves as a great help to the new Java programmer only
to give them advice that will make them worse Java programmers.

The fact is that interfaces are one of the linchpins of Java programming and
not incidental or dilatory in any way. Let's not lose sight of the real point
here in the midst of all your mud-flinging.
 
C

ClassCastException

Let's see. I took a technical essay about Java and discussed its
technical details, in a forum devoted to the discussion of Java
technology.

I was responding solely to your comment "What does it matter if I am
odious and right, if I am right", and not to the larger debate.

With respect to the larger debate, I agree with you re: the importance of
interfaces.

Clarified?
 
A

Arne Vajhøj

Let's see. I took a technical essay about Java and discussed its
technical details, in a forum devoted to the discussion of Java technology.

How odious that is!

Roedy only had a point if he was discussing something that actually was
odious.

I find it odious to hawk your web site as though it were the be-all and
end-all of Java information and then put misinformation and bad advice
in it. I find it especially odious for someone to get all snarky when
someone else goes to the trouble to present a technical viewpoint on
that bad technical information in a forum devoted to doing just that. I
find it very odious for someone to present themselves as a great help to
the new Java programmer only to give them advice that will make them
worse Java programmers.

The fact is that interfaces are one of the linchpins of Java programming
and not incidental or dilatory in any way. Let's not lose sight of the
real point here in the midst of all your mud-flinging.

I would put it more briefly: if you don't have the time or the will
to put correct info on the web, then don't put any info on the
web - incorrect or misleading info is worse than no info.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top