Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

14 October 2013

First Video from Canon 600d

I have been writing posts here in Unstuck for quite sometime and i always wanted to move to next level from writing to something different. The entire world is moving towards video. Recently, i bought a Canon 600d DSLR (in fact it was my wife's negotiation skill that made me to buy this camera. Later i thought, it is worth buying) and captured few videos. Here is one that i captured and published under the banner of OpenGyan. I thought of sharing it with you. Here is the video, watch it and share you comments.


28 January 2009

What is Creational Pattern?

As name suggests, the creational patterns are used in object creation. Any object oriented programming language will give you an infrastructure to create objects and perform whole lot of operations. One of the important and primary operations in any application is creating object. For example, in Java, you can create objects of any concrete types using "new" operator. However, the Java compiler or JVM do not know, are you creating objects in right way.  The way we choose to create objects decides many aspects such as reusability, maintainability and flexibility. Though we create objects in an application, we will creating objects for so many reasons. For instance, in the case of Singleton it enforces creating only one object for a class (type). As the purpose and scope of the objects vary, the way in which they are created should also vary to reap full benefits of Object Oriented Programming. There cannot be single solution for whole a lot of problems.

Let us consider a real world example. Assume that a car manufacture is planning to manufacture new brand (assume Swift by Maruti). While designing the car, the designers will focus on individual aspects of the car. There will also be a mechcanism to customize any model or to add features to the car. The extra fittings or specific model (Vxi, Zxi) will have its own assembling mechanisms. The dealers or the customers do not need to worry about how the car is made. They just give which model they want and the car is delivered to them. Internally, Maruti will have its own processes and standards to manufacture car hiding all the manufacturing details. It may choose to manufacture the parts or procure it from a different vendor. It is all internal Maruthi and the user does not need to know too much of details. It is all about exposing needed level of abstraction to the clients - not more and not less.

Also, as a developer, it does not make sense to fill your code with lot of "new" operator. By using "new" operator in lot of places makes the code to break maintainability and flexibility. When few more classes are added to the package or namespace, the developer will face a nightmare maintaining the code and quality of the code is also degrades.

So, the creational patterns helps to create objects in a better way rather than using "new" operator. When you use creational patterns (or any design pattern), you will be programming to an interface and not to the implementation. When you program to interface, your code becomes flexible and maintainable. In the next series of posts, we will be discussing creational patterns one-by-one.

26 October 2008

Design Pattern - Introduction

If you are a software developer, your responsibilities include design, implementation and unit testing the software. Once the software released, the whole bunch of new issues suddenly creeps into your code and then on you will be running after each bug and trying to chase it down to death. In most of the cases, the bug wins and the developers lose. Sometimes, I used to think that there is an egoistic clash between bugs and developers both of them willing to fight till the last breadth. Irrespective of the honest effort, the bugs manifest in multiple forms - usability, functionality, performance, scalability and so many jargons. With current time to market pressures, the software community is pro-actively by changing the software development models - Agile, Iterative, Test Driven Development. These software development models give a framework to tackle the changes in requirements. These days it has become unwritten law to change the requirements, quite often. Even though, we have software development models that offer flexibility, doing the fundamental right will give you a lot more flexibility. Design Pattern is one such tool that helps by providing conceptual solution to common problems and thus decreasing the software development time. 

Design patterns are solutions to common problems. It is not a software tool, framework or library. Design Patterns are simple and effective ideas for common/repeated problems.  Since it is a concept, it can be reused anywhere in software design. The concept of design pattern must have be adopted by software development community taking an inspiration from architecture of buildings or civil engineering. The fundamental concepts and theories of building various types of buildings such as houses, roads, flyovers, auditoriums, cinema halls, communities and etc are same. For example, there are blueprints available to make various types of buildings based on the land terrain, climatic conditions and so many factors. But given a set of requirements, any experienced architect or civil engineer will be able to give you the plan for the building and when followed with fundamental concepts, the building will be made. So, the developers in software community also thought in similar lines and came out with classical ways of solving design problems. Hence, Design Patterns are solutions of common problem.

Like a blueprint, Design Patterns are template for complex problems. Once again going back to the example, the architect or civil engineer will know how to build buildings and what needs to be done. In similar way, Design Patterns are just ideas/concepts. They are not specific to a platform, programming language or an operating system. Design Patterns might have been used atleast millions of times by software developers and the concepts, principles are time tested. Hence most of the Design Patterns states which problem that it is trying to solve and of course the solution. In order to make things clear, apart from the intent and associated text, the design patterns are explained with the help of UML class diagrams.

Design Pattern makes our life easier. Say for example, someone comes to you and asks for "Can you tell the place where people go from one city to another, purchasing tickets. They will also wait on a platform for the vehicle containing a series of boogies pulled by an engine powered by electricity or diesel?" Won't you run from him?. The job would be much easier the person asks for the way to railway station. In software development, without design patterns, the developers need to beat around the bush to express what is there in their mind and Design Patterns makes communication fast, crisp and clear. So, Design Patterns are communication tool.

Having discussed about the design patterns, the rest of the article discusses various types of design patterns. Based on the applicability, the design patterns can be categorized into three main types. They are

1. Creational Patterns which primarily deal with how the objects are created and how to create objects based on a specific situation. The examples of creational patterns are Singleton, Factory, Prototype.


2. Behavioral Patterns identifies common communication patterns between objects and offers flexibility in performing the communication. The examples are State, Strategy, Observer, Chain of Responsibility.


3. Structural Patterns deals with realization of relationships among objects. Decorator, Adapter and Flyweight patterns are examples of structural patterns.

In this blog, we saw the basics of design pattern and its types. In upcoming blogs we shall see about specific design pattern with real world examples, class diagrams and how to apply these concepts into software development.

Summary:
1. Design Patterns are solution to common and repeated problems
2. Design Patterns are not library, API or framework or source code
3. Design Patterns help developers to communicate fast and to the point.
4. Creational, Structural and Behavioral are three types of Design Patterns