Tech Off Thread

7 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Class's

Back to Forum: Tech Off
  • User profile image
    RamblingGeek​UK

    I'm a novice programmer, I use to write software when I was younger back in the Quick Basic Days....

    I'm trying to get back into more of a hobby than anything else. I've been reading up on a few things, but I seem to have two areas which I think I'm over complicating in my head.

    These are Databases and Classes.

    Right now I want to get my head around classes, can any one help? From what I understand thus far a class is your object in OOP, is that correct?

    Why right a class, I don't fully undertand the advanatge, although it appears the "right thing to do!".

    I hope people can recommend some good advice reading material to get me started.

    I'm the kind of person who really wants to do things the correct way.

    Thanks in advance.

  • User profile image
    zhuo

    Kryptos wrote:
    I'm a novice programmer, I use to write software when I was younger back in the Quick Basic Days....

    I'm trying to get back into more of a hobby than anything else. I've been reading up on a few things, but I seem to have two areas which I think I'm over complicating in my head.

    These are Databases and Classes.

    Right now I want to get my head around classes, can any one help? From what I understand thus far a class is your object in OOP, is that correct?

    Why right a class, I don't fully undertand the advanatge, although it appears the "right thing to do!".

    I hope people can recommend some good advice reading material to get me started.

    I'm the kind of person who really wants to do things the correct way.

    Thanks in advance.


    Objects are instances of Classes. Classes are like the blue prints of a house. Objects are actual houses built using the blue print.

    Classes allows you to encapsulate functionalities and relevant properties. The hard question is often where to draw the class boundary, i.e. how do you decide this functionality belong in one class and not another? Depending on the development methodology and the type of application you are writing, you may not care.

    Well designed classes encourages reuse. Couple with other features of OO e.g. Inheritance you can build powerful reusable and extendable frameworks. The Dot Net framework is a true testament of this.

    I don't know of any good materials, the best way to learn is probably to start your own toy project and get stuck into it. Build a Wiki or something.


    James Big Smile

  • User profile image
    RamblingGeek​UK

    zhuo wrote:
    Objects are instances of Classes. Classes are like the blue prints of a house. Objects are actual houses built using the blue print.

    Classes allows you to encapsulate functionalities and relevant properties. The hard question is often where to draw the class boundary, i.e. how do you decide this functionality belong in one class and not another? Depending on the development methodology and the type of application you are writing, you may not care.

    Well designed classes encourages reuse. Couple with other features of OO e.g. Inheritance you can build powerful reusable and extendable frameworks. The Dot Net framework is a true testament of this.

    I don't know of any good materials, the best way to learn is probably to start your own toy project and get stuck into it. Build a Wiki or something.


    James Big Smile



    Thanks for the reply.  This is beginning to make sense.

    So if I wrote an application to track site visits to customers, then I could write a class called customers and that class would have certain functions, routines and properties that I could call over and over?

  • User profile image
    Wells

    I hate to be the grammar (I need to watch my language), but "Class's" is incorrect.  That denotes posession, where you want the plural, i.e. Classes. Tongue Out  Then again, if it were posession the last s should be dropped too...

    Anyway! To your questions,

    Kryptos wrote:
    Thanks for the reply.  This is beginning to make sense. So if I wrote an application to track site visits to customers, then I could write a class called customers and that class would have certain functions, routines and properties that I could call over and over?


    Exactly.  Basically, you use a class to bundle together data and the methods (functions) that act upon that data, into one neat little package.

    Any access to the data is provided through a public interface, while the internal variables and other stuff is kept private.

    A classic example would be something like

     class Person
     {
         public:

              void SetName(string Name) const { _name = Name; }
              string Name() const { return _name; }

          private:

              string _name;
      };

    in C++.

    You can see the public methods Name() and SetName() that users of the class can access to get/set the name.

    The private data, _name cannot be accessed by users of the class.  This 'hiding' of private stuff, and only allowing access through a public interface is called Encapsulation, and is an important idea to grasp.

    It means you can change the implementation details of your class without breaking any existing code that uses it.  So for example, I might decide to represet the string using some other data type.  I can easily change my private implementation details, whilst keeping the public functions the same.

    That'll do for now Wink

    EDIT:

    I don't know WTF is going on, but when posting with IE7, linebreaks are removed from my posts.  I had to use Firefox (:o) to post!

    EDIT2:

    And what's with n-azi being a bad word?

  • User profile image
    RamblingGeek​UK

    Wells I don't mind being corrected on my English! As it's rubbish...... thanks for the tip!

    What you says makes sense. I think I begining to get my head around this now.

    I think I'm going to start writing some code and play around with some ideas. I'll also re-read what I've already read, to see if it makes more sense.....

    This is great so much easier than trying to figure out if you really understand a topic on your own.

    Keep them comming! Big Smile

  • User profile image
    itprochris

    I would go to the Infragistics DevCenter at http://devcenter.infragistics.com/RefApps/Tracker/tracker.aspx and read the eBook. It is very informative on classes, data access, and constructing a well-architectured app.Cool

  • User profile image
    Angus

    I don't know what language you are using, but check lesson 6 on this tutorial: http://lab.msdn.microsoft.com/express/beginner/default.aspx
    I found it of great use when I was trying to get to grips with the basics of OOP that can be complex for a beginner. Lesson 6 on that tutorial session could be helpful, and if I were you, I would check out the other videos in that set of lessons.

    Angus Higgins

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.