Skip to main content

Posts

Showing posts from 2008

Singletons

In the previous post I had said that it may not be a good idea to have static attributes in your class. The Singleton design pattern also uses a static attribute to hold the Singleton instance. Even though there are valid uses of Singletons, lately this pattern has come under considerable attack . Here is another page on the Portland Pattern Repository Wiki , that outlines a practical problem someone faced while using Singletons. Google has an open source tool to detect Singletons. They call it the Google Singleton Detector . They have identified 4 types of Singletons, namely: Singletons, Hingletons, Mingletons, and Fingletons. You can find definitions for all the funny _ingletons on their wiki , but for those of you too lazy to visit the wiki, I will quote them here: Singleton: A class for which there should only be one instance in the entire system at any given time. This program detects singletons which enforce their own singularity, which means they keep one static instance of the

Using static attributes in Java

As you will probably know, the 'static' keyword in Java is used to denote fields, methods, and inner classes that do not belong to any instance of a class. They belong to the class itself and can be accessed when the class is loaded. In this post we will focus on static fields and very briefly discuss pitfalls of their usage. Static fields are used for a variety of reasons: To define constants In the Singleton design pattern As global stores for application wide settings For mapping default objects (like formats) with Strings Several other reasons depending on the requirements A few days back I was reviewing some code, and I realized that mutable static fields were being used in way too many places. This can make the code very brittle. When an object has a mutable static field, for all practical purposes this becomes a global variable, and thus has all the pitfalls of global variables. Some object might change the value, and another object that was depending on the old value wi

Figure it out yourself

In this blog, Guy Kawasaki writes about 10 (real world) things college students ought to learn. He has raised some very good points that are not taught in school but are extremely important at work. In point #4 he says: How to figure out anything on your own. Armed with Google, PDFs of manuals, and self-reliance, force yourself to learn how to figure out just about anything on your own. There are no office hours, no teaching assistants, and study groups in the real world. Actually, the real world is one long, often lonely independent study, so get with it. Here’s a question to test your research prowess. How do you update the calendar in a Motorola Q phone with appointments stored in Now-Up-To-Date? (I’ll send a copy of The Art of the Start to the first person with a good answer.) This brings to mind ideas that I have been trying to talk about for a while: self learning, informal learning, and continuous learning. I would again like to take this opportunity to remind you of the

Docking Frames

Docking Frames is an excellent Java docking framework. There are a few other docking frameworks out there also, like FlexDock , MyDoggy , and VLDockin g, but from all of them I found DockingFrames to be the best for my requirements. DockingFrames just works. I found very little inconsistency and bugs in it. Also it uses static variables very judiciously which was important for our use, since we might want to use docking in multiple places in the application, such that each of those do not know of each other. I also found the lead contributor to be very responsive. He was extremely prompt in answering questions and always gave good suggestions. DockingFrames uses the concept of themes for docking. A theme specifies things like icons, buttons, tabs, etc that appear in the panels that contain the docked components. In the beginning I used the BasicTheme and the FlatTheme. However, BasicTheme uses angular tabs (for selecting components that are docked in tabs), which I liked more than t

Coming back

It's been a long time since I have blogged here. I maintained a blog at http://www.adaptivelearningonline.net for almost 2 years. However, it was a hosted blog and I was unable to update it regularly. Consequently I have stopped that blog. I hope to restart sharing what I learn by posting here again.

Locking Screen on EEEPC

The Asus EEEPC does allow locking the desktop using CTRL-ALT-L. However there is a bundled utility kdesktop_lock that allows just that. To lock the desktop type the following line in a terminal. kdesktop_lock --forcelock This will lock the desktop (with the taskbar still being displayed) Here's how you can add an icon to the EEEPC's SimpleUI, so that you do not have to type in the command every time. Add this to the /opt/xandros/share/AsusLauncher/simpleui.rc icon="iptv_norm.png" selected_icon="iptv_hi.png"> Lock Desktop