Eyal Golan

Greenhorn
+ Follow
since May 20, 2008
Merit badge: grant badges
For More
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 Eyal Golan

OK,
I guess I need to clarify things.
What I am actually trying to do is a sequence of calls to the web.
I am using Apache HttpClient library.

The purpose of the module is to simulate a sequence of calls (GET and POST).

So the sequence is something like:
Call a URL and parse the result.
If status result is 200 - call URL_A
else if status 302- call URL_B
else finish with error

Then, the same procedure (probably with different if / else) for URL_A
etc.

My solution was:
Each call to URL (I know exactly the options that will be in the sequence) is represented in a class.
All of them inherit a base abstract class. they have a method 'execute'.
In the execute, each class execute the POST (or GET) , parses the response and create the next class accordingly.

There is a Manager class with 'next' method that the operation classes call it with the next class as parameter.
Manager also has method like: error, parseResult (the last operation calls it).

I want to put the design I created on some charts, but it may take me some time due to high pressure at work

So,
what do you think?
Thanks David,
but I'm not sure though.

You see, I have well, "conditional chain of responsibility".

Maybe I my DP is a mix of chain and state...
Hi,
I have a code that I want to refactor to be better maintainable and readable.
The code is like a sequence of operation.
Each operation return result, if the result is XXX, then doing the next operation.

I developed the code quick and dirty to check things, and now I want to make it better.
The current solution takes consideration only in success sequence.

The code is something like that:

Result r1 = app.doA1();
if (r1.status==1) {
Result r2 = app.doA2();

etc.


I am going to extract all the 'doA#' methods into classes.
Each class will process and return the next class or, if error, then will trigger a method from a centralized class.

After this long intro
I am sure there is a suitable design pattern for that (State???)
I want to build the code correctly.

Any suggestion will be gladly taken.

Thanks

Avishkar Nikale wrote:Can we say that a method objective should dictate the same?

1) Lets say a factory class depending on various conditions creates a object
& assigns it to the return reference.
The return statement usually is at the end of the method.
2) If it is a execution of a business process it might make more sense to return if the
process cannot continue further.

? ? ?



True,
but in my situation EVERYTHING has one exit point, even situation like your second remark.
(but hey, you're encouraging me to do it the way I prefer...)
13 years ago

Rob Prime wrote:I generally disagree with using only one exit point. However, I also agree in adapting to the project style. If that style is one exit point I would force myself to adapt.


Rob Prime wrote:As Robert C.Martin would say clean code reads like well-written prose.



Yes I agree with you all..
I thought that maybe someone will encourage me to do it differently
13 years ago
Hi all,
I'm not sure if this is the right forum, but the question is relevant to any java (or other language) programmer.

There is the old debate on how many exit point should a method have?
I think that a method should exit the minute it know it can.
Others think that it should exit only in one location.

I don't want to open this discussion.

I have a different situation, I've recently inherited a project that is in a very early stage.
The guy you developed it before, had a convention of one exit point.

Now, should I continue with his convention, or whenever I write new functionality (method), I can use mine?

What do you think?
13 years ago
Hi Gian,
I know about these tools.
Haven't tried them yet.
It look like HttpUnit is the one I need.

Thanks
13 years ago
Hello all,
I've started working on an application that uses hibernate.
The mapping uses xml (the *.hbm.xml files).

I am considering moving to annotations instead.
By moving to annotations, I mean that for new tables I will use it instead of the hbm.xml.

now, I'm not sure I should, and would happily get your insight.
The main reason on NOT doing that is that I will have mixed metadata mapping, which may cause development hell.

moving the old ones to annotations is another possibility, but a dangerous one (I need to set many unit test before).

And actually, the first question, should have been: can I even mix the two ways of mapping?

Thanks
Hello all,
I've just started working on a very new project that consists as the entry points for the clients web application with servlets.
The data that is transferred is XML and I added a filter that set it (a long with other things).

In order to check that things work, I added to Firefox the Poster plugin. With it, I am putting the correct XML, press POST and see that the correct XML is in the response.

Is there a way of doing so by programming (say I want to add JUnit that does it).
HTTPClient / HTTPPost , others. ?

Thanks,

Eyal
13 years ago
Thank you all for the answers.

Paul Clapham wrote:...However if you use a StringBuilder instead of a String to combine the parts, you will find it has an append() method which is perfect for the parameters of the characters() method. It would be better to do it that way.


Thanks for reminding me the StringBuilder. I used the String tempVal as this is what was before...

And again, thank you all
Hello all,
I've just started working on a new project and I encountered an XML parsing problem.
A (very) short description of the project's design:
There is a servlet that accepts XML and passes it to a handler to process.
Everything is in UTF-8 encoding.

The problem is in that handler:
Suppose I have something like the following:

the characters method of the DefaultHandler seemed to split that value and actually was called 3 times.

The original code (which I started working on) had a string that was set in characters method:

It was initialized to empty string at the beginning of startElement method.
Then, in endElement, tempVal was used to build the domain objects.

I created a small JUnit test and found a solution.
The solution is to concatenate that tempVal in characters method.

I would like to consult you if this is the correct one, or is there a better one.

(Forgive me for the long post, as I wanted to be as clear as possible).
Here's the code (i could not attach a java / text file)



well, my question can be also:
Is there a way to set the way the parser works so it won't split the '&' ?


Thank you very much for any help
In Pragmatic Programmer, item 5, they suggest to extend your knowledge portfolio.
I guess I will take Coders to be one of the next technical books to read
14 years ago
Hi,
I am looking forward to reading this book.
I am currently reading the Pragmatic Programmer and I believe that Coders @ work is a great opportunity to make me a better developer.

and my question:
Do you describe in the book how it was done? Have you actually interviewed or looked behind the shoulders of the participants?

Thanks
14 years ago
Thanks Ulf.
I'm looking into it.
It's a topic I haven't worked with it yet.
14 years ago