Polymorphism
Polymorphism implies that different objects behave in different forms, by exposing different functionalities that is the properties and methods; by the use of the same public interface.
The behavior differs since various classes can implement many different un-related interfaces and the same interface can be implemented by various classes.- Interface Polymorphism -
One class can implement from one or more interfaces; resulting a class that instantiated objects will behave in a specific way.
Let’s see what an interface is. An interface defines the agreed structure of a class behavior. Behavior of an object will be determined by the properties and the methods which they expose. There for an interface has the method definitions, where the class can implement and override them.
interface IVehicle
{
void drive();
// this is the method definition
}
// -------------------------------------------
public class Car : IVehicle
{
virtual void drive()
{
// this is the method implementation
}
}According to the above example; if we create a Lorry class which will implement from the IVehicle, and write a method implementation for the drive() method; then the objects created from the car class will differ from the objects created from the lorry class. As you see now its clear that even the both classes implements from a single interface the end result would differ. Note: Further the methods defined with in the interface are by default public and abstract.
When you are overriding a method is an interface you need to use the key word “virtual”, in order to override. Further, you are allowed to define properties in interfaces but not fields, this ensures that (classes that interact with the interfaces) it does not have access to the internal data of objects.- Inheritance polymorphism –
One class can inherit from another, where the base class will contain the complete functionality. That is, the base class will contain the method implementations; and the inherited classes will contain the base class functionality plus the additional functionalities as well.Let’s see how we can do this in code.
public abstract class vehicle
{
public abstract void drive();
}
-------------------------------------
public class car : vehicle
{
public override void drive()
{
//this is the new implementation
}
}
In this scenario as well, another class which will inherit the vehicle class will have the same drive() method plus some additional functionality.
In the case of maintainability, as you may see, when we code for abstract classes; and once we need some additional functionality, we need to change the existing base class. But if we have code for interfaces; then it’s a matter of adding new functionality, with out touching the existing code. There fore coding for interfaces are easy; in the case of maintenance when adding new functionality.
Software Development – Time Matters
As most of us are developers which mostly deal with coding or some times in design, we tend to work on tough targets where we strive to win the battle with the knowledge, time and the perfection or the completion of the product. Question is how we approach this? Ofcourse need not to mention that one should ofcourse have the high focuss and clear mind and very good visualisation.
After doing a brief survey from most of the Software Experts I learnt that, one such approach they take is to focus on the skeleton first. Let me explain a bit more on this. In this approach we see the main functionalities as the outline of work. Try to focus on them and get the working product. Then focus on the details, for example enhancements and find out efficient ways of solving the problem.
If we have a complex work; what will we do? Basically we will devide it to smaller parts. Work on the small units or parts and get it working. In coding, there are two points which spots on. One is the Technical Approach and the other is the Logical Approach taken in solving a problem.
Let’s look at this a bit deep. There you will face some technical challengers. At the time we face technical concerns there is always web for reference. Or simply we can post questions or search the web, where others have posted same or similar problems. We can carefully go through them and find out where exactly our problem fits. Once you get keen on this, you will feel as if u are like a detective trying to find pieces to solve a plot.
Logic is tricky. Not every one can learn the rocket science….but not to forget that rocket science was invented by the man...Not any one else. So, let’s just start visualising the work flow involved behind and try to model it.
Completion of a given development work with in a time span, is a one major skill of a developer. Of course there are other skills as well, such as working till the completion of the product and the quality of it too matters. But since this article focuses on time concerns…let me leave an open end to this. So feel free to comment…Because I am in the process of developing that special skill. :d.
Few thoughts to light up your articles…
Recently one of my blog viewers sent me a mail requesting some advice to enhance their blog. As a result, for all the readers, I thought to publish this small article that would encapsulate my thoughts to shed a little light on their blogs:) hope that it would help her and the others who were interested in the same…
In my case I use my blog as to publish articles, not as just anything and every thing. In what ever I publish I do take a deep concern in it, because it’s mostly on business domain or in technology.
So keeping that in mind, here are some points that I’ve observed, which we could use when we are writing articles.
First of all before we start writing, examine the purpose, or the objective of writing the article. In simple terms, ask your self what exactly you want to convey.
Then decide on the targeted audience. For example, if the article is much to do with the business try eliminating the too much technical explanations, because it might lose the interest of readers or it could make the reader dreary. In some instances, if you expect some level of technical understanding from the reader in order for him to read your article, make sure to mention it in a very pleasant way.
Then think of an appropriate approach for presenting your idea. This should also be well balanced with the topic as well as the audience. Following are some of those commonly used approaches.
- Convey direct idea: this is good when explaining theories. With are strait forward or technical.
- Explanation with a story: this is also a good approach when the idea is too complex for a general person to understand. And further we need them to walk through it. There for stories are effective in this sense. Anyway, every one loves stories I guess:)
- Use a work flow: this is a combination of above both. Where the idea could be so lengthy in explanations and we need to explain every little part in it. In this case, try to break it in to pieces, arrange them and explain each separately with out breaking the links to one another.
After selecting the approach we should structure the article with concern. It should be seen as three separate parts, begin, body and end. Beginning could be a question, or a solution to a problem or an exciting topic, where the attention of the reader is captured. The body need to be presented in detail and with facts where it will be solid and crisp with appropriate information and the end can picture with either the conclusions or suggestions….or an open thought.
Writing an article is as same as giving a GIFT to a friend. Even if the gift is of value if the wrapper is messy or unappealing it would not serve your purpose. This is same vice versa. There fore take a little concern and a bit of attempt not only to convey your idea, but also to convey in an inspiring manner.
All the best to you all and enjoy writing...!!!