Beware Of Using Get And Set Codes Ohio

There is no doubt computer code writing is a tough job, you need to be careful when doing that job. Read the article below to learn tips for using"get" And "set".

Local Companies

Desktop Solutions
614-884-3714
3021 Bethel RD
Columbus, OH
Megasys Software Services
614-457-5544
1681 Old Henderson RD
Columbus, OH
Valent Software
614-457-9000
2000 Henderson RD
Columbus, OH
Ventech Solutions
614-751-1167
950 Taylor Station Rd
Columbus, OH
Technology Software Inc
614-442-8400
1505 Bethel RD
Columbus, OH
Teamwork Solutions
614-457-7100
1880 Mackenzie DR
Columbus, OH
Priority One Solutions
216-298-4020
2130 Superior Ave E
Cleveland, OH
Crystal Vision Software
419-472-0000
3601 W Alexis RD
Toledo, OH
F 1 Technologies
419-255-6366
2108 Glenwood Ave
Toledo, OH
ProTrain & True North Career Services Inc.
(513) 825-1555
650 Northland Boulevard
Cincinnati, OH

 

It’s an all-too-common pitfall. Programmers who attempt to write object-oriented code decide to make all of their data variables private, while creating public get() and set() function pairs for each one. “See?” they declare, as they pat themselves on their backs. “The data is private, but it can be accessed through these functions. I’ve encapsulated my data. That’s what object-oriented design requires.”

I think this betrays a fundamental (and exceedingly common) misunderstanding of what constitutes encapsulation and information hiding. Ideally, in an object-oriented design, the user of a software class should have no idea what type of data the class contains. As far as he’s concerned, the class should simply provide the required services, and its internal details should be invisible. However, when we provide get() and set() function pairs for each member variable, we are basically announcing the existence of this data to the world. The information hiding provided by this class is weak—and arguably non-existent. One might change the name, data type or implementation of this member variable, but its existence remains painfully obvious to everyone.

(Note that I say that the user should “ideally” be oblivious to the type of data contained within the class. In practice, this is not always feasible. If we were to implement a BankAccount class, for example, most programmers would immediately guess that this class would have the account balance as one of its data members. They would also guess—rightfully so—that the owner of this account is likely to be data member as well. Nevertheless, we should avoid needlessly divulging such details, especially when the contents of a class are not so easily discerned.)

In effect, these get() and set() member functions are almost as bad as having public data. Sure, they may provide some useful services; for example, the set() function could validate the data, ensuring that it is within the proper range of values. Nevertheless, they tend to violate the spirit of information hiding, at least to some degree.

Using get() and set() functions is not always a bad idea; in fact, sometimes they make perfect sense. Their frequent use, however, is a pretty good indication of a poorly abstracted software design—one that does not adhere well to the principle of information hiding. When designing software classes, we need to think primarily in terms of the services they provide (i.e. their public functions), rather than the data they contain. Ideally, their data implementations should proceed from the required services, rather than other way around.

To illustrate this concept, let us revisit the BankAccount class mentioned earlier. It is clear that the BankAccount object will need to keep track of its balance, so let’s make that a data member. A novice programmer (or one with a poor grasp of object orientation) may choose to provide both GetBalance() and SetBalance() functions for this class… but does this make sense?

What happens when a user attempts to make a deposit? The user would have to call GetBalance(), add the deposit amount, and then set the new value using GetBalance(). That’s not how real users operate, though; in the real world, there is no need for the depositor to know how much money is in the account. This class design gives the user too much information and requires too many steps.

Similarly, to perform a withdrawal, the user would need to call GetBalance(), subtract the withdrawal amount, and then call SetBalance() to update the account. This also requires too much work on the user’s part. In the real world, the user should not always be required to know exactly how much money is in the account. This person might want to know that there are sufficient funds, but he wouldn’t necessarily need to know the precise balance, and this information should not be a constant requirement.

A sensibly written class should provide the following services instead: DepositAmount(), WithdrawAmount() and GetBalance(). With this design, the data member—the account balance—is logically implied by the services provided, rather than the other way around. (We could define other services, such as AccrueInterest() and TransferFunds(), but let’s keep it simple for now. Note that these services might suggest additional data members; for example, AccrueInterest() would suggest that a data member would be needed for the interest rate.)

In summary, get() and set() function pairs are not inherently bad, but their preponderance could suggest a poorly abstracted software design. There’s nothing inherently wrong with using get() and set() functions when they form part of a sensibly designed set of services. Nor is there anything wrong with using a data member to reflect these functions. When one proceeds in the opposite direction, though—when one starts with the data members, then adds corresponding get() and set() pairs—that’s a strong indication of a poorly conceived software design.

About the Author:

V. Berba Velasco Jr., Ph.D. is a senior electrical and software engineer at CTL (http://www.elispot-analyzers.de, http://www.immunospot.com, http://www.elispot.cn, http://www.elispot.co.jp), a biotech firm that provides ELISPOT technology, cryopreserved PBMCs and serum-free media.






Article Source:

thePhantomWriters Article Submission Service

Featured Local Company

Desktop Solutions

614-884-3714
3021 Bethel RD
Columbus, OH

Related Articles
- Printing Software in Business Ohio
The businesses are growing on the large scale with a great number of profits and by minimizing their costs. This is done and made easy with the help of the different softwares that are specially designed for different businesses either small or large. Printing software is one of such softwares that is now commonly used by all the businesses.
- Using Lookup Tables in AppleWorks Ohio
- How To Build A Flash Game Ohio
- Regarding dumb Smart Folders Ohio
- DVD ripping FAQ Ohio
- Beating Spyware Ohio
- Win PC Defender Ohio
- Bioinformatics Introduction Ohio
- CMMS Implementation Ohio
- Antivirus And Security Ohio
Regional Articles
- Beware Of Using Get And Set Codes Akron OH
- Beware Of Using Get And Set Codes Alliance OH
- Beware Of Using Get And Set Codes Amelia OH
- Beware Of Using Get And Set Codes Ashland OH
- Beware Of Using Get And Set Codes Ashtabula OH
- Beware Of Using Get And Set Codes Athens OH
- Beware Of Using Get And Set Codes Avon Lake OH
- Beware Of Using Get And Set Codes Barberton OH
- Beware Of Using Get And Set Codes Batavia OH
- Beware Of Using Get And Set Codes Bay Village OH
- Beware Of Using Get And Set Codes Beachwood OH
- Beware Of Using Get And Set Codes Bedford OH
- Beware Of Using Get And Set Codes Bellefontaine OH
- Beware Of Using Get And Set Codes Bowling Green OH
- Beware Of Using Get And Set Codes Broadview Heights OH
- Beware Of Using Get And Set Codes Brook Park OH
- Beware Of Using Get And Set Codes Brunswick OH
- Beware Of Using Get And Set Codes Bucyrus OH
- Beware Of Using Get And Set Codes Canal Winchester OH
- Beware Of Using Get And Set Codes Canfield OH
- Beware Of Using Get And Set Codes Canton OH
- Beware Of Using Get And Set Codes Celina OH
- Beware Of Using Get And Set Codes Chagrin Falls OH
- Beware Of Using Get And Set Codes Chardon OH
- Beware Of Using Get And Set Codes Chillicothe OH
- Beware Of Using Get And Set Codes Cincinnati OH
- Beware Of Using Get And Set Codes Circleville OH
- Beware Of Using Get And Set Codes Cleveland OH
- Beware Of Using Get And Set Codes Columbus OH
- Beware Of Using Get And Set Codes Conneaut OH
- Beware Of Using Get And Set Codes Coshocton OH
- Beware Of Using Get And Set Codes Cuyahoga Falls OH
- Beware Of Using Get And Set Codes Dayton OH
- Beware Of Using Get And Set Codes Defiance OH
- Beware Of Using Get And Set Codes Delaware OH
- Beware Of Using Get And Set Codes Dublin OH
- Beware Of Using Get And Set Codes East Liverpool OH
- Beware Of Using Get And Set Codes Eastlake OH
- Beware Of Using Get And Set Codes Eaton OH
- Beware Of Using Get And Set Codes Elyria OH
- Beware Of Using Get And Set Codes Euclid OH
- Beware Of Using Get And Set Codes Fairborn OH
- Beware Of Using Get And Set Codes Fairfield OH
- Beware Of Using Get And Set Codes Findlay OH
- Beware Of Using Get And Set Codes Fostoria OH
- Beware Of Using Get And Set Codes Franklin OH
- Beware Of Using Get And Set Codes Fremont OH
- Beware Of Using Get And Set Codes Galion OH
- Beware Of Using Get And Set Codes Gallipolis OH
- Beware Of Using Get And Set Codes Galloway OH
- Beware Of Using Get And Set Codes Girard OH
- Beware Of Using Get And Set Codes Grove City OH
- Beware Of Using Get And Set Codes Hamilton OH
- Beware Of Using Get And Set Codes Heath OH
- Beware Of Using Get And Set Codes Hilliard OH
- Beware Of Using Get And Set Codes Hubbard OH
- Beware Of Using Get And Set Codes Ironton OH
- Beware Of Using Get And Set Codes Kent OH
- Beware Of Using Get And Set Codes Lakewood OH
- Beware Of Using Get And Set Codes Lancaster OH
- Beware Of Using Get And Set Codes Lebanon OH
- Beware Of Using Get And Set Codes Lima OH
- Beware Of Using Get And Set Codes Lorain OH
- Beware Of Using Get And Set Codes Loveland OH
- Beware Of Using Get And Set Codes Madison OH
- Beware Of Using Get And Set Codes Maineville OH
- Beware Of Using Get And Set Codes Mansfield OH
- Beware Of Using Get And Set Codes Maple Heights OH
- Beware Of Using Get And Set Codes Marion OH
- Beware Of Using Get And Set Codes Marysville OH
- Beware Of Using Get And Set Codes Mason OH
- Beware Of Using Get And Set Codes Massillon OH
- Beware Of Using Get And Set Codes Maumee OH
- Beware Of Using Get And Set Codes Medina OH
- Beware Of Using Get And Set Codes Mentor OH
- Beware Of Using Get And Set Codes Miamisburg OH
- Beware Of Using Get And Set Codes Middletown OH
- Beware Of Using Get And Set Codes Milford OH
- Beware Of Using Get And Set Codes Millersburg OH
- Beware Of Using Get And Set Codes Mount Vernon OH
- Beware Of Using Get And Set Codes Napoleon OH
- Beware Of Using Get And Set Codes New Carlisle OH
- Beware Of Using Get And Set Codes New Philadelphia OH
- Beware Of Using Get And Set Codes Newark OH
- Beware Of Using Get And Set Codes North Olmsted OH
- Beware Of Using Get And Set Codes North Ridgeville OH
- Beware Of Using Get And Set Codes North Royalton OH
- Beware Of Using Get And Set Codes Olmsted Falls OH
- Beware Of Using Get And Set Codes Oregon OH
- Beware Of Using Get And Set Codes Oxford OH
- Beware Of Using Get And Set Codes Painesville OH
- Beware Of Using Get And Set Codes Pataskala OH
- Beware Of Using Get And Set Codes Perrysburg OH
- Beware Of Using Get And Set Codes Pickerington OH
- Beware Of Using Get And Set Codes Piqua OH
- Beware Of Using Get And Set Codes Portsmouth OH
- Beware Of Using Get And Set Codes Ravenna OH
- Beware Of Using Get And Set Codes Reynoldsburg OH
- Beware Of Using Get And Set Codes Rocky River OH
- Beware Of Using Get And Set Codes Salem OH
- Beware Of Using Get And Set Codes Sandusky OH
- Beware Of Using Get And Set Codes Sidney OH
- Beware Of Using Get And Set Codes Solon OH
- Beware Of Using Get And Set Codes Springboro OH
- Beware Of Using Get And Set Codes Springfield OH
- Beware Of Using Get And Set Codes Steubenville OH
- Beware Of Using Get And Set Codes Stow OH
- Beware Of Using Get And Set Codes Strongsville OH
- Beware Of Using Get And Set Codes Sylvania OH
- Beware Of Using Get And Set Codes Tallmadge OH
- Beware Of Using Get And Set Codes Tiffin OH
- Beware Of Using Get And Set Codes Tipp City OH
- Beware Of Using Get And Set Codes Toledo OH
- Beware Of Using Get And Set Codes Troy OH
- Beware Of Using Get And Set Codes Twinsburg OH
- Beware Of Using Get And Set Codes Van Wert OH
- Beware Of Using Get And Set Codes Vandalia OH
- Beware Of Using Get And Set Codes Vermilion OH
- Beware Of Using Get And Set Codes Wadsworth OH
- Beware Of Using Get And Set Codes Wapakoneta OH
- Beware Of Using Get And Set Codes Warren OH
- Beware Of Using Get And Set Codes Washington Court House OH
- Beware Of Using Get And Set Codes West Chester OH
- Beware Of Using Get And Set Codes Westerville OH
- Beware Of Using Get And Set Codes Westlake OH
- Beware Of Using Get And Set Codes Wickliffe OH
- Beware Of Using Get And Set Codes Willoughby OH
- Beware Of Using Get And Set Codes Wooster OH
- Beware Of Using Get And Set Codes Xenia OH
- Beware Of Using Get And Set Codes Youngstown OH
- Beware Of Using Get And Set Codes Zanesville OH
Related Articles
- Beating Spyware Ohio
Spyware spread quickly across the internet world forcing users to become aware of the prevalent threats facing their privacy while surfing the internet. Spyware collects information on you internet and computer usage habits as well as more serious information including personal identification and credit card numbers.
- Bioinformatics Introduction Ohio
- DVD ripping FAQ Ohio
- Antivirus And Security Ohio
- Using Lookup Tables in AppleWorks Ohio
- Printing Software in Business Ohio
- CMMS Implementation Ohio
- How To Build A Flash Game Ohio
- Win PC Defender Ohio
- Regarding dumb Smart Folders Ohio
Related Local Events
NAIAS 2010
Dates: 1/15/2010 - 1/15/2010
Location: COBO Convention Center
Detroit, OH
View Details

Forge Fair 2010
Dates: 4/20/2010 - 4/22/2010
Location: Cincinnati Convention Center
Cincinnati, OH
View Details

Earth Science Day
Dates: 10/17/2009 - 10/17/2009
Location: Cleveland Museum of Natural History
Cleveland, OH
View Details

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Advertising Family Home Services Real Estate Resources
Business Services Fashion Industrial Goods & Services Retail & Consumer Services
Career Financial Services Insurance Software
Cars Food & Beverage Internet Technology
Computer Hardware Franchise Legal Telecommunications
Construction Health Miscellaneous Trade Shows
Education Holidays Nightlife Travel
Entertainment Home Appliances Online Database Weddings
Environmental Home Electronics Pets World History