473,800 Members | 3,007 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 1489
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
3851
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
4533
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
7411
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
3803
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
4143
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
3175
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
2110
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
9694
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
10509
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...
1
10256
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10039
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...
0
9095
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7584
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
5612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4152
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
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.