Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > Application Design > Design Patterns

Design Patterns - Page 2

21-40 of 79     Previous     Next
Interface Usage
by DevX Pro
In designing a program, how do I know when to use an interface or a class? Is there a basic rule to follow?
Create an Array of Functions in Java
by Behrouz Fallahi
Java doesn't offer direct support for pointer to functions. But this ...
C++ abstract classes
by DevX Pro
What are Abstract Classes? Please explain with an example.
Avoid Empty Exception Handlers
by Ajit Sagar
One of the most frustrating experiences when running a Java program is an empty line where you expect information about a thrown exception. The programmer probably meant to catch the exception but ...
Visual C++ Check/Radio Buttons
by DevX Pro
How does one go about disabling/enabling buttons and check boxes in dialogs based on the state of other buttons or check boxes? The controls in question are of the MFC class CButton and are created as part of a CDialog object.
Enhance Performance Using the Reference Counting Idiom
by Danny Kalev
Under some circumstances, the reference counting model can enhance performance in terms of both memory usage and speed. A reference counting class counts how many object instances have an identical ...
The "Big Three Rule" or the "Big Two Rule"?
by Danny Kalev
The famous "Big Three Rule" says that if a class needs any of the Big Three member functions (copy constructor, assignment operator, and destructor), it needs them all. Generally, this rule refers to ...
Looped Exceptions
by DevX Pro
Is there any way to catch exceptions repeatedly, instead of just once? For example, when creating a Date object with a String, an IllegalArgumentException can be generated and caught. In the catch statement, if an attempt is made to create the Date with another String, there isn't anything I can do if it also throws an exception. Is there some sort of looped catch statement?
Writing an Event Producer
by Ajit Sagar
An event producer is also known as the "source" of the event. Java does not define a base class or an interface for the event producer. However, the Listener design pattern requires that the event ...
Implementing the EventListener Interface
by Ajit Sagar
The EventListener interface is a marker or tag interface that doesn't define any methods. Its purpose is to provide a base interface for all event listener objects that follow the Listener pattern ...
Using the EventObject Class
by Ajit Sagar
The EventObject class is the base class for transferring events in Java (see Tip "Understanding the Listener Pattern"). ...
Understanding the Listener Pattern
by Ajit Sagar
The Listener pattern is commonly used in the AWT since JDK 1.1. In fact, the Listener has been the base for the event handling mechanism for UI events in Java. The Listener pattern also provides the ...
Disable and Enable Trace Output in Your Program
by Ajit Sagar
The prominent mechanism used to debug a Java application is to write string messages to System.out. However, this method clutters up the output of the program. In order to turn debugging statements ...
Private Inheritance
by Danny Kalev
When a derived class inherits from a private base, the is-a relation between a derived object and its private base does not exist. For ...
Using Proxy Classes in Java
by Ajit Sagar
The Proxy is one of the most common design patterns in circulation. Gamma et. al. define the intent of the Proxy as: "Provide a surrogate or a placeholder for another object to control access to it." ...
Prefer Function Objects to Function Pointers
by Danny Kalev
Passing a function pointer is a common practice in event-driven systems, whereby a callback routine is invoked through a pointer. C++, however, offers a better alternative to function pointers: ...
Creating an Editor Like MS Notepad
by DevX Pro
I am working on a project where I am supposed to create a Microsoft notepad-like program. Do you have any tips on how I should go about creating it?
Designing Legacy Code Wrapper Classes
by Danny Kalev
In many systems, legacy C code is combined with newer C++ code. A common (yet wrong) practice is to wrap the C functions in a single C++ class and create a single instance thereof, which provides as ...
Java's Alternative to Function Pointers
by Ajit Sagar
Although Java borrows a lot of concepts and syntax from C++, it also leaves out some of C++'s main features to meet its goal of simplicity. For example, Java excluded memory pointers and function ...
A Mutable Singleton
by Ajit Sagar
The Singleton pattern ensures that only one instance of an object is instantiated at run time and that this instance is accessible from a well-known access point. You can change the "singular" ...
21-40 of 79     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date