Francesco Bianchi

Ranch Hand
+ Follow
since Jun 22, 2007
Merit badge: grant badges
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Francesco Bianchi

Try have a look at this: Explanation.

I've found the explanation pretty long but nevertheless insufficient in properly clarifying the real point. Try to think a bit about it and if you are still in troubles I will give you my personal interpretation.

Little hint for the next time you are in such troubles: let Google help you finding out if someone has already solved an exactly identical puzzle.

And about the 0.6 mistery: you could have used any number between 0.5 and 1.0 instead and the effect would have been the same. It's only purpose is to set the size of both the TWO arrays big enough so that their sum exceeds the total system memory (0.6 + 0.6 = 1.2). I've not tried but I think tha tin reality 1.0 would have been a little too much for instantiating even only the first array as long as some memory is occupied by your test class too... (in fact the snippet blows also setting the parameter to 4.5)

13 years ago
Great score. Congrats!
14 years ago
Thank you Madhuri for answering me. Now I'm even more nervous than before...but I'll try as well
14 years ago
A servlet is first of all a class. As every class it must be instantiated before being used (that is the constructor is called).

Once instantiated, a Servlet still needs to do some operations to be able to act as a Servlet. At minimum it has to have access to its own ServletContext instance. That is injected by the container during initialization phase, usually right after it has been instatiated. That is also the point where you should put all your "run-once" code.

So: you define a class which happens to be a Servlet. To use it you first have to get an instance (constructor()), then to teach it what it needs in order to act as a servlet (init()) and only at that point you can make it properly work (by calling service() method)

If you look through Servlet interface you will find 2 init() methods...

But I think now you can go back to the optimus HFSJ, Chap. 4
14 years ago

I'll take the test in 10 days but I don't feel enough prepared. I get very different percentages depending on the mock I'm taking. Have you ever calculated your on HFSJ mock? If yes, could you please tell it?

Thanks in advance,
14 years ago
Outstanding scoring!!

And thanks for the advice, I will give a try to the SCWCD package then
14 years ago
Not yet Ismael

Please read again the following statement:

Originally posted by Stevi Deter:

B and TestClass are not in the same package as Object, so they cannot see the protected java.lang.Object.clone() member that is inherited by A through extending Object.

Horri quoted a sentence from K&B but dispite I find that book marvellous, I think it's not enough clear on this point. Try to read: whereas a protected member can be accessed (through inheritance) by a subclass as whereas a protected member can be accessed (through DIRECT inheritance) by ITS FIRST subclass (To be honest, they point this clearly out some lines after)

Moreover, if you read the last sentence well, you can see that protected members are just defined as VISIBLE and not as INHERITED as most think.

In your hierarchy, A comes right after Object. All the subsequent subclasses have to pass through A to reach Object members. And as long as both A, B and TestClass are in a different package from Object, A is THE ONLY class allowed to SEE protected Object members. But still A doesn't have a clone() method. It can just use it.

IF (but only IF, and this is NOT the case) all the four classes where in the same package (A, B, TestClass and A's ancestor), you example could work.

Hope it's clearer now.
[ April 27, 2008: Message edited by: Francesco Bianchi ]
As stated also in HFSJ, MVC pattern is kind-of extension of business delegate pattern in the sense that uses the same principles, have the same benefits but adds much more flexibility on the navigation side in change of increased development costs.

In general, there is not a best choice: it depends in fact on the use cases you collected by your users.

If talking about both web and application clients, I think that MVC is a safer choice. Web and client applications are very different regarding the way they can communicate with a server, I would say almost the opposite. You cannot be sure that the methods implemented having the web model in mind can work correctly if piloted by an application client.

To make the 2 models act in a reasonably similar way you should add so much overhead that you could lose the benefits of a lighter model as business delegate.

Moreover MVC let's you control navigation on the server side while a simple Business Delegate just has to wait for a request forcing you to put all the navigation logic on the clients.

At least, in my opinion
be so nice to post indented code and, most of all, code which compiles (the first 2 lines cannot).
14 years ago
Hello Joseph,
I think you could find an answer by looking at the Observer (also known as Listener in Java world) pattern.
In your case the outer class could register to an inner one as an Observer. When some special events occurs, the inner (observed) class would just notify all its listeners (i.e. the outer class) about it. It would then be a problem of the Listener deciding what to do.

Some benefits you could obtain are:
  • a more readible (and maintanable) code
  • a more correct assignement of responsabilities to classes
  • now you would be 3 to have the three class definitions in 3 different files (that would help readibility and reuse)
  • you don't have anymore a bunch of uncontrolled threads tryng to concurrently access and modify the same couple of variables

  • If you need some examples from the Masters look into Swing code. It is heavely based on Listener pattern.
    [ April 26, 2008: Message edited by: Francesco Bianchi ]
    14 years ago
    Thank you Stevi. You and B T R are right.
    I have been so stupid not to even read the word "ServletException" in answer (2). I apologize for my oversight.
    I think Savitha is having some problems with understanding polymorphim. In particular the case where you pass an instance of B to a reference of type A (assuming B extends A) to call a method both classes implements.

    Am I right?
    I'm sorry, I don't really agree this is so obvious.

    The resons I can give you are basically two:
  • For same very strange business rules, I could decide to force the error code of my response to be 404 even if a resource has been found
  • HTTP specs are out since a certain bunch of time...ok.. But what if in a future version the 404 code changes its meaning? I think there is a reason if it's saved somewhere as a public static final int... And that not only to attach it a label to clarify its meaning...

  • By the way.. I tried a Marcus mock 1 hour ago and did same mistake as V Gala