473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Balancing speed against OO design - optimization issues with PHP/MySQL

Hi all, a request for opinions, please.

I am designing a smallish application to manage members of several
committees of a particula Organization. The structure of the system is as
follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.

Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible. Efficient from a speed
point of view. However, from a coding/OO-style point of view, it makes
more sense to have each People object be defined as *one* person -- but
that would mean that each has data for only one person and that would mean
a separate SELECT statement for each People object created. (Assuming that
there is a SQL SELECT in the constructor of each People object or
something similar to that).

Traditionally (i.e. non-OO), to code this, I would do as few SQL calls as
possible. But I can't see how to do that from an OO point of view.

For example, does it make sense to put all the people data into an array
outside of the People class and use this list to set up the class
constructor? (It doesn't make sense to me)

Or, for example, does it make sense to have the People class just be a
list of *everyone* in the people table? (This too does not make sense to
me)

On the other hand, what is the performance impact if I *do* make each
People class instance be only *one* person?

Allright, I hope this makes some sense. Thanks (in advance) for the advice!

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #1
3 2130
"Jeffrey Silverman" <je*****@jhu.edu> wrote in message
news:<pa****************************@jhu.edu>...

I am designing a smallish application to manage members of several
committees of a particula Organization.
Notably missing from your description is the proposed functionality
of your software. In other words, you want suggestions as to HOW
to design the software without explaining WHAT this software has to
do.
The structure of the system is as follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.
Why even bother with 'theOrganization' and 'Committee'? They are
nothing but simple arrays... Also, to make things worse, technically,
'theOrganization' should be a singleton... :)
Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible. Efficient from a speed
point of view. However, from a coding/OO-style point of view, it makes
more sense to have each People object be defined as *one* person -- but
that would mean that each has data for only one person and that would mean
a separate SELECT statement for each People object created. (Assuming that
there is a SQL SELECT in the constructor of each People object or
something similar to that).

Traditionally (i.e. non-OO), to code this, I would do as few SQL calls as
possible. But I can't see how to do that from an OO point of view.
Which leads me to asking, why do you want OO design here in the first
place, if it is to result in lousy performance? Sounds like you are
deliberately setting yourself up for a failure...
For example, does it make sense to put all the people data into an array
outside of the People class and use this list to set up the class
constructor? (It doesn't make sense to me)

Or, for example, does it make sense to have the People class just be a
list of *everyone* in the people table? (This too does not make sense to
me)

On the other hand, what is the performance impact if I *do* make each
People class instance be only *one* person?


These questions would make sense if you were writing a desktop
application. But you're not; by choosing PHP as your development
tool, you have automatically abandoned the traditional concept of
application. You are not designing a monolythic package; rather,
you need to come up with a collection of relatively independent
utilities or modules, each suited for a narrowly defined task.
Until you figure out what those tasks are, you won't be able
to come up with a decent design.

Cheers,
NC
Jul 16 '05 #2
Hi Jeffrey
I am designing a smallish application to manage members of several
committees of a particula Organization. The structure of the system is as
follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.

Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible.
&c


Don't struggle with this.

Design your objects with a proper hierarchy.
Trust your database engine - you have no choice unless you build it
yourself.
Address the database engine properly using your preferred language with
correct reference objects.

And get on with things. :-)

Best regards,
Neil
Jul 16 '05 #3
On Mon, 11 Aug 2003 23:39:11 +0100, Neil White wrote:

<snip!>
Don't struggle with this.

okay, thanks, I won't
Design your objects with a proper hierarchy. Trust your database engine -
you have no choice unless you build it yourself.
Address the database engine properly using your preferred language with
correct reference objects.

And get on with things. :-)


Okay, thanks. In fact, I already have. And it turns out that I think I was
needlessly concerned.

But that's okay -- I just wanted some general opinions in this regard. And
I got some.

later...

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: J. Campbell | last post by:
Hi everyone. I'm sure that this is common knowledge for many/most here. However, it was rather illuminating for me (someone learning c++) and I thought it might be helpful for someone else. I'm...
3
by: Shabam | last post by:
When a web application becomes overloaded with traffic, one can offload it by load balancing and clustering the front end web servers. What happens when the back-end MSSQL database becomes...
40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
43
by: Davey | last post by:
I am planning on developing an application which will involve skills that I have very little experience of - therefore I would appreciate comments on my initial design thoughts. Overview on...
7
by: YAZ | last post by:
Hello, I have a dll which do some number crunching. Performances (execution speed) are very important in my application. I use VC6 to compile the DLL. A friend of mine told me that in Visual...
10
by: GeekBoy | last post by:
Okay, I have two identical web servers running Windows 2003 web server. I have an ASP.NET application which runs great on one of them. Dedicated IP address, behind our firewall, etc. Everyone's...
7
by: Michael | last post by:
I'm writing an application that decodes a file containing binary records. Each record is a particular event type. Each record is translated into ASCII and then written to a file. Each file contains...
12
by: PD | last post by:
I am currently making a dating website. I want to have some information on how to structure the database and the php files so that I can achieve speed and efficiency. Can some one please give...
4
by: Pseudonyme | last post by:
Dear Sirs and Madams, Receive as information that storing a MYSQL result under $_SESSION was accelerating web page displays processes ? Absolutly needed but impossible to get this working ! I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.