Aakhri Jung!
5 posters
Page 1 of 3
Page 1 of 3 • 1, 2, 3
Re: Aakhri Jung!
(a) Allow users to scan over and access the elements of a collection without knowing the underlying representation of the collection.
(b) You are tasked with designing an application for scheduling a conference room. This process uses web services from the facilities team for heating, IT team for audiovisual and with security to grant access to the rooms at the booked time. However, to save employees time you create simple interface which takes care of this in the background. What pattern is used here.
(c) You are designing a web interface for both computers and mobile devices. Depending upon the type of the device, appropriate interfaces for the underlying platform should be invoked.
(d) A design pattern that requires making the constructor private.
(b) You are tasked with designing an application for scheduling a conference room. This process uses web services from the facilities team for heating, IT team for audiovisual and with security to grant access to the rooms at the booked time. However, to save employees time you create simple interface which takes care of this in the background. What pattern is used here.
(c) You are designing a web interface for both computers and mobile devices. Depending upon the type of the device, appropriate interfaces for the underlying platform should be invoked.
(d) A design pattern that requires making the constructor private.
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
(a) Allow users to scan over and access the elements of a collection without knowing the underlying representation of the collection.
iterator
(b) You are tasked with designing an application for scheduling a conference room. This process uses web services from the facilities team for heating, IT team for audiovisual and with security to grant access to the rooms at the booked time. However, to save employees time you create simple interface which takes care of this in the background. What pattern is used here.
facade
(c) You are designing a web interface for both computers and mobile devices. Depending upon the type of the device, appropriate interfaces for the underlying platform should be invoked.
template
(d) A design pattern that requires making the constructor private.
singelton
iterator
(b) You are tasked with designing an application for scheduling a conference room. This process uses web services from the facilities team for heating, IT team for audiovisual and with security to grant access to the rooms at the booked time. However, to save employees time you create simple interface which takes care of this in the background. What pattern is used here.
facade
(c) You are designing a web interface for both computers and mobile devices. Depending upon the type of the device, appropriate interfaces for the underlying platform should be invoked.
template
(d) A design pattern that requires making the constructor private.
singelton
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
b)You are developing a game, and your task is to change an actress's physical positions based on her previous conditions. For instance, If actress is standing, and user presses "Up", she should jump. If in same position user presses down she should sit. If actress is sitting, and user presses "Up", she should stand up. What design pattern should be used here. STATE
(c) We are building Taypals add a payment option feature. A user can add a credit card, debit card, or bank account. The processing steps differ depending on the given payment option. ABSTRACT FACTORY
(c) We are building Taypals add a payment option feature. A user can add a credit card, debit card, or bank account. The processing steps differ depending on the given payment option. ABSTRACT FACTORY
Re: Aakhri Jung!
) In the future, you are implementing a system for time travel. It is to allow you to travel to any era for your life, and later, you can return to the present, or to another era you have been to. Once you return, everything is as it was when you left.
memnto
(b) Here is a physical analogy to a design pattern. Which pattern? When you call Microsoft tech support, you deal with a Level 1 consultant. If (s)he cant answer your question, eventually you are routed to a Level 2 consultant. If this consultant cant answer your question, you are transferred to a Level 3 consultant.
chain of responsibility
memnto
(b) Here is a physical analogy to a design pattern. Which pattern? When you call Microsoft tech support, you deal with a Level 1 consultant. If (s)he cant answer your question, eventually you are routed to a Level 2 consultant. If this consultant cant answer your question, you are transferred to a Level 3 consultant.
chain of responsibility
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
auto.print(auto);
auto.print(sedanAuto);
auto.print(sedan);
sedan.print(o);
sedan.print(auto);
sedan.print(sedan);
auto.print(sedanAuto);
auto.print(sedan);
sedan.print(o);
sedan.print(auto);
sedan.print(sedan);
Re: Aakhri Jung!
//in the MoneyConverter class
public Money convertTo(Money money, Currency to) {
if (money instanceof SimpleMoney) {
SimpleMoney simpleMoney = (SimpleMoney) money;
long newAmount = simpleMoney.getAmount() * getRate(simpleMoney.getCurrency(), to);
return new SimpleMoney(newAmount, to);
}
else {
MixedMoney mixedMoney = (MixedMoney) money;
long totalAmount = 0;
for (Currency currency: mixedMoney.getCurrencies()) {
long currentAmount = mixedMoney.getAmount(currency);
totalAmount += (long) (getRate(currency,to) * currentAmount);
}
return new SimpleMoney(totalAmount, to);
}
}
(a) (2 points) What principle or pattern is violated if the convertTo(...) method is implemented (only) in MoneyConverter?
Expert pattern
(b) (2 points) When different kinds of Money objects (SimpleMoney, MixedMoney) are being added together, which design pattern could be used to avoid checking the class of the object that is being added? Your answer should be the name of a design pattern; it should not involve a tree format for representing money.
visitor
public Money convertTo(Money money, Currency to) {
if (money instanceof SimpleMoney) {
SimpleMoney simpleMoney = (SimpleMoney) money;
long newAmount = simpleMoney.getAmount() * getRate(simpleMoney.getCurrency(), to);
return new SimpleMoney(newAmount, to);
}
else {
MixedMoney mixedMoney = (MixedMoney) money;
long totalAmount = 0;
for (Currency currency: mixedMoney.getCurrencies()) {
long currentAmount = mixedMoney.getAmount(currency);
totalAmount += (long) (getRate(currency,to) * currentAmount);
}
return new SimpleMoney(totalAmount, to);
}
}
(a) (2 points) What principle or pattern is violated if the convertTo(...) method is implemented (only) in MoneyConverter?
Expert pattern
(b) (2 points) When different kinds of Money objects (SimpleMoney, MixedMoney) are being added together, which design pattern could be used to avoid checking the class of the object that is being added? Your answer should be the name of a design pattern; it should not involve a tree format for representing money.
visitor
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
Not sure. Verify
Car, Mustang, Wheel
There is both an is-a and a has-a relationship between/among these classes
Car, wheel
Person, Veteran, Teacher
There is an is-a relationship between/among these classes.
Person
List, ArrayList, LinkedList
There is an is-a relationship between/among these classes.
List
Car, Mustang, Wheel
There is both an is-a and a has-a relationship between/among these classes
Car, wheel
Person, Veteran, Teacher
There is an is-a relationship between/among these classes.
Person
List, ArrayList, LinkedList
There is an is-a relationship between/among these classes.
List
Re: Aakhri Jung!
public
Money
convertFrom(
Money money
, Currency to) {
long newAmount =
money.getAmount
() * mc.getRate(
getCurrency
(), to);
return new SimpleMoney(
newAmount
,
to
);
}
Money
convertFrom(
Money money
, Currency to) {
long newAmount =
money.getAmount
() * mc.getRate(
getCurrency
(), to);
return new SimpleMoney(
newAmount
,
to
);
}
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
class Rectangle {
public:
double getHeight();
void setHeight(double h);
double getWidth();
void setWidth(double w);
};
A Square is made a subclass of Rectangle.
Does the above scenario violate the Liskov Substitution Principle? YES
public:
double getHeight();
void setHeight(double h);
double getWidth();
void setWidth(double w);
};
A Square is made a subclass of Rectangle.
Does the above scenario violate the Liskov Substitution Principle? YES
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
The Bridge pattern decouples a set of implementations from set of objects using them.
There is high coupling between observer base class and subject.
Proxy implements a different interface than the interface implemented by the object it is serving as a proxy for.
There is high coupling between observer base class and subject.
Proxy implements a different interface than the interface implemented by the object it is serving as a proxy for.
piefgpi- Posts : 8
Join date : 2016-04-29
Re: Aakhri Jung!
(i) List, ArrayList, LinkedList
a
list
(ii) Car, Mustang, Wheel
c
car wheel
(iii) Person, Veteran, Teacher
a
person
maybe this is right.. not too sure
gorydog- Posts : 10
Join date : 2016-04-29
Re: Aakhri Jung!
-The Bridge pattern decouples a set of implementations from set of objects using them.
-Using this pattern, Subjects and Observers can push messages back and forth.
-Proxy implements a different interface than the interface implemented by the object it is serving as a proxy for.
-Using this pattern, Subjects and Observers can push messages back and forth.
-Proxy implements a different interface than the interface implemented by the object it is serving as a proxy for.
Re: Aakhri Jung!
public
Money
convertFrom(
Money mc
, Currency to) {
long newAmount =
mc.getAmount
() * mc.getRate(
mc.getCurrency
(), to);
return new SimpleMoney(
newAmount
,
to
);
Money
convertFrom(
Money mc
, Currency to) {
long newAmount =
mc.getAmount
() * mc.getRate(
mc.getCurrency
(), to);
return new SimpleMoney(
newAmount
,
to
);
piefgpi- Posts : 8
Join date : 2016-04-29
Re: Aakhri Jung!
Different responsibilities should be divided among different objects.
Encapsulation: One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes
Expert pattern: The object that contains the necessary data to perform a task should be the object that manipulates the data
The DRY principle: Code should not be duplicated
Design your classes so that they can handle change
Code to interfaces, not classes
Encapsulate the concepts that vary
Give classes a complete interface
A well-formed class has a consistent interface
a) 1,4
b) 1,2
c) 2,6
Encapsulation: One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes
Expert pattern: The object that contains the necessary data to perform a task should be the object that manipulates the data
The DRY principle: Code should not be duplicated
Design your classes so that they can handle change
Code to interfaces, not classes
Encapsulate the concepts that vary
Give classes a complete interface
A well-formed class has a consistent interface
a) 1,4
b) 1,2
c) 2,6
sasti_randi- Posts : 14
Join date : 2016-04-29
Re: Aakhri Jung!
You are developing a game, and your task is to change an actress's physical positions based on her previous conditions. For instance, If actress is standing, and user presses "Up", she should jump. If in same position user presses down she should sit. If actress is sitting, and user presses "Up", she should stand up. What design pattern should be used here.
STATE
STATE
ledzep93- Posts : 9
Join date : 2016-04-29
Re: Aakhri Jung!
(a) What would be a good precondition for y = arcsin(x)?
-1≤x≤1
(b) What would be a good postcondition for the method? Note: The postcondition should involve sin.
sin y = x
(c) What is the obligation for the client in using the arcsin method?
-1≤x≤1
(d) What is the benefit for the client in using the arcsin method?
sin y = x
(e) Suppose we wanted to incorporate the precondition into the postcondition. Give the new postcondition.
e nahi aaya
-1≤x≤1
(b) What would be a good postcondition for the method? Note: The postcondition should involve sin.
sin y = x
(c) What is the obligation for the client in using the arcsin method?
-1≤x≤1
(d) What is the benefit for the client in using the arcsin method?
sin y = x
(e) Suppose we wanted to incorporate the precondition into the postcondition. Give the new postcondition.
e nahi aaya
Page 1 of 3 • 1, 2, 3
Page 1 of 3
Permissions in this forum:
You cannot reply to topics in this forum
|
|