This question I got from net, in a document which is having some questions. I may be confused or not satisfied with the answers which are given in this document with other questions also.
But right now I'm studying Design Patterns, and I got this problem confusing.
Q: Compact Computers is a small computer assembly company. Its online application allows customers to pick and choose accessories to build their own PCs. The accessories are: i. Processor - 800Mhz, 1Ghz, 1.2Ghz ii. HDD - 40 GB, 60 GB, 80 GB iii. Memory - 128 MB, 256 MB, 512 MB Customers choose parts and quantities during the order. For example, a customer could choose a second HDD as a secondary hard drive or purchase additional RAM. What design pattern may be optimal for implementing a suitable design here? A Factory Method B Prototype C Singleton D Template Method E Business Delegate F Builder
Ans given is B.
In the first sight it looks like the computer product creation problem. But solution this problem asking for the creation of the products like HDD RAM and Processor and not the computer. Thats why answer given is PROTOTYPE. And the explanation they have given is "Prototype (GOF 117)"Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype." In this example, the key is that using prototypical instances (for Hard Drives and RAM), you can create multiple instances of the required part. Hence choice B is correct."
Now there are two doubts first is to identify that the problem which we need to hit is the creation of product like HDD RAM but not the computer.
Second: Even if we assume that we somehow find out that we need to find the answer for the HDD and RAM creation, still the question gives scenario that we may need to create more then one object of these type to assemble a Computer. And these objects are not in third party API or very complex to create. So, why I'll use Prototype pattern. As it is specified in the question that type of these products are going to be constant (40/60/80GB HDD). So, I would be having three sub type of HDD interface / abs. class as HDD40GB etc. and create the instances as per the user selection's product and its quantity. And add these objects in the Computer one to assemble it.
Because Prototype pattern applies when: The classes to instantiate are specified at runtime. ■ You need to avoid building a class hierarchy of factories that parallels the hierarchy of objects. ■ Instances of the class have one of only a few different combinations of state.
But I didnt find any applicability to this situation.
Can any body please help me out to solve my two doubts.
You are correct, I never understood the question was focused on computer components and not the computer itself.
And in the other scenario you mention I found the Builder pattern to be the best match. It's used for creation of complex objects and a computer configuration can be perceived as such. Once the user has chosen what components he wants (and this indeed can be Prototype) a ConcreteBuilder can be created and the Director invokes corresponding methods and vo�la...
As you can see, in my opinion, Prototype can be a valid choice in both cases you mention. In the second case, you should choose between Prototype and Builder. What is the question? What is the best choice for that question? I have no idea. :roll:
Anyway, this is just a mock and they're known for not being too reliable (it's one of the 288 questions, right?). I'm just hoping the exam is more clear on what the questions are.
Manish S Malhotra
Joined: Jan 19, 2007
Thanks Bojan for your time.
Yes, its from one of the 288 questions. Have you solved those questions, and how much you find the reliability of the answers in that doc. I'm concerned about the type of questions comes in the actual paper.
Have you already given Part I, or going to appear. How you are preparing for the scenario based questions for EJBS/ Architectures / Design Patterns etc.
If you can share your experience on these topics also then it would be great.
Joined: Nov 20, 2003
I have not given the first part but I expect to do so in a 10-15 days (I'm terribly short with time these days). If you still need the answers by that time I will let you know about my experience.
Regarding the materials, for EJB's I used Head First to repass it, for Design Patterns GoF book (very good!) and for Common Architectures I couldn't find anything better than the Paul Allen's book. Actually I find it quite interesting except that it has A LOT info not needed on the exam (I think). But as my goal is not only to prepare for the exam it's not too bad.
And of course, all the notes you can find here or on the yahoo groups.
Manish S Malhotra
Joined: Jan 19, 2007
Does the Head First EJB also helped you to answer the scenario based questions which are asking to use EJB's.
I have studied Richard Monson-Haefel and little bit Ed Roman.
And please share your answers also with me as you said.
Thanks for your time.
Joined: Nov 20, 2003
I took the first part this morning and I scored 89%.
Regarding the design pattern questions - they are VERY easy (or at least they were in my case - I scored 100% there). They are much clearer than the mocks and as far as I could see, there were no "gray areas" - i.e. no cases where you can apply two or more of the listed ones.
I got five negatives, I guess they were mostly scenario based ones. I had read posts of the people saying there are some questions that are difficult to understand or not clear but I supposed Sun had already taken care of that. Well - obviously they did not.
I can say that my English is fairly good but there were at least two or three question where I did not understand the scenario. One was VERY confusing and it didn't even include any of the "special" things - pure design and common sense. I bet I missed that one!
The time was not a problem as 75 minutes were more than sufficient in my case. I even could re-pass the whole test two times.
So, off to the second part now. I wish you luck! And prepare some mind reading techniques!
Manish S Malhotra
Joined: Jan 19, 2007
Congrats Bojan Its party time for you until you start your next part
I would be giving Part I in the coming week ( well most probably).
Thanks a lot for your detailed experience of the exam and the questions related to Design Patterns and scenario based questions.
Can you please tell me more about the topics like EJB, Security, Legacy Connectivity, Corba/IIOP and Internationalization. Because I found most confusing questions are from 1. Security 2. Corba/IIOP, RMI, JRMP etc.
Even I have studied the chapter of protocol from Marc Cade book. One of the practice question which is Question No. 5. If you read the solution of that questions, few things which is written are not there in the question even, like the technology used is Java. And the biggest problem with that question is to identify that we need to use Distributed Computing or just thin client + server type of architecture. For this also I'm not able to find out from the question. If you did that question can you please help.
I think 2nd is correct because in EJB 1.1 specs, I have not found any thing about JRMP, and it was supported in EJB1.0 version.
Q2: Is it possible to specify the number of EJB instances to pool during deployment time? 1. True 2. False
I think it is FALSE, if we think in terms of only EJB1.1 specs. Because it wont tell where and how to specify the number of instances of EJB in the pool. But if we consider vendors then all the App Servers provide way to specify this number. I�m confused for the right one.
Q3: Which is a very ambiguous one (as per me ): Scenario Based
Scenario: ATMEJB has method withdrawal() with Required Tx attr. and it is calling AccoutEJB getAccount() method. At the same time ChecqueProcessingEJB is calling AccountEJB getAccount() without any Tx context.
The algorithm of getAccount() is as follows: 1. Deduct the amount from the account balance 2. Calculate Interest 3. Update history 4. Return the requested amount to the caller
Q: What best describes the AccountEJB component?
A. Stateless Session Bean with RequiredNew Tx attr. for getAccount() B. BMP with Required Tx attr. for getAccount() C. CMP with Supports Tx attr. for getAccount() D. CMP with RequiredNew Tx attr. for getAccount()
I choose option A, as AccountEJB is doing many things it looks like Facade and Transaction is required for getAccount().
But the answer given in the mock is D. They given detailed reasons but all on the assumptions.
Two things I want to ask 1. Can we use Required in this scenario for getAccount(), if not then why? 2. What I'm not able to understand is getAccount() doing the database related activity or just playing with the object as data. One thing is sure either it has to populated account related data from the DB at the client request either by SessionBean or finderMethod of the EntityBean. Even if we assume somehow that its an Entity Bean, but still the problem is that its doing too much things in one method whether entity beans needs to only return the DB state. Is the statement "at the same time" some other bean is also accessing means that its an shared component which is part of the definition of the Entity Bean (shared data). So, from this we can firmly say that AccountEJB is an Entity Bean, irrespective of the business logic is put in its method. So, here the case is to handle shared data when concurrent users are accessing it. But can't this be handled by SLSB also by using the Tx context and with correct Isolation Level. So, that the other Tx. have to wait for the data until it is used by the current Tx. (locks depends on the Isolation level).
I know I think I have written, but it was required to spit out whatever I'm thinking to correct myself :roll: .
One interesting statement you have used "And prepare some mind reading techniques!" Do you mean from that to read the minds of the examiner to crack the Scenario based questions?
As it is specified in the question that type of these products are going to be constant (40/60/80GB HDD). So, I would be having three sub type of HDD interface / abs. class as HDD40GB etc. and create the instances as per the user selection's product and its quantity.
I do not think that we need multiple sub type in this case; since it includes change in properties value only; and no funtional change. e.g. if a car company has 10 colors for a specific car (model); it need not to have 10 sub types.
subject: Design Pattern: Confusing Questions !! Please help in answering....