473,789 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to make good use of includes

Because my functions tend to become rather lengthy I split up the
functions for each subject or action in a function (a) that checks
user input (filter and validation) and if this checks out ok it passes
the variables to another function (b) that retrieves or stores the
data from/in the database, function (a) then communicates the result
(true, false, error, list with data) to the client.
Currently I organized all functions per subject (all functions that
handle for example 'groups': get, add, modify, delete in a file) and I
include all the files when the webservice is called, this is over 500
kB.
A different approach would be to only include the functions needed,
this means a file for each function, so a lot more includes.

What is a good approach ?

Pugi!
Dec 29 '07 #1
1 1487
On 29 Dec, 18:51, "Pugi!" <pugin...@gmail .comwrote:
Because my functions tend to become rather lengthy I split up the
functions for each subject or action in a function (a) that checks
user input (filter and validation) and if this checks out ok it passes
the variables to another function (b) that retrieves or stores the
data from/in the database, function (a) then communicates the result
(true, false, error, list with data) to the client.
Currently I organized all functions per subject (all functions that
handle for example 'groups': get, add, modify, delete in a file) and I
include all the files when the webservice is called, this is over 500
kB.
A different approach would be to only include the functions needed,
this means a file for each function, so a lot more includes.

What is a good approach ?

Pugi!
You're currently loading 500 kB of code for every request? That's not
good.

Firstly, even if you are running a webservice, a front controller
architecture undermines on of the fundamental concepts of HTTP -
addressability. There should be multiple entry points for different
areas of functionality.

Since you seem to be taking a procedural (or possibly) functional
approach to programming, IIRC the autoloader functionality will be of
no benefit.

Without knowing what your webservice does and what interfaces it
provides it is difficult to say how it should be split up but I'd say
you should definitely be looking at conditional includes based on the
entry point or request details and splitting up the functionality to
get the optimum number of files (e.g.
- one include file for soap parsing and input validation,
- one for database connectivity/dbms abstraction
- one which interfaces to the request specific include files (below)
and generates the output
(the above would be included every time)
- one for adding records of type 'A'
- one for deleting records of type 'A'
- one for updating records of type 'A'
- one for adding records of type 'B'
....

(note that although validation should be done at entry, encoding
should be done at the point the datum exits PHP to be written to the
browser or the database or somewhere else.

C.
Dec 30 '07 #2

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

Similar topics

31
3850
by: Bruce W...1 | last post by:
This is a best practices question. For a website where PHP is used, does it make sense to have both .htm and .php files? In other words, for pages that have no active content there's no point in naming them with a .php extension. Is there any advantage or disadvantage to making all files .php, or the same for mixing them with .htm files? What do you do, and why?
14
4529
by: BOOGIEMAN | last post by:
Well that's it, how do I make Windows Application with Python ??? Is there simple way that works 100% ? How can I rework visual design done in VS 2003 to use it for my python program ?
15
7410
by: tom pester | last post by:
Hi, Im new to php and have a background in asp. All the help is very much appreciated. today I was using the include function in a file that itself gets included : *************** consumer.php : <? include "inc.php" ?> inc.php : <? include "Common/functions.php" ?>
5
3802
by: frankhall36 | last post by:
Yeah, I need some help, I'm not a very good programmer but I've tried a lot of languages, and anyways, I want to start applying programming to physics, and I would like to learn how to make a Variable Type for a little program I am making. Basically a 32byte or up sized long double (which is 16 bytes from what I was told). I just really want to learn how to be able to declare my own type so that I could do things with very good...
52
4123
by: mavic | last post by:
hi to everybody,i need help for my project....how to make a program that accept any integer and convert it binary,octal and hexadecimal.pls help me...thanks
42
3172
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional array (size is 10*10), setting all the values inside the 10*10 matrix to zero. My C-function looks like this:
9
2218
by: xz | last post by:
What sense do h files make in c/cpp? I never thought about this question before. Does the existence of h files make sense at all? Why do we need to declare functions in h files and define/implement them in cpp?
0
275
by: JM | last post by:
Because my functions tend to become rather lengthy I split up the functions for each subject or action in a function (a) that checks user input (filter and validation) and if this checks out ok it passes the variables to another function (b) that retrieves or stores the data from/in the database, function (a) then communicates the result (true, false, error, list with data) to the client. Currently I organized all functions per subject...
9
2108
by: GloStix | last post by:
Okay, when I click the link it dissapears and makes a white space underneath it but the space is clickable. so when you click the space, the link actually works Used Firefox 3.0 RC2 for this. OS X 10.5 http://www.screencast.com/t/wgztYUrdN (Video) http://www.jameswmann.com/music.htm (The actual page) HTML
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10374
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5539
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.