3

I'm currently preparing to take my Magento Certified Developer test next Tuesday. A couple of the practice tests I have encountered have the following question:

Which object never encapsulates any shopping cart items?
A. Mage_Checkout_Model_Cart
B. Mage_Sales_Model_Quote
C. Mage_Sales_Model_Quote_Address<type=shipping>
D. Mage_Sales_Model_Quote_Address<type=billing>
Answer: B

Why would that be the correct answer? Mage_Sales_Model_Quote has shopping cart items that are associated with it ($_items property, getAllItems() and getItemsCollection() methods). Perhaps I don't properly understand what is meant by encapsulation - what would be the meaning of encapsulation in this context?

2 Answers 2

4

(B) makes the least sense. (A), (C) and (D) all give transitive access to shopping cart items through getQuote()->getItemsCollection(), but the quote itself (B) is the object that encapsulates the item collection.

To me that looks like there's a mistake in the practice question and the "never" should not be there.


About "encapsulation": In software development this is related to information hiding and usually refers to private properties.

2
2

I'm not a native english speaker but to me here "encapsulate" means "contain".

I think the answer to this question is Mage_Checkout_Model_Cart. As you can see from this class, it never encapsulates any shopping cart items but it encapsulates quotes (from Mage_Sales_Model_Quote) which themselves encapsulates shopping cart items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.