January 25, 2021
Hot Topics:

Beginning Objects in VB - Part 3

  • By Sam Huggill
  • Send Email »
  • More Articles »

OK. In the previous two articles we've talked about what objects are, and even done a little demo - but where do objects fit in to our everyday programming lives? How about some more examples!

Well, just think ahead a little. Perhaps at the moment you're just programming in VB for a hobby, maybe even hoping to earn a little money from it. Or perhaps it's your full time job and youre constantly having to write code for a variety of different applications. If you're the former of the two then you won't realise quite the importance of code reusability.

When you start to do more programming, and you have deadlines to meet you are no doubt going to want to refer back to some code you have already written and copy it over. Unfortunately you can waste a lot of time copying code from a command button, putting it into a procedure and setting up parameters. The best time to do this is at the beginning when you first write your code.

In this way you can easily reuse your code and save time when programming later. So when you begin to design (or code) your application, think in terms of objects and writing your code in nice, easy to use procedures.

Coming back to real world examples, think of MS Word. Microsoft Word (and in fact the whole of MS Office) provides a HUGE object model, which, at first look, looks very bad. But when you start working with it and delving into its properties it is actually quite good.

Now although your program may not be destined for worldwide distribution such as Word, having a well-defined object model will allow you to reap the benefits later on. It's rather like building a house. If you start off with a good design and lay good foundations, then your house has a good base. But if you just run off and get going, the chances are that it will go wrong.

The moral of this story is, plan ahead and plan in an object model that will allow you to use the parts of your program later on. See, it all makes good sense when well explained!

OK. I think that you get the point now. Lets move on to some practical advice for building your program around an object model...

Page 2 of 4

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date