Mmm... for web dev I like URL based file organisation to a degree... It depends alot on the system that's in use though; some systems work better if you organise your application code around the locations where a user is likely to use it, and in a way that's a background intention to PHP; "I can put a program anywhere on my server!". Although; personally, I don't think PHP itself brings many new principles to ANY kind of development.

What I personally dislike; is the seemingly magical index.php; which spits out different content based on a 'page' query string - I like folder division and file-naming based about functionality; in the same way as I would when working with Word documents offline; I like to see 'descriptive URLS' that indicate the web developer has a modular, flexible, and most importantly content-centric site... Otherwise; if it just feels like a site, that is clearly organised around one central, versioned 'application', that feels like it isn't going to be a constant source of useful information. And hey.. don't use URL rewrites to mask out your index.php?page=home.. I'll see right through it ^_-

That applies with or without server-side code; HTML pages have an inner hierachal structure; it makes a helluva lot of sense for that hierachy to spill up into the filesystem aswell..

Program code organisation; I need some levels in there; it pertains to easier updates; plugins; automatic compilation rules; even runtime 'special effects' if it's an interpretted language.

I'd say a good folder hierachy is possibly the most important thing to me if I'm going through someone else's code... It's easier to know where to start looking for something by looking in the obviously named folder; than by following a trail of includes/imports/codepulls/magipeeks.

But, that means intelligent division of code into files has to go on somewhere. PHP among other interpretted languages doesn't always pertain to good division of code into 'class files', or even into classes atall... Still even C(++) has that problem.

Java's gotta win outright for 'forcing' division of code into files; and even division of code into folders if one wants to use hierachal packaging within code.. I'm sure they nicked/borrowed that idea from somewhere though; but I'm not old enough to have experience of such things =P

My thoughts:

- How much whitespace you use depends on how much content you want, vs how much you have to pay for server memory and download bandwidth.

- I use only one space for each indent in tight memory situations. But I use a monospace editor font.

- I have only one level of indentation for each table:

<table><tr>
  <td>contents</td>
  <td>contents</td>
  <td>contents</td>
</tr><tr>
  <td>contents</td>
  <td>contents</td>
  <td>contents</td>
</tr></table>

- I base my decision of whether to use tables or divs to format the page by how I want the page to fail it the browser window is too small:

-- When div is used with Mozilla, it overlaps the elements (especially images) on the screen when the browser window is too narrow.
-- When div is used with IE, it collapses the horizontally spaced elements into a vertical column when the browser window is too narrow.
-- When tables are used with either Mozilla or IE, a horizontal slide bar appears at the bottom of the screen, and the display is wider than than the window.

- I totally can't stand the variable name standards which originated with c (probably because I think C is one of the third worst programming language). I string together enough characters to do the job, e.g. digindx for digit index.

- I usually choose code to reflect the mix of browsers I expect to be using it, but I also realize that if I use deprecated code, I will have a big job to do later.

commented: "I base my decision of whether to use tables or divs to format the page by how I want the page to fail it the browser window is too small" < Very True. Let's hope they fix CSS up properly sometime soon >_< - Matt +2

Ok, it isn't actually a PHP thing to use index.php or similar as a central hub and feed contents based on parameters... MOST enterprise solutions basedon Java do this too... they will have 1 system servlet which processes the URL and determines what files to include and/or forward control to as it serves the request. it is not uncommon to see:
http://intra.ibm.com/portal?cmd=page&obj=start.htm
or similar... often these URLs are huge and look awful, but they do the job and keep everything organized for the system well...

They typically have shallow folder structures, with similar contents being grouped into common locations so that URLs can be shorter allowign for longer parameters... also avoiding long file paths into a parameter list... since file paths can be MUCH longer than a URL is allowed to be...

THUS the main problem with folder structure that minics the site... if the site is several clicks deep with descriptive names, then the URL length limitations can become problems...

THIS is an even bigger problem when creating system for internation use... we have to think outside the "English Box" for a minute...

Each Japanese character that I may have in folder name, will take at least 6 characters in the URL to represent, possible many many more... so now we have taken that URL limitation and reduced it at best 1/6th the number of useful characters...

I have actually had to debug a system for an Enterprise Software vendor where this was the problem... the idiots never fixed the main code stream so each time they localized the application's new version the SAME bug popped up and customers complained until they fixed it AGAIN... only to have it come back again....

"Think ahead" was one of my hints, right? Avoiding problems is easier than fixing them....

Unless URLs allow the same characters as File Systems, and the path length limitations are the same, eventually there will be problems, especially if anything you build is to be used outside of the small English world...

I design EVERYTHING to internationalized from the start, so that it can be localized... not internationalization and localization are NOT the same thing...

But internationalizing things means thinking ahead and planning to avoid the problems that may be likely to occur...

Java stole the OOP from C/C++... C++ was referred to as C with classes.... C has "struct" which is not quite the same, though they have made some enhancements over the years to make it more similar to C++ classes... But there are serious findamental differences...

The reason C/C++ win out is simple... They NEVER take away your power to be in control and make your own design decisions... But with great power comes great responsibility, hey, where did I hear that...

Java took away a GREAT deal of the developer's power in exchange for the ease of use and portability....

Java HAD to force the classes in order to operate correctly... thus the file names MUST share the name of the class, excpet for application files with a main function...

Static objects can't call non-static ones, etc...

I used PHP to build an entire online application, and that was before PHP even had classes... then with PHP classes, I was able to do it better... Now classes have been enhanced, but still are NOT upto my expectations for encapsulation... So I turn to Java for my large scale projects and reserve PHP for my smaller scale projects... Though I am designing a system that will use BOTH together... by having PHP do some things and Java/JSP do others, I hope to achieve a synergy of performance by have Apache and my App-Server running in parallel to generate the contents in a way seldom, if ever, done before.... I won't say anymore...

Now, I promise the way I used mod_rewrite you would never know it was being used... I have a site where there was a key design requirement for search engines to index it in a certain way... by using mod_rewrite and dynamic URL generation, I was able to provide the crawlers with what t they needed to get the job done in a way completely not possible with spiders files... I don't want to give anything away but lets just say that even the best optimized crawler in th world would take a long, long time trying to crawl my site, finding ALL those parameterized pages, with every possible option and every possible combination despite the fact they usually are limited to 3 parameters... It goes way beyond that... but that is enough... and I would defy anyone to try and figure out from looking at it that it was using mod_rewrite... you just have be clever in how you use it... most people aren't....

I just want to say that you are misleading a bit about the behavior of div tags in the respective browsers... You describe 1 case where they are used in one way. The problem is that when you, as the developer, fail to properly format your divs, the browsers use defaults, and each browser is likely to have different defaults...

I have built some examples for a customer of mine whose in-house web designer, and I use the term loosly, only knew how to use tables to achieve his desired effect... BUT tables are not what they really need...

In my examples, I have several with different layouts, if the browser is resized to be smaller than the screen horizontally, scrollbars are shown just as users expect of browsers today...

First my examples are designed to automatically adjust between a range of "supported" sizes... if the browser goes over or under this size range, it take the max or min default setting and uses it... i.e. scrolls if needed... Just like this DaniWeb site, I have one with beveled edges to the sides of the content. I have one with beveled edges all around (left-right-top-bottom) including the corners which blend together so it "frames" the page, and I have one with top and bottom banner/menu bars which always stay on screen with beveled edges to the left and right and the document scrolls up-down between the banner/menus on the page... I have several more....

The total code to achieve these effects is a couple dozen lines, if that, including the resizing etc. and it represents something that can't be done with a table at all.... or at least not without some serious power coding... I don't like to say anything is impossible... the moment you do, someone comes along and does it....

In fact that was how I first fell in love with programming... When I was a kid in school, I asked my teacher how I could do something... I was learning to program back when you still had to load the bios on startup then load the dos and after 10 minutes of starting-up the machine you could start working, when we thought the addition of an an external 5.25 Inch floppy meant you were in serious business mode.... Anyway, he said I couldn't do it, he said computers just can't do that... I won't say what it is, but todays computers do it without qestion... Back then it was unheard of... I didn't like his answer so I decided to find a way to do it... My math teacher was moonlighting as a computer teach at the local college so I asked him for help figuring it out, within a week I had a working proto-type and the when the programming teacher saw it he just couldn't believe it...

The next year I was teaching his computer class while he taught physics in the next room... A short few years later the Mac was released and it could do, out of the box, what I had spent so much time trying to sort out...

The moral is, never say anything is impossible, just admit either YOU don't know how, or it could be done with a whole lot of work... In some cases the questions is, "Is there a better way?"... like using Tables for layout, there is ALWAYS a better way, you just might not know it yet...

But I admit, it is sometimes a quick way to do something and just get it done...

Peace,
;)

My thoughts:

- How much whitespace you use depends on how much content you want, vs how much you have to pay for server memory and download bandwidth.

- I use only one space for each indent in tight memory situations. But I use a monospace editor font.

- I have only one level of indentation for each table:

<table><tr>
  <td>contents</td>
  <td>contents</td>
  <td>contents</td>
</tr><tr>
  <td>contents</td>
  <td>contents</td>
  <td>contents</td>
</tr></table>

- I base my decision of whether to use tables or divs to format the page by how I want the page to fail it the browser window is too small:

-- When div is used with Mozilla, it overlaps the elements (especially images) on the screen when the browser window is too narrow.
-- When div is used with IE, it collapses the horizontally spaced elements into a vertical column when the browser window is too narrow.
-- When tables are used with either Mozilla or IE, a horizontal slide bar appears at the bottom of the screen, and the display is wider than than the window.

- I totally can't stand the variable name standards which originated with c (probably because I think C is one of the third worst programming language). I string together enough characters to do the job, e.g. digindx for digit index.

- I usually choose code to reflect the mix of browsers I expect to be using it, but I also realize that if I use deprecated code, I will have a big job to do later.

commented: "never say anything is impossible" < I've gotta agree with that - Matt +2

Folder nesting doesn't need to be too deep.. About a depth of 3 is probably more than enough; provided there's some top level grouping*. Any more; it is just over-classification, that could probably be better solved by tighter / stricter classification.

I gotta say, there's a big difference between centralizing the application and centralizing the navigation experience / interface about an all serving singularity.. The application can be centralized and act upon a distributed collection of files as they are requested; by means of handlers; even mod_redirect. That's quite different from using one script as the means of serving all requests; it's certainly my prefered technique =P. Hey; I'd rather not go too far divulging my own behind-the-scenes work; but I use that as a way of getting the best of both worlds - I can keep my application high up in /home/me; but still use it to process XML-based scripts in any folder a user requests... as long as the file ends '.xrm'.

Hey... with Java; it's worth the trade-off sometimes. Other times; perhaps not. The whole Java structure-of-an-application, although rigid, affords flexibility; and forces a developer to conform to good organisation practises ( hey; that's an opinion =P ). C++ is a more interesting language for sure; but Java is a powerful language in terms of capability; and the fact it doesn't need to be recompiled for every target OS is a huge advantage in my eyes.

Hm.. C++ Templates whup Java Generics 10 times over though..

* by "top level grouping"; I mean grouping into 'public_html', 'cgi-bin' etc if we're on Apache.. gawd knows what MS server OS's do... My Documents?..

In MS IIS you can create a web share out of any folder on the machine, and assign it a URL in the IIS admin tools, so you very well could use My Documents if you really wanted to... But realistically, no one does that... There are some default forlders for FTP and HTTP sites on an MS server and these are typically used to place subfolders... I like the WEB-INF structure of a Tomcat like app-server because it afford you a great level of security for your includes, etc. for example, I have servlets that may process a request, perhaps they set result values in a bean then they forward the request to a page to display the results... I don't EVER want this page shown unless they came through my servlet, so I place it under WEB-INF or some sub-directory of WEB-INF and it is protected as I want...

Java allows you to forward the request to another page to handle which is something most other server side technologies doesn't support... This brings me to another point... This is typically what is happening with those centralized enterprise systems... the system module doesn't actually do ANY of the work, it simply determines which "workflow" to take and steps the request through...

i.e.
You access intra.ibm.com/portal
the system servlet "hcl" takes you requests and sees you have an active session and are properly logged in... since there is nothing else in the paramters it selects the default workflow and forwards the request to the start page handler... The start page handlers takes the request, gets your user id fromt he session and finds the page set as your default start page in the database, and forwards the request to that page... The URL doesn't change, it is NOT a browser forward which would alert the user, but an internal forward so users are unaware of exactly what happened... they just see their correct start page shown...

Then the user selects a link:
intra.ibm.com/portal?cmd=new&obj=folder

The system servlet "hcl" sees the session, the correct login, the cmd parameter and the obj parameter and selects the workflow for creating a new object, forwards the request to the object manager. The object manager sees the cmd parameter and knows we're create something new and the obj parameter tells it what type of object... It selects the page with the form, for example, for naming a new folder... Then forwards the request to that page... etc. etc. etc.....

The system servlet is like a router, nothing more... this also keeps the URLs reasonbly short as they don't reflect the actualy structure of the file system... which is good, because having your file system exposed to the public is a good place for hackers to begin their attacks...

Don't getme wrong, I like Java, I enjoy programming in Java. But long before there was Java I could program the same way in C++, total OOP, but when I want to build a power tool, I don't use Java... I built a hard disk cleaner last year using Java... it will wipe clean any unused hard drive space... but since Java couldn't tell how much space was available on a hard drive until the recent release of version 1.6, this could not have been built the way I needed it prior to that... That change request had been issued to the Java Developers more than 7 years ago, but they never got around to doing something that sounds so basic... how big is the drive? how much free space is there?...

C++ is ALSO write once, run anywhere... you just have to compile the code for theplatform you want to use it on... unless you use native libraries that only work on one platform, it will run anywhere... you can also build switches into the make process to automatcially select compatible libraries on different systems when you compile it...

New is, Java STILL has to be compiled for every system... the JVM must be built to run natively and it has to compile the Java byte code prior to running it... so in essence you are doing the EXACT same thing, you just allow someone else to write those make routines to select the native libraries...

In their attempts to do write once, run anywhere, they ran into problems an settled on least common denominator, which is why the AWT looks like something that comes out the wrong end of my dog... This is why Swing was designed.... but that makes greater use of native librabries... and still we don't see true write once run anywhere...

So, when I want true speed and power, I fall back to C++ and when I want a robust, web architecture with rapid development and PLENTY of open source tools to rely and build on, I use Java. When I want a quick, simple yet full featured web design I roll over to PHP... If they would just complete the OOP aspects of PHP, they would have something to rival Java on many larger scale projects too...

Don't forget inheritance... multiple inheritance in C++ vs simple inheritance in Java...

C++ takes the DNA logic... if you are born of two or more parent objects, you should be able to inherit from both... I know I am certainly part my father's son; fast cars, real attitude, workaholic and part my mother's son; stuborn and kind.... I have my father's hair and my mother's feet... which means I ware shoes so big you could water ski in them and hair so light you might think I was bleach it... I don't... But compared to my father's small feet and my mother's red hair... it is obvious I inherit from both... BUT if I had been made by Java, I would have been ALL my father's with some modifications, or ALL my mother's with some modifications...

And with C++ it doesn't stop there you can have a cocktail of donnor parents, like the movie twins... take the best and be Arnold, or the worst and be Danny... But you get multiple options to choose from...

That is one place Java will likely never catch up... C++ outshines them all on that one... a major aspect of OOP too....

Peace,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.