Beware Of Using Get And Set Codes Illinois

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

Softweb Solutions
866-345-7638
5707 Breezeland Road
Chicago, IL
STL Technology Partners
(309) 699-6389
630 High Point Lane
East Peoria, IL
DMi Technology Group
(309) 828-4439
406 Kays Drive
Normal, IL
InterraIT
(630) 873-3525
Two Mid America Plaza
Oakbrook Terrace, IL
StrategicSytems International
+1.847.424.2497
820 Davis Street,
Evanston, IL
Quantum Design (Quantum Software Solutions)
815-885-1300
8400 E. Riverside Blvd
Rockford, IL
IT360, Inc.
(309) 283-2915
311 SW Water Street
Peoria, IL
Stellar Systems, Inc
(309) 677-7350
222 NE Monroe St. #902
Peoria, IL
Stellar Systems, Inc.
(309) 677-7350
222 NE Monroe St. #902
Peoria, IL
IFS
888-437-4968
300 Park Boulevard, Suite 555
Itasca, IL

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

Softweb Solutions

IT Consultant Company offers custom software development services, Flex, ROR, Web application development services

866-345-7638
5707 Breezeland Road
Chicago, IL
http://www.SoftwebSolutions.com

Softweb Solutions is a prominent name in providing exclusive software development services for SMEs, specializing in custom application development, website development, system integration and software testing and quality assurance, with industry-specific software expertise in High-Technology, Software, Automotive, Financial Services and Entertainment sectors.

Custom Software Development and IT Consultant

Related Articles
- Using Lookup Tables in AppleWorks Illinois
When a match is found, the function can automatically return the contents of other cells in the same row of the table. For example, a Lookup table may comprise a stock list, with rows of product codes, corresponding prices and descriptions.
- Printing Software in Business Illinois
- Antivirus And Security Illinois
- Bioinformatics Introduction Illinois
- Beating Spyware Illinois
- Win PC Defender Illinois
- CMMS Implementation Illinois
- How To Build A Flash Game Illinois
- Regarding dumb Smart Folders Illinois
- DVD ripping FAQ Illinois
Regional Articles
- Beware Of Using Get And Set Codes Addison IL
- Beware Of Using Get And Set Codes Algonquin IL
- Beware Of Using Get And Set Codes Alsip IL
- Beware Of Using Get And Set Codes Alton IL
- Beware Of Using Get And Set Codes Arlington Heights IL
- Beware Of Using Get And Set Codes Aurora IL
- Beware Of Using Get And Set Codes Barrington IL
- Beware Of Using Get And Set Codes Bartlett IL
- Beware Of Using Get And Set Codes Batavia IL
- Beware Of Using Get And Set Codes Belleville IL
- Beware Of Using Get And Set Codes Bellwood IL
- Beware Of Using Get And Set Codes Belvidere IL
- Beware Of Using Get And Set Codes Bensenville IL
- Beware Of Using Get And Set Codes Berwyn IL
- Beware Of Using Get And Set Codes Bloomingdale IL
- Beware Of Using Get And Set Codes Bloomington IL
- Beware Of Using Get And Set Codes Blue Island IL
- Beware Of Using Get And Set Codes Bolingbrook IL
- Beware Of Using Get And Set Codes Bourbonnais IL
- Beware Of Using Get And Set Codes Bridgeview IL
- Beware Of Using Get And Set Codes Buffalo Grove IL
- Beware Of Using Get And Set Codes Calumet City IL
- Beware Of Using Get And Set Codes Carbondale IL
- Beware Of Using Get And Set Codes Carol Stream IL
- Beware Of Using Get And Set Codes Carpentersville IL
- Beware Of Using Get And Set Codes Champaign IL
- Beware Of Using Get And Set Codes Chicago Heights IL
- Beware Of Using Get And Set Codes Chicago IL
- Beware Of Using Get And Set Codes Cicero IL
- Beware Of Using Get And Set Codes Clarendon Hills IL
- Beware Of Using Get And Set Codes Collinsville IL
- Beware Of Using Get And Set Codes Country Club Hills IL
- Beware Of Using Get And Set Codes Crete IL
- Beware Of Using Get And Set Codes Crystal Lake IL
- Beware Of Using Get And Set Codes Danville IL
- Beware Of Using Get And Set Codes Decatur IL
- Beware Of Using Get And Set Codes Deerfield IL
- Beware Of Using Get And Set Codes Dekalb IL
- Beware Of Using Get And Set Codes Des Plaines IL
- Beware Of Using Get And Set Codes Dolton IL
- Beware Of Using Get And Set Codes Downers Grove IL
- Beware Of Using Get And Set Codes East Moline IL
- Beware Of Using Get And Set Codes East Peoria IL
- Beware Of Using Get And Set Codes East Saint Louis IL
- Beware Of Using Get And Set Codes Edwardsville IL
- Beware Of Using Get And Set Codes Effingham IL
- Beware Of Using Get And Set Codes Elgin IL
- Beware Of Using Get And Set Codes Elk Grove Village IL
- Beware Of Using Get And Set Codes Elmhurst IL
- Beware Of Using Get And Set Codes Elmwood Park IL
- Beware Of Using Get And Set Codes Evanston IL
- Beware Of Using Get And Set Codes Evergreen Park IL
- Beware Of Using Get And Set Codes Fairview Heights IL
- Beware Of Using Get And Set Codes Franklin Park IL
- Beware Of Using Get And Set Codes Freeport IL
- Beware Of Using Get And Set Codes Galesburg IL
- Beware Of Using Get And Set Codes Glen Ellyn IL
- Beware Of Using Get And Set Codes Glendale Heights IL
- Beware Of Using Get And Set Codes Glenview IL
- Beware Of Using Get And Set Codes Godfrey IL
- Beware Of Using Get And Set Codes Granite City IL
- Beware Of Using Get And Set Codes Grayslake IL
- Beware Of Using Get And Set Codes Gurnee IL
- Beware Of Using Get And Set Codes Harvey IL
- Beware Of Using Get And Set Codes Harwood Heights IL
- Beware Of Using Get And Set Codes Hazel Crest IL
- Beware Of Using Get And Set Codes Highland Park IL
- Beware Of Using Get And Set Codes Hinsdale IL
- Beware Of Using Get And Set Codes Homewood IL
- Beware Of Using Get And Set Codes Jacksonville IL
- Beware Of Using Get And Set Codes Joliet IL
- Beware Of Using Get And Set Codes Kankakee IL
- Beware Of Using Get And Set Codes Kewanee IL
- Beware Of Using Get And Set Codes La Grange IL
- Beware Of Using Get And Set Codes Lake Bluff IL
- Beware Of Using Get And Set Codes Lake Villa IL
- Beware Of Using Get And Set Codes Lake Zurich IL
- Beware Of Using Get And Set Codes Lansing IL
- Beware Of Using Get And Set Codes Lemont IL
- Beware Of Using Get And Set Codes Libertyville IL
- Beware Of Using Get And Set Codes Lisle IL
- Beware Of Using Get And Set Codes Lockport IL
- Beware Of Using Get And Set Codes Lombard IL
- Beware Of Using Get And Set Codes Loves Park IL
- Beware Of Using Get And Set Codes Machesney Park IL
- Beware Of Using Get And Set Codes Matteson IL
- Beware Of Using Get And Set Codes Mattoon IL
- Beware Of Using Get And Set Codes Maywood IL
- Beware Of Using Get And Set Codes Mchenry IL
- Beware Of Using Get And Set Codes Melrose Park IL
- Beware Of Using Get And Set Codes Midlothian IL
- Beware Of Using Get And Set Codes Mokena IL
- Beware Of Using Get And Set Codes Moline IL
- Beware Of Using Get And Set Codes Morris IL
- Beware Of Using Get And Set Codes Morton Grove IL
- Beware Of Using Get And Set Codes Morton IL
- Beware Of Using Get And Set Codes Mount Prospect IL
- Beware Of Using Get And Set Codes Mundelein IL
- Beware Of Using Get And Set Codes Murphysboro IL
- Beware Of Using Get And Set Codes Naperville IL
- Beware Of Using Get And Set Codes New Lenox IL
- Beware Of Using Get And Set Codes Niles IL
- Beware Of Using Get And Set Codes Normal IL
- Beware Of Using Get And Set Codes North Chicago IL
- Beware Of Using Get And Set Codes Northbrook IL
- Beware Of Using Get And Set Codes O Fallon IL
- Beware Of Using Get And Set Codes Oak Forest IL
- Beware Of Using Get And Set Codes Oak Lawn IL
- Beware Of Using Get And Set Codes Oak Park IL
- Beware Of Using Get And Set Codes Orland Park IL
- Beware Of Using Get And Set Codes Palatine IL
- Beware Of Using Get And Set Codes Palos Hills IL
- Beware Of Using Get And Set Codes Park Forest IL
- Beware Of Using Get And Set Codes Park Ridge IL
- Beware Of Using Get And Set Codes Pekin IL
- Beware Of Using Get And Set Codes Peoria IL
- Beware Of Using Get And Set Codes Plainfield IL
- Beware Of Using Get And Set Codes Prospect Heights IL
- Beware Of Using Get And Set Codes Quincy IL
- Beware Of Using Get And Set Codes Riverdale IL
- Beware Of Using Get And Set Codes Rochelle IL
- Beware Of Using Get And Set Codes Rock Falls IL
- Beware Of Using Get And Set Codes Rock Island IL
- Beware Of Using Get And Set Codes Rockford IL
- Beware Of Using Get And Set Codes Rolling Meadows IL
- Beware Of Using Get And Set Codes Romeoville IL
- Beware Of Using Get And Set Codes Roscoe IL
- Beware Of Using Get And Set Codes Roselle IL
- Beware Of Using Get And Set Codes Round Lake IL
- Beware Of Using Get And Set Codes Saint Charles IL
- Beware Of Using Get And Set Codes Schaumburg IL
- Beware Of Using Get And Set Codes Skokie IL
- Beware Of Using Get And Set Codes South Elgin IL
- Beware Of Using Get And Set Codes South Holland IL
- Beware Of Using Get And Set Codes Springfield IL
- Beware Of Using Get And Set Codes Streamwood IL
- Beware Of Using Get And Set Codes Streator IL
- Beware Of Using Get And Set Codes Sycamore IL
- Beware Of Using Get And Set Codes Taylorville IL
- Beware Of Using Get And Set Codes Tinley Park IL
- Beware Of Using Get And Set Codes Urbana IL
- Beware Of Using Get And Set Codes Vernon Hills IL
- Beware Of Using Get And Set Codes Villa Park IL
- Beware Of Using Get And Set Codes Waukegan IL
- Beware Of Using Get And Set Codes West Chicago IL
- Beware Of Using Get And Set Codes Westchester IL
- Beware Of Using Get And Set Codes Westmont IL
- Beware Of Using Get And Set Codes Wheaton IL
- Beware Of Using Get And Set Codes Wheeling IL
- Beware Of Using Get And Set Codes Wilmette IL
- Beware Of Using Get And Set Codes Wood Dale IL
- Beware Of Using Get And Set Codes Woodridge IL
- Beware Of Using Get And Set Codes Woodstock IL
- Beware Of Using Get And Set Codes Zion IL
Related Local Events
BIO - International Convention and Exhibition for Biotechnology
Dates: 5/2/2010 - 5/5/2010
Location: McCormick Place
Chicago, IL
View Details

PTXi - Process Technology Expo International
Dates: 5/4/2010 - 5/6/2010
Location: Donald E. Stephens Convention Center
Rosemont, IL
View Details

Virtualization / Consolidation Strategies - Implementation Strategies
Dates: 12/10/2009 - 12/10/2009
Location: The Donald E. Stephens Convention Center
Rosemont, IL
View Details

The CIO Agenda - 2010 and Beyond
Dates: 11/5/2009 - 11/5/2009
Location: The Donald E. Stephens Convention Center
Rosemont, IL
View Details

SuperComm
Dates: 10/21/2009 - 10/23/2009
Location: McCormick Place, Chicago
Chicago, IL
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