Showing posts with label Objectville. Show all posts
Showing posts with label Objectville. Show all posts

04 April 2011

Design Patterns - How to Learn

Most often we encounter people whom they call themselves as expert in design patterns. They start off with the discussion saying that they know Singleton pattern - knowing little bit of what is singleton and completely ignorant of why Singleton is needed. While design pattern helped experts to improve their productivity and the quality of software they write, it hasn't done anything to novice designers like us. Right away, let me say that it is not the problem with the design patterns. It shows that the way we learn design patterns isn't right.

Learning design patterns starts with getting hands dirt with abstraction, hierarchy, encapsulation and loose coupling. All these attributes do not come easy and they evolve over a period of time with imagination. We have to visualize how a solution is better than the other and if we can solve by writing code, it really helps us to understand deeper.

Keeping that mind, i started to put together series of puzzles on software design to improve my design knowledge - particularly on object oriented software design for quite sometime. I would say that this method is changing the way i think. If you also want to get your hands dirt, you can find puzzles tagged as "Design for Fun".


Let me tell you, more puzzles are on the way.

15 December 2010

Software Design Puzzle #5 - Ice Cream, Ice Cream, Ice Cream

Uncle John is very tired working for a software company. It is his childhood dream to be a entrepreneur and so he resigned his job and started a ice cream business. His business idea is very simple. Like coffees, teas, milkshakes, he wants to do ice cream vending machines and sell ice creams along with ice vending machine. Being a Java developer, he wants to develop a highly flexible ice cream vending machines (and eventually patent it). He wants to give few varieties of ice creams - cone, cup and stick and so many flavors.

The question here is, how will you design the ice cream vending machine (time being forget the fact how various ice creams base/flavors are mixed and ice cream is made which by itself is a separate design problem to solve).

How will you design the vending machine?

08 December 2010

Software Design Puzzle #4 - Apple Farm

This time, it is producers and consumers. Here is the story

There is a apple farm and the season is at its peak. The farm has many trees and each tree has numerous apples. The owner decides to harvest the apple and invites bids from various folks who are interested to buy apples. Some of them want the apples to be sent to their places and some of them are ready to reach the farm to procure the apples. So, the farmer plans for the harvest. He employs few hundreds of people - some to pick apples from the tree and some to package/transport apples. And by the way, the farmer sends apple as package of 500 apples.

Can you bring out classes and their relationships to fulfill the above requirements?

25 October 2010

A Thought on Design Pattern

Few years back, i was introduced to "Design Patterns" at work. It was series of presentations from each one of us. I really feel thankful for the person who inculcated the importance of giving presentation in me (a separate post should go for that). After covering reasonable number of presentations on design patterns, there was a recap session. We were just revising all the presentations. Two of us felt that all patterns appeared the same and we shared a comment - "everything is same". There was a intense debate over that.

Even today, i feel that all design patterns are same. Yes, all design patterns abstract the problems and give us a viewfinder to view things in a simplistic way. Rather than (or in addition) the usual definition of - "proven and time tested solutions to common problems", the definition would be have been apt or more beautiful we append these words to the definition - "a binocular that helps us to see things in the ways that should have been seen". Each pattern enable us to think in a simple way. Each pattern takes one simple thing and does it well (Unix philosophy).

So, the design pattern is - "proven and time tested solution for common recurring problems that helps us to see things in simple way".

03 October 2010

Presentation on "Basics Things on Objects"

Last week i shared with you one of my old presentations on Security. From this week and for few weeks, i ll be writing/sharing few presentations on "Objects", "Design", "Design Principles" and "Design Patterns". I m not sure whether i ll be regularly posting every week. At this point of time, i m trying to find my consistency to post the presentations every week. Please bear with me until i find my consistency.

Each deck will have
  • slides focusing on only one thing
  • short recap of things that are discussed
  • drill for the week (you can try to reflect on the problem until i post the next presentation)
  • the topic of next week
Here goes the first presentation. This is just a curtain raiser to help us to set in same frequency. [ I would love to hear from you - what do think and how can we make this much better.]

Basic Things on "Objects" - Part 1


20 September 2010

Can you Really Teach Abstraction?

I was talking to one of my friends about OOPS. While talking to him, a question suddenly flashed in my mind about OOPS and more specifically about abstraction - how can you teach abstraction and the methods to be used to abstract ideas. In order to answer this question, we need to understand the real meaning of abstraction - "a concept or idea that is not associated with any specific instance". In other words, it is our ability to take our learning to higher level so that it becomes independent of specific instances. 

Let us try to understand whether it is possible to teach abstraction with a help of simple mathematical addition. 1 + 1 = 2, 1 + 3 = 4,  6 + 5 = 11. Each of these additions are specific instances of addition. When we are learning "addition", we focus more on "+" (and put it in long term memory, yep that is abstraction) and we just remember the numbers until we solve the problem. Once the problem is solved, we just forget the numbers (short term memory). When we are early stages of learning, we tend to believe that specific instance is ultimate truth. When we practice, we face many types of similar problems and start to change our perspectives. The change of perspectives is critical that leads abstraction. With practice, we are programmed to abstract concepts (eg: addition).

So, i tend to believe that abstraction is directly proportional to practice and more specifically the number of "wow" moments that you create on specific subject and i agree if someone says "abstraction cannot be taught but can only be felt or facilitated".

19 September 2010

OOP - Bending, Stretching, Thinking My Mind

The past two days, the Saturday and Sunday, were really exciting. I lived in this world with a lot of imagination and i would say it was good exercise for my brain. When it comes to Object Oriented Programming, nothing comes near to practice (of course, practice with head/brain/mind or whatever we call it). Object thinking was good testimony that one has brain and trying to use it.

I started off with a nice relaxation at Marina Beach with Sandy (an amazing guy and rock star) who often gives you a lot of challenges in the form of questions. It is not so easy to answer him as it is quite difficult to convince him (i bet, if i have a presentation now, i ll be more comfortable in answering questions than i used to be few months back). We spent around two hours in Marina beach (and we both thanked each other for making a good start) and later an hour in Saravana Bhavan. Dropped of Sandy at Guindy and from Guindy, i started my week on OOP.

I was trying to come up with a design for a problem and so far came up with at least five designs. Whenever i tried redesigning, i got to go back and reread the requirements/problem statements. I m a poor guy and i got to read the requirements many times. But yet to settle down with a design. I believe, i ll change the design five more times :-)

I expect to complete the design and coding of the problem this week and hope the next Saturday morning will be intense with some OO discussion.

@Sandy
I hope, you will join me next Saturday too :-). But the next time, we will be more technical and let us make sure that there is good amount of learning. What do u think?

31 August 2010

Software Design Puzzle #4 - Building A Flexible Weather Station

The puzzle is on building a flexible weather station. This weather station's main job is to provide instantaneous updates to its clients on various weather conditions like temperature, atmospheric pressure, wind speed, pollution levels and a forecast on the rain. The clients are heterogeneous starting from a full blown weather forecasting websites which are interested in all updates (everything from temperature to rain forecast that are available time to time) to a roaming marketing guys who just want forecast of rain to plan their travel. The point is there are few clients that want all updates, few wanting all except few conditions and many wanting only few conditions. The clients will also be requesting for more weather parameters dynamically.

The requirement is to identify design pattern(s) that will suit these requirements. Model the class diagrams focusing on important aspects of the design. The following is a just a sample client (thanks to Google).

A question that comes to my mind on these puzzles. Does it really help me to build my OO expertise?

An honest answer is it depends. The idea of posting these puzzles is not make us OO guru with few hundred puzzles and in fact OO requires naked thinking. I feel that a lot of thinking can be stimulated by these examples. Memorizing a design doesn't help though. Just skim through the puzzle and solve it. When you are solving think about abstraction. Abstraction is your ability to see sand in a beach as a thin line when you are flying few thousand feet above and view them as a mighty rock when seeing through microscope.

20 August 2010

Software Design Puzzle #3 - Modeling TCP/IP Stack

You would have heard about TCP/IP Stack in Networking (if you haven't or want help in refreshing, please refer here). The puzzle to identify and come up with set of classes with properties and functionalities to represent TCP/IP model using object oriented principles. Also, identify the list of design patterns that can be used while you are designing the classes.

The answers to previous two puzzles on algorithm is out. Please check out all the puzzles here. Will be publishing the answers to all outstanding puzzles this weekend.

Also, please do let me know your comments/feedback/suggestions.

17 August 2010

Design Patterns - Tool to Think in Objects

There are many reasons to know and experience design patterns like finding answer to well known problems that are tested by time, it is a common language that can used for effective communication and many more. While getting exposed to design patterns helps us find solution, the experience of analyzing design patterns helps us to build a ever expanding knowledge base. It changes our perspective of seeking solution.

If one can analyze few design patterns, then it becomes all the more easy for someone to comprehend other design patterns. While learning and analyzing patters, without our conscious efforts, it helps us to see problem from objects point of view. Our structured thinking goes away step by step and we tend to "think" objects and "design" objects.

One of the key benefits of learning design patterns is "object thinking"

The answers for puzzles posted last week were published. Please visit Puzzle and Puzzle. Watch out for the next puzzle on "Binary Tree".

11 April 2010

Software Design - Puzzle #2

Here goes another design puzzle.

There are varieties of creatures (example Man, Lion, Tiger, Monkey) each exhibiting varieties of walking behaviors (Walk, Slow Walk, Chasing, Running, Jumping). The walking behavior changes based on the mood of the creatures. (Hint: This forces us to bring in different walking behaviors to our objects dynamically).

Can you analyze this requirement and come up with design pattern(s) that could solve this problem and set of classes to model this requirement.

14 March 2010

Software Design - Puzzle #1

You are sitting in a boardroom of a famous gaming giant. They have invited you to discuss about the design of their next product - a strategy game. The game is "Konquer" in which a king tries to rule the entire world and takes the world towards prosperity. The gaming giant is planning to give the responsibility of modeling classes. Here is the requirement one
Since the area is very large, the king is trying to split his kingdom into more manageable parts. He needs idea on making his entire region into more manageable regions. The requirement is that you have to come up with list of regions and model them into set of classes. After this, the king goes for the hunting asking you to meet him after two days to discuss your ideas.
With this example, we will learn few object oriented principles that leads to better software design.