Skip to main content

Posts

Showing posts from December, 2015

Observer Pattern : Real Life Example and Java Code Example

Observer Pattern The observer pattern defines a one to many relation between objects so that when one object changes state, all of its dependent or related objects get notified automatically Real Life Example: Group Chat is a real life example of observer pattern. Whenever someone type some text in text button and hit send button. Every member get notified that someone texted in group. Java Code Example: public interface Subject { void register(Observer observer); void remove(Observer observer); void notifyRespectedObserver(String msg); } public interface Observer { void update(String msg); String write(String msg); String getName(); } public class Console implements Subject { public List memberList; public Console(){ memberList = new LinkedList (); } public void register(Observer observer){ memberList.add(observer); } public void remove(Observer observer){ memberList.remove(observer); } public void notifyRespectedObserver(String msg){ for

Design Pattern : Real Life Example and Java Code Example

                      I n software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into the source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. - Wiki To explore the various kind of Design Patterns follow the below links. ----------------------------------------------------------------------------------------------------------------- Observer Pattern ----------------------------------------------------------------------------------------------------------------- Proxy Pattern ----------------------------------------------------------------------------------------------------------------- Builder Pattern ----------------------------------------------------------------------------------------------------------------- Singleton P

How to Restore the Original Storage Capacity of Pen Drive

                      I n the following post we will see how to restore the actual storage capacity of your pen drive. Sometimes it happens that your pen drive show smaller storage capacity than original storage capacity. For example If you have a 8 GB pen drive which has original storage capacity of 7.18 GB but now it is showing total space 4.32 GB. Usually it happens when you make your pen drive bootable for linux or other Operating Systems or your pen drive got older. To get back your pen drive with original storage capacity you need to do following things: 1) Mount your pen drive into windows operating system 2) Open cmd as administrator 3) Execute following command in the cmd C:\\Windows\System32>diskpart your cmd will change C:\\Windows\System32> to DISKPART> Now type the below command: DISKPART>list disk It gives the list of all disk partition and available devices along with index(start with 0) like Disk 0 Online 298