Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2008
    Posts
    186

    Unanswered: Middle-layer DLL. Am I doing this right?

    In my middle-layer DLL I have several dozen methods. However, there are about 4 categories which these methods can be grouped/categorized into.

    For example, the "Books" cateogry has methods such as: AddBook, AddAuthor, AddPublisher, GetBooks, GetAuthors, etc.

    The "Staff" category has methods such as: AddMember, SetMemberRank, GetMembers, etc.

    Then there's a "Customer" category, and "Equipment" category which contain similar methods.

    My question: I'm thinking of using the following setup for the DLL.

    * Create 4 static classes representing the 4 categories. Then enclose each methods in 1 of the 4 categories
    * Within EACH method, a new connection is created, the respective stored proc is executed, the connection is closed, and any results are returned

    The problem: This DLL will be used by an intranet asp.net app. I'm concerned with the overhead of creating/closing a new connection everytime a DLL method is invoked.

    Any thoughts/comments/suggestions?

    Thanks

  2. #2
    Join Date
    Jan 2008
    Posts
    186
    Quote Originally Posted by dbguyfh
    Create 4 static classes representing the 4 categories. Then enclose each methods in 1 of the 4 categories
    ...And the other alternative is to NOT categorize them, but instead place them all in the same class... The only problem with this is that there will be several dozen methods in this monster class.

    What do you think of that?

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by dbguyfh
    Any thoughts/comments/suggestions?

    Thanks
    yeah. you worry too much. you are welcome.


    what is your alternative?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  4. #4
    Join Date
    Jan 2008
    Posts
    186
    Quote Originally Posted by Thrasymachus
    yeah. you worry too much. you are welcome.


    what is your alternative?
    I suppose it's not that bad, since I do have connection pooling enabled.

    The alternative would be to find some way to reuse a connection... So, perhaps, instead of making those 4 classes (Books, Equipment, Staff, Customer) static classes, I could make them normal classes... Then have a private var inside them to store the connection. This way, I could re-use the same connection (at least for methods of the same category) instead of creating/destroying everytime a method is called.

    Is that any better?

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    I dunno. Whats your environment like? Do you have hundreds of users or millions and what is the hardware like. Chances are, and I am willing to bet you dollars to donuts that you have enough resources at your disposal.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  6. #6
    Join Date
    Jan 2008
    Posts
    186
    Quote Originally Posted by Thrasymachus
    I dunno. Whats your environment like? Do you have hundreds of users or millions and what is the hardware like. Chances are, and I am willing to bet you dollars to donuts that you have enough resources at your disposal.
    No not millions. Likely somewhere in the hundreds, or possibly approaching a thousand.

    So, likely, you think that whether I open/close a connection upon every method call versus opening it upon instantiation of a "category class" (and disposing when finished with it) won't make much of a difference at all?

  7. #7
    Join Date
    Jan 2008
    Posts
    186
    BTW: What do you think of the approach of using these "static classes" to act as a container for methods of similar functionality.

    Is there a better (more proper?) way of doing it?

    Like I said earlier, the alternative is to put all methods in the same class and not cateogrize them.

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    unless you are running your app on a set of toaster ovens, you will be fine. open and close connections as you need them and let SS take care of the connection pooling. you are probably not more clever than the boys in redmond.

    it's been 60 days since I wrote any object oriented code, and although I am always praised for my elegance, I am no expert in OOP.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

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