performance vs. oop

Results 1 to 2 of 2

Thread: performance vs. oop

  1. #1
    Join Date
    Dec 1969

    Default performance vs. oop

    Whith we should structure better the code than other server-side languages due to object oriented programming. The issue is: how many performances are we going to lose?<BR>I’m developing a forum in During analysis phase I guess I was undermine performances! I’ll do an example.<BR>Suppose I want to write a control to visualize a thread of my forum. I can do this in two ways:<BR><BR>CASE I:<BR>I create my class called Thread containing a collection of Posts (another class) and other variables. When a user request the page I include in it my control ThreadViewer which fills a variable (say CurrentThread) of kind Thread, and create the page basing in this variable. To fill CurrentThread I use another class, called SqlDataProvider. This class has a function which takes thread’s ID and gives a variable of kind Thread.<BR><BR>Advantage:<BR>- My package is structured! This means that user can write a class, say MdbDataProvider, and use it in his forum<BR>- …code well structured…and all other oop advantages…<BR><BR>Disadvantage:<BR>- It’s not hard to understand that this solution (versus the one below) will use a double memory quantity: first it’ll open a database connection and then it will fill a variable of Thread class with a COPY of data contained in database connection. This just to give to ThreadViewer a variable of Thread class.<BR><BR>CASE II:<BR>I create my control called ThreadViewer that directly read from database each data it needs and write these data directly in output stream<BR><BR>Advantage:<BR>- Optimized memory<BR><BR>Disavantage:<BR>- The control depends from data structure: to change data structure you have to rewrite the control.<BR><BR>What does you suggest me?<BR>Perhaps the example above is not the most right one…but I hope you have understand the point of my discussion.<BR><BR>Thank you in advance.<BR>Bye.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: performance vs. oop

    Write it the way it will be most easy to maintain. Afterwards, you can then go back and make adjustments for specific problems. For example, you can optimize a certain part if it&#039;s using too much memory or runs too slow.<BR><BR>Keep in mind the adage: "Premature optimization is the root of all evil"<BR><BR>Mike

Posting Permissions

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