Browse DevX
Sign up for e-mail newsletters from DevX

Search the Tips
Tip Bank > Application Design > Design Patterns

Design Patterns

1-20 of 79     Previous     Next
Determine which Proxy Pattern You Need
by Shalini Ajay
The proxy pattern can be used in situations where multiple copies of a complex object must exist.
Use the "Service Locator" Design Pattern with the J2EE Architechture
by Mouli Chandra
This tip is an extension of a Design Pattern called "Service Locator" for the J2EE architecture. Generally, the "Service Locator" pattern returns a home object by merely accepting a string, usually a mapping for a JNDI name.
Abstract classes as interfaces
by Danny Kalev
In software design, you should plan ahead the interface of a class hierarchy to make sure that all related concrete classes share a common interface. This can be achieved by using abstract ...
Writing Binary Data to an ofstream
by Danny Kalev
To write the binary value of a variable to an output file stream (ofstream) object, use the write() member function. write() takes two parameters: const char * and long, which hold the address of ...
Making Global Objects
by Nitin Kumar
Let's take an example: a program has a PrintSpooler class. This class maintains a queue for printer requests and serializes them. The program cannot contain multiple PrintSpooler Objects because ...
"Setter" and "Getter" Member Functions
by Danny Kalev
Encapsulation is a fundamental principle in object orientation. Encapsulation restricts direct access to a data member of a class. Instead, users query the object itself in order to get or set its ...
Creating a Temporary File
by Danny Kalev
Many applications create temporary files that exist as long as the program is running and are later discarded. For example, a Web browser can store a list of pages that have been viewed during the ...
Designing a Generic Callback Dispatcher
by Danny Kalev
In many applications, you need a generic class that invokes callback functions regardless of their class type. For example, an even-driven system that needs to call a member function of a GUI ...
Implementing Callback Routines
by C.V. Ram
One of the easier ways of implementing an event-driven programming model is through passing function pointers which are invoked when an event occurs. But because Java doesn't support the notion of ...
Inheritance in C++
by DevX Pro
In order to have better maintainability and optimum performance, how many levels of inheritance do you recommend ?
Layout Manager for Scrolling DIV's
by Chris McCann
A scrolling DIV is a great way to display a large amount of data without ...
Delegation Technique
by DevX Pro
What is delegation and how can I use it? Could you please give an example of a simple delegation technique?
Calling a Function at Program's Startup
by Danny Kalev
Certain applications need to invoke startup functions that run before the application starts. For example, polling, billing, and logger functions must be invoked before the actual program begins. The ...
What Are Design Patterns?
by Behrouz Fallahi
A design pattern is a design solution to a software problem that occurs within a specific, recurring set of situations.
Use Singleton Objects to Reduce Garbage Collection
by C.V. Ram
Performance tuning of Servlets is a major criteria as a servlet is expected to simultaneously handle dozens, if not hundreds, of threads depending on the requests. These coexisting threads have to ...
Font Metrics
by Daniel Savarese
Font properties that affect the rendering of strings are represented by the FontMetrics class. You can determine the FontMetrics of the current font in a graphics context with Graphics.
Virtual Function
by DevX Pro
I'm surprised the following code doesn't compile: class C1 { public: virtual void f() { /* ... */ } void f(bool) { /* ... */ } }; class C2 : public C1 { public: void f() { /* ... */ } }; main() { C2 c2; c2.f(true); } I found that adding "using C1::f;" in C2 class solves the problem; however, I see no ambiguity in the call to f.
To Virtual Or Not To Virtual?
by Danny Kalev
< ...
Correctly Declaring Global Objects
by Danny Kalev
Although the use of global variables is not recommended in general, sometimes it's unavoidable. When using a global variable or object, never instantiate it in a header file because the header is ...
Over Engineering, Wheel Re-Invention, and Other Diseases
by Danny Kalev
Writing code from scratch, without any prior design or plan, is a very bad programming practice. However, the opposite, namely over-engineering, can be just as harmful. In essence, over engineering ...
1-20 of 79     Previous     Next
Thanks for your registration, follow us on our social networks to keep up-to-date