Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Coding Style


nezda

Recommended Posts

Posted

I have been browsing the osCommerce source today. This is the first large piece of PHP code I have looked at, although I am quite a competent developer in C, C++, and Java. IMHO, the code is very difficult to read and navigate due to its formatting. Some lines are 200+ characters long and the code feels very vertically cramped -- it almost appears machine generated. How do osCommerce developers view the code so that they can see it all and understand it quickly. Word-wrap or higher resolution (6000*4000??) are not enough to make this code readable. Why is the code formatted this way rather than breaking lines at logical points around the +/- 80 character column and using white space to offset logical chunks? I realize some of the code is embedded in HTML, but the PHP blocks are free to use whitespace in any manner.

 

Please do not misunderstand, I mean no disrespect, the code is very clever and functional, it is just tough to read and therefore maintain.

 

How do others feel about this?

Posted

Well, I felt the same initially, but now I use editplus, which has nice code highlighting functions.

Basically different HTML elements are different colors to PHP elements, also it has word wrap + line numbers, so you can very quickly see which lines are wrapping.

 

I found after a while, it all became clear, you get used to looking at it and picking it out to the point where its like reading straight text..

Posted

I agree that the code is hard to read, but I do something about it.

 

Whenever I'm modifying a file, I take about 30 minutes to an hour to go through the entire file and document almost every line. Anything that might not be quickly understandable gets a comment right above it. Most of my files are commented now, and I'm getting a better feel on how the whole engine is put together.

 

- Jonathan

Download osCommerce Order Editor v1.2 Here:

http://www.oscommerce.com/community/contributions,1435

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...