Jump to content

[SOLVED] The server - enemy or friend?


origil

Recommended Posts

Hey,

I am new to php programming and I come from a C++ background.

 

My general question is how to write my webpages as there is a lot of code reuse.

In C++ I would include many files to a page, making many functions accessible to them, thus reusing code efficiently.

This greatly speeds up development time and perhaps only slows compilation time by a bit.

 

In Php, however, I am afraid this might slow down the server.

For example, I have 2 choices:

 

1. The ugly and maybe faster for the server way: Copy paste a lot of code and modify small parts. (Example: I have many pages dealing with text input forms - same structure, only different names to forms)

 

2. The nice clean but maybe slower for the server way: Create functions that generate the desired html code. As well as include some of my php function files I might not use in some pages.

 

I would go with option 2 if I only knew how much extra work is there for the server. Is this a consideration?

When a website has 10 users this would not matter. But what if there are a thousand users? How much of an issue is this on the long run?

 

Thanks in advance,

Ori

Link to comment
Share on other sites

The actual execution time between 1 & 2 would be minimal. I wouldn't even worry about it. Of course you should always code for code reuse, includes run as though the code is actually within the same file. As for including functions that you may not use in every page, I wouldn't worry too much about it.

Link to comment
Share on other sites

Isn't Nice Clean Code Much Easier To Read For The Server Than Ugly Code

 

 

 

Well... When It Comes To It I Value The Layout Of My Code..

But Thats Only So It's Easy On My Eyes

 

 

 

 

 

 

 

OFF TOPIC:

And Can I Ask - Is C++ Like C#? I Tried A Bit Of C++ And Gave Up And Switched To C#

And Also What Software Do You Use? (I Used Visual C# Express + Visual C++ Express)

Link to comment
Share on other sites

Thank you all for the replies.

Phew...  ;) Option 2 it is then. No more ugly code!

 

Traun, as for your off topic question,

I am not too familiar with C# but as I heard it is a higher level language than C++.

Meaning it simplifies many development issues (which leads to faster development) but cannot compete with file sizes and execution time.

The syntax is highly similar to C++ but C# also has shares many of the Java features.

I guess overall it is an improved version of C++: does more work for the programmer and is more strict on many issues which often lead to many bugs in C++.

About slower execution time and file size - a really small price to pay with today's hardware. (Just as assembly is faster than C++).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.