Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » is there U++ coding style reference?
Re: is there U++ coding style reference? [message #27637 is a reply to message #27636] Tue, 27 July 2010 12:02 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
The only Upp style thing that caught me out was with references. Upp style (Mireks style really) is to put the ampersand with the type:
int& parameter

but I don't worry too much about this in my own code, only when committing packages to the bazaar. Otherwise Upp matched my previous style very well (one of the reasons I liked it in fact).

I too prefer constructors at the top of the file. I also attempt to keep functions in the order in which they appear in the header for easier browsing, but this often goes astray. For clarity I usually put static variable definitions, CH_STYLE and other housekeeping stuff at the bottom.

The new/delete stuff is very important IMO, since it's what separates Upp from almost all other C++ code. The rule is NEVER use new/delete. It's very unlikely you'd need something that the Upp containers can't do but in that case you should create your own simple containter to encapsulate the allocation and deallocation of memory. Then you never have to worry about memory leaks in application code (bar some special cases with statics).

The only caveat to this is that you want to use it for window management of non-dialog windows. For example:
class MyWindow : public WithLayout<TopWindow> {
  virtual void Close() { delete this; }
};

void NewWindow()
{
   new MyWindow()->Open();
}
though personally I would avoid this if at all possible.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: using Ctrl::Add; required for templates / overloaded virtual functions
Next Topic: dll instead of exe
Goto Forum:
  


Current Time: Mon Aug 25 16:14:52 CEST 2025

Total time taken to generate the page: 0.09698 seconds