Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Proper OO Design

    I understand the concepts of OO programming and the benefits but I often have trouble conceptualizing proper design. Most often I have difficulty when writing classes for integrations, like Quickbooks for example.

    I need to write a class for an accounting software integration that uses web services to transfer data.

    I'd be making calls like CreateCustomer, UpdateCustomer, CreateInvoice, GetStock, etc.

    The way I'm looking at it now, I would create a class with a constructor that took no parameters. Then I'd simply call each method as I needed it and pass the necessary data to each method.

    So CreateCustomer would take an array with necessary fields, and then pass that off to internal methods which would generate the xml and send it and handle the response.

    My problem and the reason I think I'm doing something wrong is because when I start coding this I feel like I'm writing a library of methods. It doesnt seem like I'm writing a class.

    I'm just looking for clarification on it. Is this proper OO design?

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You were right to feel weird, that isn't proper OOP design. You wouldn't have all those functions be in the same class, classes are objects so you would have a customer class, an invoice class, a stock class.

    So the customer class would have all the data of a single customer. The invoice class would have all the data and functions for an invoice.

    So then you would create a new instance of the invoice class, and give it an instance of the customer class and then add stock items to it. Then inside the invoice class is where you can do anything you need like totaling the price, calculating tax, etc.

    Does that make sense? Some times it can be really helpful to draw the classes out so you can visualize them.
    OracleGuy

  • Users who have thanked oracleguy for this post:

    0x001A4 (04-01-2011)

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    That makes perfect sense. In fact this answers a lot of my questions regarding proper design. I was taught the concepts by thinking of things like people, cars, animals. Trying to wrap my head around business objects was getting the better of me. I was thinking I'd be instantiating a "Quickbooks" object but I guess I was looking too much at the big picture and not enough at the actual components that go into accounting software.

    That helps a lot, thank you.

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by oracleguy View Post
    Some times it can be really helpful to draw the classes out so you can visualize them.
    yep, totally agree - uml diagram

  • #5
    New Coder
    Join Date
    Feb 2006
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I started drawing it out on paper and have very decent class definitions going. I also have a parent class I'll use for shared methods and properties among classes.

    So last night I downloaded the Modeling plugin for Eclipse and started putting them into a UML diagram. Its coming along nicely.

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by 0x001A4 View Post
    I started drawing it out on paper and have very decent class definitions going. I also have a parent class I'll use for shared methods and properties among classes.
    That doesn't sound quite right. Depending on the properties and functions there might be a different/better/proper way to do it. How about you draw up your UML diagram and post it and get some feedback?
    OracleGuy


  •  

    Posting Permissions

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