Results 1 to 15 of 15

Thread: why do they need to create class?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    why do they need to create class?

    Why do they need to create Class?
    What is useful to create Class?





    Your help will be appreciated


    Thank!!!!!!!!!!

  2. #2
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502

    Re: why do they need to create class?

    There are many reasons to use classes.

    1) It makes your system more structured. You can group methods, functions, constants, ... with a common goal.

    2) It improves your flow of thoughts, because a class can be an entity: for example a class Person, which holds the name and address of a person or you can have a class BusinessProcess, which holds a length in hours, the envolved employers, ... But you can create just any class you like.

    3) Data-classes can reflect the structure of your database.

    4) A certain class can be designed without having knowledge of the other classes. This makes it easier to design the software in team.

    5) It makes your system loosely coupled and therefor more flexible. That is, because a class hides all the details and keeps them for itself. So, when you choose to use a different technology you can just replace that 1 single class without having to rewrite your entire system.

    6) Classes allow inheritance and polymorphism (for that you should follow a tutorial or so, that's too hard to explain here.

    It is maybe handy to point out that classes can be categorized in 3 groups:
    - data related classes: such as Person, Job, Car, Organization, Order, Bank, Delivery, Product, ...

    - graphical related classes: such as Button, TextBox, Form, CheckBox, PictureBox, ...

    - controller classes: these are classes which take care of the operation, communication and interaction between the different components of your system: such as DatabaseConnection, SelectionManager, Webcam, Thread, ...

    If you want more, just read a book, or an online tutorial or check out wikipedia.
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  3. #3
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: why do they need to create class?

    Class in the building block of Object-Oriented programing language, more easily structured the program. Easy to develop, easy to understand, etc...
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  4. #4
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: why do they need to create class?

    Other than all that was said, designing with OOP in general makes it easier to relate to your customer/manager/anybody non-technical what you are doing since you are modeling your design off classes which will represent objects etc.

  5. #5
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: why do they need to create class?

    From my experience, while learning, structured programming was easier than object oriented. I couldn't understand why they were saying that OOP was easier since structured seemed easier. However now that I know OOP, I could definitely say that it is easier than structured, since it produces high quality structured programs that more manageable especially with maintenance.

    With structured programming, one could easily sit down and start typing code. However with OOP, you actually have to plan your class diagrams initially (which seems more difficult), but after, everything runs smoothly.

    Jennifer.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: why do they need to create class?

    Quote Originally Posted by JenniferBabe
    With structured programming
    "procedural", perhaps?

  7. #7
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: why do they need to create class?

    A difference of terminology. I guess it means the same. When we refer to structured programming, the style is that is the language C where a line of code executes one after the other from begin to end.

    Probably a term of the caribbean (where i'm from) perhaps.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: why do they need to create class?

    But all code executes from beginning to end.

  9. #9
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: why do they need to create class?

    Quote Originally Posted by JenniferBabe
    A difference of terminology. I guess it means the same. When we refer to structured programming, the style is that is the language C where a line of code executes one after the other from begin to end.

    Probably a term of the caribbean (where i'm from) perhaps.
    No, structured programming is a valid term it just a bit 'old'. Looking at the history you will see the origins of OOP come out of structured programming.

    http://en.wikipedia.org/wiki/Structured_programming

  10. #10
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: why do they need to create class?

    Quote Originally Posted by superbovine
    No, structured programming is a valid term it just a bit 'old'. Looking at the history you will see the origins of OOP come out of structured programming.

    http://en.wikipedia.org/wiki/Structured_programming
    Correct. Most of the OOP concepts are based on structured programming languages.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  11. #11
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: why do they need to create class?

    I agree the OOP came out of structured programming. What I was saying was for me I learnt structured first without OOP. The transition to OOP was like a big jump. During that transition OOP seemed more difficult, but after I learnt it OOP is a lot better.

  12. #12
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502

    Re: why do they need to create class?

    Well maybe my last answer was more about Object Oriented programming than about classes. In this post I'll try to show a bit what classes are about and what the most obvious advantage is.

    Without classes you would write the following:

    Code:
    Dim person1_Age As Integer
    Dim person1_FirstName As String
    Dim person1_Function As String
    Dim person2_Age As Integer
    Dim person2_FirstName As String
    Dim person2_Function As String
    
    person1_Age = 22;
    person1_FirstName = "Bram";
    person1_Function = "Director";
    
    person2_Age = 19;
    person2_FirstName = "Tom";
    person2_Function = "Village Idiot";
    in a Object oriented language you can write the code above better structured, by creating a class "Person" first, and writing the following:

    Code:
    Dim person1 As Person
    Dim person2 As Person
    
    person1.Age = 22
    person1.FirstName = "Bram"
    person1.Function = "Director"
    
    person2.Age = 19
    person2.FirstName = "Tom"
    person2.Function = "Village Idiot"
    You can also create a "constructor" to the class so that the creation is easier.

    Code:
    Dim person3 As Person
    person1 = New Person("Paul", "CEM", 54)
    So, it's better structured because fields, properties, functions, events, ... are grouped together.

    Because they are grouped you can more easily pass them to functions, put them in lists, or save them to files, ...
    Code:
    SavePersonToFile(person1, "somefile.txt") //is easy to read
    
    SavePersonToFile(person1_firstname, person1_age, person1_job, "somefile.txt) //is harder to read
    But as I said earlier you can also put functions inside the classes. An example of how to use a function which was stored inside a class:
    Code:
    Dim workedHours as Integer
    workedHours = 45
    Dim payCheck as Integer 
    payCheck = person1.CalculatePayCheck(workedHours)
    as for the saving to files, also this gets very clean!
    Code:
    person1.SaveToFile("somefile.txt")
    For me personally this was the first advantage that opened my eyes and made me appreciate OOP. . (Allthough strictly seen there are languages who support this and still are no real object oriented languages.)
    Last edited by BramVandenbon; Jun 20th, 2007 at 01:14 PM. Reason: a bit more
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  13. #13
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: why do they need to create class?

    Quote Originally Posted by JenniferBabe
    I agree the OOP came out of structured programming. What I was saying was for me I learnt structured first without OOP. The transition to OOP was like a big jump. During that transition OOP seemed more difficult, but after I learnt it OOP is a lot better.
    Actually I feel this few years back. Fist of all I start to learn programming with C++, then move Java. There is a big gap, I fell, on OOP and structured programming. After few weeks feel easy to learn, easy to use any OOP language. Just need to get the correct idea about OOP concepts.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  14. #14
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: why do they need to create class?

    Quote Originally Posted by BramVandenbon
    So, it's better structured because fields, properties, functions, events, ... are grouped together.
    And also you can use those groups again and again, in more cases.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  15. #15
    Addicted Member thirith's Avatar
    Join Date
    Oct 2004
    Posts
    196

    Re: why do they need to create class?

    There are many Ideas on this OOP question.
    Surely, you will see when you try to develop a project that related to Business. that need to separate Business from the programing.
    So, the OOP is the way to separate Business logic from you program.
    You easy to manage your group to develop that project.

    For example, after you defined a class or a template that follow your business logic. it will become the standard for your process.
    if other developer want to use this class in the same perspective, they can use existing class without re-code or they can extend by Inherits from the base class.
    ជីន ច័ន្ទធិរិទ្ធ៖ពេលវេលាពុំដែលរង់ចាំអ្នកឡើយ!Time never wait you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width