Sunday, 13 May 2007
Tuesday, 10 April 2007
Façade Pattern: The Camouflage of a Complex System
Figure: A typical Facade pattern UML diagram [1]
In the pattern world, that’s exactly what the Façade pattern does. It presents an interface that lets the user view only the simpler side of the system, not the complex architecture of the other associated classes and methods. “Facade is an object that provides a unified interface to a set of interfaces in a subsystem”. [2]
When I ordered my Head First Design Pattern book from http://www.alibris.com/, I had no idea where the book was actually located. When I did not receive the book in due time, they let me know that their system has located a copy in their Canadian warehouse. It will be shipped to USA from there and they will post it from there to London as soon as possible! It made me thinking, oh my God, did I even think of all these looking at the very simple alibris website? The obvious answer was NO. Now, as I’m trying to produce an example, I thought why not build this scenario in Java? Let’s have a look at the possible pseudo style Java code for the Alibris store system
public interface Alibris{
public takeOrder();
}
This is the interface I saw when I went into the Website. But all the hard working classes and methods were hidden actually behind the scene that I could not see. They can be:
public class Locate{
public locateBook(“Book Name”){
//Returning the location of the book
return location;
}//End locateBook
}//End Locate
public class mainWarehouse{//The main warehouse in USA
public getAcopy{//From the Canadian warehouse
public askForAcopy(location);
}//End getAcopy
}//End mainWarehouse
public class Dispatch{//Send the book to the Customer’s address
public sendBookTo(“Customer’s Address”); //Send to London
}//End Dispatch
These can be a very generic possibility of classes and methods of the book store. Locating the actual location of the book and returning the location to the main Warehouse. Then another class dispatches the book for the Customer’s address. The Façade pattern hides all these classes and methods from the customer when he/she orders a book. Hope that explains the basic of the Façade pattern. Please feel free to add to my thoughts.
Reference:
[1] Facade Pattern. Website
http://sern.ucalgary.ca/courses/seng/443/f2004/patternNotes/Choy_Wong_&_Zalzala/index.html#REFERENCE. 02 April. 2007
[2] Gamma et al. 1995. Design Patterns: Elements of Reusable Object-Oriented Software. p. 157
The Student Conference in the University of Portsmouth
Like all BSc. Computing final year Students from the university, we also need to do the final year project. As we, the St-Patrick’s students do our Degree program as on an off campus mode, lecturers come from the university to see our progress in the project by means of posters and prototype. From the posters and prototype, the lecturers from the University select the best ones to attend the Student Conference at the University every year. The conference is aimed for the students so that they can show their products to the prospective students, lecturers of Portsmouth University and people from the Industry. The conference holds great prospects because students can get an unbiased and broader evaluation of the work done from diverse perspectives. Sometimes, if the product is of good standard and has business prospect, the student might get a possibility to extend the scope of the project from being academic to commercial. As it is not easy for a fresh overseas graduate to enter the job market, these opportunities can prove very effective to land a job or a business contract. Not only that, let’s say even if someone doesn’t get such a chance, there are opportunities to learn about what kind of people or product the industry is looking for and look at the other projects from the University students to have a better idea of where we as individuals and St-Patrick’s students stand. The competitive element of the conference is addressed by three prizes on three different categories- the best product, the best poster and the best presenter.
The Conference Day - The dawn
This year, the conference was held on the 28th March. Six of us from Cohort-6 were chosen to attend the conference. There were two more students from Cohort-5 who went with us to attend the Conference. Mr. Sundar Subbiah was the coordinator of the group of eight students. The contingent rolled off to Portsmouth at 10:30 with an air of enthusiasm and positiveness around us All of us enjoyed the one and half hour journey. We were excited as most of us were going to the University for the first time.
At the University of Portsmouth
At around 12 o’clock we reached the university after a short walk from the station. We entered into the campus and the first building we saw was the convocation hall. Personally, it gave me a wonderful feeling to see the hall because at that point I was dreaming about me standing tall with pride on the stairs of the building with my gown and hat on and the certificate in my hand posing for the graduation day picture. It was a feeling I can’t express in words. I was thinking I can’t wait to come back here for my Graduation Day. Following the warm welcome from Dr. Kate Dingley and Penny Hart, we felt welcome as one among the students in the university. The swift response to our printing and stationery needs a special note of addressing here.
In the conference room, we met Penny Hart and she exceeded all my expectations about how we were going to be treated. She was everywhere. She assigned our places in the room, gave us support to stick the poster on the wall and any particular hardware we needed for our demonstration. I never had the feeling that she wasn’t my lecturer. I felt like she knew us from a long time and she was ready to give us all the support we needed. Moreover, she was coming to us every now and then and asking if we were ok or if we needed anything. This first impression helped us get rid of some tension and worries that we were having about the presentation. Sundar was taking very good care of us as he was asking us on our wellness and confidence.
The Conference & Resources
Before the conference started, we all got our designated place to stick our poster and set up the environment and equipments for the demonstration. We all had our laptops with us so we settled down with all the set-up. The Demonstration segment of the conference started at 3:00 pm. The Dean officially welcomed all of us and declared the start of the conference. There were a good number of people including students, lecturers and industry people. They were attentive to detail looking at the posters of different products and if they were interested about the product they asked for a demonstration. Some of them just came and asked the students to explain and demonstrate the product. There was euphoria of enthusiasm all around the hall and Projects were being appreciated all around, Projects from St-Patrick’s students got lots of interest from all kind of different people and they praised our projects. Mr. Paul French from Taylor Lock Company was interested about my product MoHSACS (Mobile Home Security and Appliance Controlling System) to be used with the lock his company invented. He gave me his business card and asked me to contact him. The Demonstrations was from 3:00 pm to 4:30 pm. At the end Mr. Ajit Narayan, Head of the School of Computing declared the winners of the prizes. Unfortunately, none of the prizes went to St-Patrick’s students but we were happy with what we achieved –positive response and recognition for our relentless effort. Going to the conference is a great opportunity for any Computing Final Year student. It was like viewing the future, as in, knowing what kind of jobs we can expect or what the industry people are looking to get from the fresh graduates.
After the Conference
Soon after the awards ceremony we were appreciated by the lecturers from the technology department for our efforts. Many thanks to Penny Hart, Kate Dingley, Amanda, Alice and Jane just to name a few who made it a point to see us of personally. We felt touched by your professionalism – Many thanks. Being the optimists we decided to head straight to the city to have a look around. The day being clear and bright we decided to visit the Harbour and Gunwharf. We spent some really good time. After the sun down, we went to have some meal and then headed to the station. We took the 8:30pm train back to London and at around 10, we reached Waterloo. The journey back to London was very enjoyable. Everyone was talking and sharing jokes, we were having a good laugh. When I reached home, I felt very satisfied with the outcome of the conference.
Projects from St-Patrick’s Students - Where we stand
Attending this years Conference, I got a clear idea about us- the St-Patrick’s students in terms of our project standard. I was pleased to know that the project coordinator (Penny Hart) and other lecturers of the University of Portsmouth believe that our projects have a very good standard. And they also believe we work really hard to reach our project goals and our ideas are sometimes better than their students; which gave me a lot of satisfaction.
Prospective St-Patrick’s BSc. Computing Students – What can be done
The prospective BSc. Computing students should focus more on their projects, try to progress for the prototype and create good project posters so that they can get a chance to be invited to the conference. Being in the Student Conference means a lot and makes big difference in thinking. Once there, a student will learn to think differently towards his/her project and grow the hunger to do better. I felt we, St-Patrick’s students have some lacking in few areas that I would like to point out. First of all, our posters are not up to the standard. I was impressed to see some posters of the Portsmouth students. Those posters are really wonderful, they stand out and more importantly, they convey the message. Our posters were mostly in black and white and in A3 pages. What we did is, we made few A3 pages, printed it in black and white and then stuck in the wall. Some might say if the product is good, you don’t need to advertise. Well, that’s true but we are living in a world where the competition is very high and you need to catch some eyes to be sold. Even though the main idea is not to sell, it is definitely good to have some professional looking posters. Secondly, we can work more on our presentation. Our presentation this time was definitely good but we could’ve definitely done better if we could have managed a bit more of resources on time. Last but not the least is showing the prototype in live environment instead of in emulators. There are two good reasons for that. One, it looks more real and two, people from the industry watching the demonstration can have a better associate with the product and more realistic idea about the end product.
Friday, 6 April 2007
Saving the cap of your Flash (Memory) Drive: A real life pattern

Hi folks, today I came up with a pattern when I lost the cap of my Flash drive and found it after looking for about 20 minutes. What happened is, I was working on my flash drive and when I finished working on it, I couldn’t find the cap of the drive as the cap is tiny and I forgot where I kept it. This was the second time I lost it and found it back. Then I was thinking, well, that’s a real life problem and a pattern as I’ve seen some of my friends lost the flash drive cap. So I thought why not find a solution to the problem? I came up with an idea that I would like to share with all of you.
The problem
Losing the flash drive cap; as most of the time it is tiny and easily gets lost.
Context
Losing the cap of the flash drive is a common scenario in today’s life. As we all know most of the flash drives come with a tiny cap that I normally hold between my lips (Fearing I will loose it) or on the desk and as it’s so tiny it keeps getting lost and we spend hours to find it back and sometimes end up not finding it at all. I was trying to find a way out how to save it from getting lost.
Solution
As I was looking for a solution, I was thinking about if there was a way I could fix the cap with the flash drive so that it’s not detached and I won’t loose it. Here is a list of what tools are needed and how to do it.
Tools needed...
- A simple needle that we normally use to repair cloths (A thin nail would also do but make sure the nail is thin enough so that the hole in the cap doesn’t get too big)
- A piece of thread (You can have it as long as you want but it’s better to have it small)
How to do it...
Go to the kitchen and turn on one of the burners in low heat. Hold one side of the needle with gloves and warm the other end till it gets red. It should take roughly a minute. You can use a candle if you feel it easier and safer. The point is to get the needle red hot so that you can pierce through the TOP of the cap and make a tiny hole to put the thread in. Once the cap is pierced, put the thread through the hole and tie few knots (On top of each other) at the end of the tread to make the knot big enough so that it doesn’t pass through the hole. Now, you have got the cap attached at one end of the thread. Almost all the flash drives have got a tiny hole to attach the neck strap. Tie the other end of the thread to that hole and your cap is permanently attached to the flash drive and you won’t loose it again.
Tip: To make the thread strong for longer lasting, you can use a strong but thin thread or you can double up the thread to make it stronger. Moreover, if you keep the thread just long enough to fit in the flash drive USB lead; it won’t get messed with the neck strap and won’t look ugly.
Caution: Don’t hold the needle with bare hands because you might get burn. Moreover, be utmost careful when you handle fire.
Tuesday, 3 April 2007
The coursework: a Critical Evaluation
I like programming. It is something that I really enjoy. But I made a mistake when I first started to code, that is, instead of looking at the problem from the Designer’s point of view, I used to look at it from a Programmer’s point of view (Some of you have also done it and will agree with me, I believe). It has had a serious side effect on my thinking and problem solving approach. Pattern is a whole new world and even though Software Design Pattern is about developing software, it looks at the problem from a Design point of view. Now whenever I try to look at a problem, my mind-set ultimately starts thinking about the implementation of the problem, not the design. After getting the Course Work, I have started to realize this situation. When I look at the problem to solve, I start thinking about the OOP-way of solving it. Even though I understand the Strategy, Decorator, Adapter and some other patterns, I’m really not sure how this problem will be designed and implemented using pattern. However, better LATE than NEVER! At this point, I’m happy that I’m studying this module because at least now my thinking will be changed and I will start having a Bird’s Eye View to a problem.
Let’s get to the point… there are five different tasks in the course work. Among them we have to do four each worth 25% mark.
Task ONE: Prototype UML diagram
Strategy, Decorator and Adapter are three different patterns in software design. As we have to design a prototype application for the given problem and enable users to view customer records in a variety of ways using these patterns, we have a very good chance to learn design patterns and improve our skills as Software Engineers. I don’t know how to implement it now or don’t have a clear vision but I am going to read more about them, have a look at some examples from the Head First Design Pattern book and hopefully I’ll be up for the task.
Task TWO: Coding with Patterns
In task two, we have to implement the design to produce code and physically develop the application. This task is a step forward to the task one. Doing this task will actually give us the hand-on experience of using pattern in Software Design. I wish to do both task one and two. Once I do task one, the coding should not be a problem but before going to task two I have to make sure that the design is right. If not, there is a possibility to loose marks for both the tasks. Food for thought :)
Task THREE: Patterns and Software Development
In this task we will have an opportunity to follow and apply the techniques of the legendary GoF to create a pattern about the mentioned Iron’s temporal patterns. Apart from implementing patterns in designing software, we will also create a pattern so that we learn how to document or preserve a pattern. Completing this task will give us the experience of preserving a pattern.
Task FOUR: Critiquing Patterns
This task is about critiquing Mr. Beedle’s thought about Anti patterns. We will have to look into Anti pattern alongside pattern and produce out own thoughts about it. Producing an essay of evaluation of Mr. Beedle’s comment and expanding on it in only 600 words will be a challenging task.
Task FIVE: Patterns Blogs
This task created a platform for interactive learning and sharing our thoughts about Patterns by posting our thoughts in blogs. The idea is simply brilliant. This task did eventually bring our heads together and benefit from the collective knowledge about patterns as we all are expressing our ideas and gaining from the classmate’s understanding.
Finally, as a whole, I think the design of the course work is very organized. It focuses on tasks from different areas of learning patterns to help us learn, understand and implement the Patterns for Software Design.
Sunday, 25 March 2007
What is Adapter Pattern?
“Convert the interface of a class into another interface the client expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces” [GoF, p139]
An adapter in Software Engineering works as a wrapper. Adapters wrap or modify an existing class/object and provide a different or translated view of the existing one. In other words, it creates an intermediate abstraction that maps or translates the old class/object to fit into the new system.
Figure: A class adapter uses multiple inheritances to adopt one interface to another
Figure: An object adapter relies on object composition
Rules of thumb:
Ø Adapter makes things work after they're designed; Bridge makes them work before they are. [GoF, p219]
Ø Adapter provides a different interface to its subject. Proxy provides the same interface. Decorator provides an enhanced interface. [GoF. p216]
Ø Bridge is designed up-front to let the abstraction and the implementation vary independently. Adapter is retrofitted to make unrelated classes work together. [GoF, p161]
Ø Adapter is meant to change the interface of an existing object. Decorator enhances another object without changing its interface. Decorator is thus more transparent to the application than an adapter is. As a consequence, Decorator supports recursive composition, which isn't possible with pure Adapters. [GoF, 149]
Ø Facade defines a new interface, whereas Adapter reuses an old interface. Remember that Adapter makes two existing interfaces work together as opposed to defining an entirely new one. [GoF, pp219]
Monday, 19 March 2007
Anti Patterns: Don’t ignore them
Well, I believe we all know the answers. Let’s elaborate on this thought to find out the “WHAT” and “WHY” of anti-patterns. A design pattern gives the general solution to a recurring problem in a particular context and “an Anti-pattern tells us how to go from a problem to a BAD solution”. [1] When a good pattern is applied by a wrong person, it becomes an Anti-pattern and we document it to avoid the same mistake. "Why on earth would we document a bad solution?" Keep reading...
If there is a bad solution to a problem and it is recurring, wouldn't it be a good idea to document it so that the developers in future don't make the same mistake and avoid that bad solution at the first place? Like patterns, Anti-patterns also have components. Below is the list of the components of an Anti-pattern solution:
- Name
- Problem
- Context
- Forces
- Supposed Solution
- Refactored Solution
- Examples
Why shouldn't we ignore Anti-patterns?
We shouldn't ignore Anti-patterns because:
- To avoid bad solutions: An Anti-pattern documentation points out the BAD solution so that we can avoid them
- They suggest good solutions: The Refactored Solution section of an Anti-patterns document actually leads to a good solution
- It alerts the user showing why a bad solution is attractive: In Forces section, an Anti-pattern tells us why a bad solution is attractive
- Shows where the Anti-pattern can be found: An Anti-pattern solution gives the example of fields where that particular Anti-pattern can be found so that the user can be careful about those fields
Therefore, we can conclude that we shouldn't ignore Anti-patterns; rather we should study them so that we don't fall into the same trap that others suffered.
Reference:
[1] Freeman, E., et al. 2004. Head First Design Patterns. p. 606