Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

separate scripts vs a few larger general ones

Posted on 2014-09-05
7
Medium Priority
?
184 Views
Last Modified: 2014-09-06
Hi,

I would like to know if it is more advantageous to have a singular script that contains either one or very few (1-3) functions / classes  or have a larger scripts that contain more functions / classes. in each instance the functions / classes would be related and likely be required in the same documents but with the larger ones i would not nessecarily use everything within them where as the smaller ones i could just include the ones i need.

thoughts?

thanks in advanced?
0
Comment
Question by:J N
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40307077
This question is a little like, "Should I date a blonde or a brunette?"  It depends on personal preference.  Here are my thoughts...

1. Disk I/O operations take a lot of time -- up to 3 orders of magnitude more than in-memory operations.  It follows that autoloaders, numerous include() statements, and the like are expensive in deployed applications.  Visit any WordPress web site to see the effect.

2. Web sites that are built out of parts, but are deployed in combined scripts, can be much faster to load, but require more steps to maintain.  You have to make a "build" yourself -- the automation from autoloaders is not there.

Which do you want?  Fast or easy?
0
 
LVL 6

Author Comment

by:J N
ID: 40307084
Thanks!


fast vs easy is not really what im after im more concerned with efficiency. If a method is faster but requires me to cut corners than i am not interested. However, if fast means more efficient than that is exactly what i am looking at
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40307127
In loading time, fast always means more efficient.  However, putting common routines in 'include' files makes it much easier to maintain because you don't have to forget where you are using them.  Every time you edit or change the include file, the changes are automatically 'include'd in every page that uses it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40307482
fast vs easy is not really what im after
Grab a copy of YSlow and use it to analyze a couple of sites.  I recommend you analyze http://sscce.org and https://www.healthcare.gov to see and compare the behavior of each.  I'm not suggesting that you avoid all include() statements; I'm suggesting that one include() that loads many classes is w-a-a-a-y more efficient than having individual class autoloaders.  If you're not familiar with class autoloaders, read this and also look up Composer.  This is the way many high-level developers are organizing their work today.  I do not think a deployed application should be organized that way, and I think when you do your homework with YSlow you'll come to the same conclusion.
https://addons.mozilla.org/en-US/firefox/addon/yslow/
0
 
LVL 6

Author Comment

by:J N
ID: 40307782
Thanks Ray!

Im not loading very many libraries so i dont think i need to worry about composer. The only libraries i really use is jquery and bootstrap.


from what i gather you are suggesting i write a larger resource script and include it rather than individual classes and creating an autoloader function?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 40307856
Here's the thing as I see it.  If I can have 10 classes in a single script and use include() (really, require_once() but they are essentially the same thing) in a deployed application, I will have better performance than if I have 10 auto-loaders.  OTOH, if I have 10 employees working in different locations on different classes, the auto-loaders will help ensure that the development environment always uses the latest versions of their classes.  The "build" process can usually leave the auto-loader in place, because once the large include() script is built, all of the classes will be declared when they are included, and the auto-loaders will not have to do numerous extra disk searches.

Does that make sense?  Really, I think once you see the output from YSlow you will see the concept very clearly.
0
 
LVL 6

Author Closing Comment

by:J N
ID: 40307938
Thanks a lot !!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question