Writers' Community!
Home News Business Science & Technology Life
Front Page Page Two Columnists Submit an Article FAQs Contact Author Login
Article Submission
We Need YOUR Articles!
We'll Promote Them for FREE!

Author Login

New Authors
Register Here


Now Serving 5,561 Authors
48,446 Quality Articles
& 7,219 Current Users Online!
Featured Authors
Nicole Beurkens (148)
Jeff Brown (7,977)
David Tanguay (7,555)
Ira Coffin (897)
Joel Hendon (4,850)
Terry Mitchell (2,785)
Rob Lafferty (123)
Arlene Wright-Correll (10,108)
Jane Bullard (1,959)
Robert Melaccio, Sr. (6,499)
Avis Ward (13,445)
Richard Nicastro (2,545)
Dianne Lehmann (3,112)
Mogama (12,156)

View All Featured Authors
Most Recent
DVD Software Explained and Clarified

Microsoft Word 2007 Ribbon Controls

Effective Use of MS Project Calendars

Excel for Beginners

The future of PowerPoint?

Shrink Your Technology - How to Work Anywhere, Anytime Out of a Backpack

TCP/IP protocols and configurations.

How TCP/IP and Routing Work

Outsourcing Work

Preventing Malware Downloads with a Spyware Adware Blocker

Home » Categories » Computers & Networking » Software » Five Tips For Effective Object-Orientation In C++ » Printer Friendly

V Berba Velasco Jr  PhD

Five Tips For Effective Object-Orientation In C++

Rated 3.5 out of 5
No Reader Ratings Available ?
Rate It  /  View Comments  /  View All Articles submitted by V Berba Velasco Jr PhD
Submitted Monday, August 21, 2006
V Berba Velasco Jr PhD (616)
V Berba Velasco Jr PhD

Articles and Stuff
Log in to become a member of V Berba Velasco Jr PhD's Fan Club!


Spurgeon’s Law says that 90% of everything is crap. This certainly holds true in the world of software development, and especially when it comes to object-orientation and C++ programming. This is largely due to the pervasiveness and complexity of C++; it’s one of the most commonly used object-oriented languages, and yet few people know how to use it effectively. Couple this with the fact that few programmers truly grasp the object-oriented programming philosophy and you have an instant recipe for sloppy code.

Volumes can be—and have been—written on how to develop proper object-oriented software designs using C++. Obviously, there won’t be space in this article for a truly thorough discussion; however, I would like to present a few quick, simple and effective tips for developing robust C++ software.

1. Work on the class designs first before deciding on the precise sequence of operations. Many programmers fancy themselves as doing object-oriented programming, but in reality, they use structured programming with some external object-oriented trappings. Ideally, one should first select a set of software objects that provide a logical abstraction of the software, then work on the sequence of operations. (This is by no means an absolute rule though, as the process of developing this sequence often reveals ways in which the object design can be refined.)

2. Avoid using public ‘get’ and ‘set’ member functions. Getters and setters are not inherently bad; however, they are often a sign of poor software abstraction. ‘Get’ and ‘set’ functions implicitly force the user to think in terms of the object’s internal data (i.e. whatever these functions are getting or setting), and such details should ideally be hidden from the object’s user. Getters and setters have their place, but please use them sparingly.

3. Think in terms of design patterns. Design patterns allow someone to draw on years of problem-solving experience within the computer science community. Instead of reinventing the wheel, why not just pick one off the shelf?

4. Avoid double indirection. C programmers are forced to work with pointers, and so they are used to having pointers to pointers throughout their code. This can often lead to confusing code, due to the all-too-familiar problems of NULL references and pointer arithmetic. In contrast, C++ programmers are under no such constraints, due to the built-in support for variable references in C++; that is, one can always use references to pointers instead, which makes the code much easier to understand. (Hint: If a C++ programmer uses double indirection, that’s a clear sign that he’s still thinking like an inexperienced C hack!)

5. Use ‘const’ objects and ‘const’ functions whenever possible. If you know that an object’s data is never supposed to be modified, then declare the object to be ‘const’. This will prevent you—or worse, a naïve colleague--from accidentally modifying its state later on. Of course, one should also declare the appropriate member functions to be ‘const’ as well, to properly enforce this rule.

About the author:

V. B. Velasco Jr., Ph.D. has worked as an electrical and software engineer for more than a decade and places a premium on elegant software design. He maintains a small, rudimentary website devoted to some of his casual interests.






Reprint Rights

Log in to become a member of V Berba Velasco Jr PhD's Fan Club!

Comments on this article:
No comments yet.


Was this article helpful to you? Leave a Public Comment or Question:

 

This Article has been viewed 31 times.
Article added to SearchWarp.com on Monday, August 21, 2006
View other articles written by V Berba Velasco Jr PhD (616)
V Berba Velasco Jr PhD


If you found this article interesting, you may want to check out:

Disclaimer:  All information on this site is provided for informational purposes only! By no means is any information presented herein intended to substitute for the advice provided to you by any health care or other professional or organization.


Today's Most Popular
Introduction to DQL-Documentum Query Language

Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help

How To Export A Microsoft Access Report as a PDF

Improve PC Performance - 6 Tips You Must Know.

Elimination of Spooler Subsystem App problem. Easy and quick.

Microsoft Outlook 2000 Tips – I Can’t Send My Attachments!

Linux Command Tutorials - Opening a Linux Terminal / Console to Run Linux Commands - Tutorial Help

What Shows Up On a Criminal Record Background Check?

Windows Vista and Internet Explorer 7 Delete View Objects Bug

15 Questions to ask your software vendor

Home  |  Page Two  |  FAQ's  |  Contact  |  Terms of Service  |  Article Submission Guidelines  |  Writers' Contests  |  Privacy  |  Mission / About
Copyright © 1999-2008 SearchWarp.com, All Rights Reserved - SearchWarp.com is an IcoLogic, Inc. Company