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++ » UppHub » QrCode image generation And debuging QR symbology
Re: QrCode image generation And debuging QR symbology [message #45349 is a reply to message #45342] Sat, 31 October 2015 22:12 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Sergey,

So you want to talk about your coding style? Ok let's start:

1. First of all. Never use "using namespace Upp" in your header file. Instead of this use NAMESPACE_UPP & END_UPP_NAMESPACE macro.
using namespace Upp;

class QrEncode {
// ...
};


Should be:
NAMESPACE_UPP

class QrEncode {
// ...
};

END_UPP_NAMESPACE


2. Next simply thing you do in your code regularly is (:
for(int i = 0; i < qrcode->width; i++){


Giv it a space before bracket:
for(int i = 0; i < qrcode->width; i++) {


3. The ternary operator (?Smile should be written like this - more spaces:
int cs = casesensitive ? 1 : 0;


4. Decide where you put brackets in your if statement:
if ( qrcode == NULL ) {


It should be
if(qrcode == NULL) {


5. The valid way to represent if/else if/else block is:
if(...) {
   // ...
}
else
if(...) {
   // ...
}
else {
   // ...
}


You made small mistake here (never use this)
} else {


6. Method/Function arguments is not perfect:
is = Size(20+border*2,20+border*2);


It should be (a lot more spaces - remember to put space after comma, and after/before math operator like "-" or "+"):
is = Size(20 + border * 2, 20 + border * 2);


7. Operator "<<" should have spaces too:
uint8_t m = 1 << (layer);


8. Method/function opening braket starts always in new line:
Image QrEncode::QrEncode_To_Image(String s1){


Should be
Image QrEncode::QrEncode_To_Image(String s1)
{


9. You have got several tabulation/space problems - you can detect this by showing whitespace in your code or use feature show mismatch witespace in newer ide versions.

10. In class constructor QrEncode you have too many enters at the end.

P.S.
All things wrote in this post base on Ultimate++ code. Please notice that there is not official Ultimate++ coding standard. But I strongly believe that all things I proposed will increase your code read ability.

[EDIT - There is more!]
11. "public/private/protected" goes in the same line as class statment:
class QrEncoder {
   typedef QrEncode CLASSNAME;
   public:
      QrEncoder();
   // ...      


It should be
class QrEncoder {
   typedef QrEncode CLASSNAME;
public:
   QrEncoder();
   // ...      


Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Sat, 31 October 2015 22:25]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PolyXML problems with MSC15
Next Topic: CaptureScreenDll with PDF option
Goto Forum:
  


Current Time: Mon May 13 04:00:43 CEST 2024

Total time taken to generate the page: 0.01646 seconds