glass
pen
clip
papers
heaphones

Oklahoma Christian University Design Patterns Discussion

Oklahoma Christian University Design Patterns Discussion

Description

Pattern Notebook: Add Singleton, Command, Adapter and Facade to Pattern Notebook, submit your new notebook as part or tnis assignment.

What is the potential problem with Singleton related to threads?

2. Instead of a special pattern for a single instance of an object, why not just make a class in which all variables and methods are static (thus ensuring that they all exist in one shared space no matter how many instances are created)?

What are the problems with subclassing a singleton class?

Of the key principles we’ve discussed so far, which ones do the Command pattern implement?

5. Compare and contrast the Facade and Adapter pattern.

Review the “Fireside Chats” between Decorator and Adapter Pattern (on page 252-252 in chapter 7 of the older text). Summarize the main points being made (don’t just copy the chat text, think about what each “line” for the Decorator and the Adapter are saying and summarize in your own words

7. You have a class that manages an IP Packet. The IPPacket class contains either a UDP class or a TCP class object.

Each of the UDP and TCP Class objects have unique methods such as “Getsize()”, or “GetCheckSum()”. TCP has some other unique ones like “GetLastByteSentO”.

What is wrong with the following code? How would you change the TCP and UDP classes to fix the problem

seen here?

IPPacket pkt1, pkt2;

UDPPaCket uap;

TCPPacket tcp;

Prtl.setPavload(tco):

Pkt2.setPayload (udp);

lastByte = pkt1.getPayloadObject () .getLastByteSent ();

SIze = pkt.getPayloadObject () .getsize () ;

8. Define the “Principle of Least Knowledge”

How does the Fa├žade pattern help you follow the Principle of Least Knowledge?