/
home
/
Programming
/
Style
/
Curly braces { }
should be used on all conditionals, and thensome.
- // Bad
- if (sneed)
- {
- feed();
- seed();
- }
- else
- {
- chuck();
- }
- // Good
- if (sneed) {
- feed();
- seed();
- } else {
- chuck();
- }
- // Bad
- void sneed() {
- feed();
- seed();
- }
- // Good
- void sneed()
- {
- feed();
- seed();
- }
- // Bad
- void feed() { seed(); }
- void formerly() { feed(); seed(); }
- void sneed() { chuck(); seed(); }
- // Good
- void feed () { seed(); }
- void formerly() { feed (); seed(); }
- void sneed () { chuck(); seed(); }
- // Bad
- int sneed()
- {
- Chuck c;
- c.setSeed(1);
- c.setFeed(2);
- c.init();
- Chuck d;
- Farmer farmer;
- if ( farmer.isSneed() ) {
- c.setSeed(3);
- c.setFeed(4);
- } else {
- c.setSeed(5);
- c.setFeed(6);
- }
- Chuck e;
- e.clear();
- return c + d + e;
- }
- // Good
- int sneed()
- {
- Chuck c;
- {
- c.setSeed(1);
- c.setFeed(2);
- c.init();
- }
- Chuck d;
- {
- Farmer farmer;
- if ( farmer.isSneed() ) {
- d.setSeed(3);
- d.setFeed(4);
- } else {
- d.setSeed(5);
- d.setFeed(6);
- }
- }
- Chuck e;
- {
- e.clear();
- }
- return c + d + e;
- }
- // Bad
- Sneed::Sneed()
- {
- QString s;
- // Prepare Seed
- m_Seed.clear();
- m_Seed.append( s_Type );
- m_Seed.setMax( mn_Limit );
- m_Seed.setMin(0);
- s.remove( m_Seed.toString() );
- // Add feed
- if ( m_Feed == nullptr ) { m_Feed = new Feed(); }
- m_Feed->grabAll();
- m_Feed->splice( &m_Seed );
- m_Feed->waitForSneed();
- s.append( m_Feed->readAll() );
- // Finish chuck
- m_Chuck.setFinal(s);
- this->clear();
- // Finish Sneed
- g.submode = NoSubMode;
- g.subsubmode = NoSubSubMode;
- g.movetype = MoveInclusive;
- g.gflag = false;
- m_Register = '"';
- g.rangemode = RangeCharMode;
- g.currentCommand.clear();
- resetCount();
- }
- // Good
- Sneed::Sneed()
- {
- QString s;
- /* Prepare Seed */
- {
- m_Seed.clear();
- m_Seed.append( s_Type );
- m_Seed.setMax( mn_Limit );
- m_Seed.setMin(0);
- s.remove( m_Seed.toString() );
- }
- /* Add feed */
- {
- if ( m_Feed == nullptr ) { m_Feed = new Feed(); }
- m_Feed->grabAll();
- m_Feed->splice( &m_Seed );
- m_Feed->waitForSneed();
- s.append( m_Feed->readAll() );
- }
- /* Finish Chuck */
- {
- m_Chuck.setFinal(s);
- }
- this->clear();
- /* Complete Sneed */
- {
- g.submode = NoSubMode;
- g.subsubmode = NoSubSubMode;
- g.movetype = MoveInclusive;
- g.gflag = false;
- m_Register = '"';
- g.rangemode = RangeCharMode;
- g.currentCommand.clear();
- }
- resetCount();
- }