Class (computer Programming) - Benefits

Benefits

This section contains weasel words: vague phrasing that often accompanies biased or unverifiable information. Such statements should be clarified or removed.

Computer programs usually model aspects of some real or abstract world (the Domain). Because each class models a concept, classes provide a more natural way to create such models. Each class in the model represents a noun in the domain, and the methods of the class represent verbs that may apply to that noun (Verbs can also be modeled as classes, see Command Pattern). For example in a typical business system, various aspects of the business are modeled, using such classes as Customer, Product, Worker, Invoice, Job, etc. An Invoice may have methods like Create, Print or Send, a Job may be Performed or Canceled, etc. Once the system can model aspects of the business accurately, it can provide users of the system with useful information about those aspects. Classes allow a clear correspondence (mapping) between the model and the domain, making it easier to design, build, modify and understand these models. Classes provide some control over the often challenging complexity of such models.

Classes can accelerate development by reducing redundant program code, testing and bug fixing. If a class has been thoroughly tested and is known to be a 'solid work', it is usually true that using or extending the well-tested class will reduce the number of bugs - as compared to the use of freshly developed or ad hoc code - in the final output. In addition, efficient class reuse means that many bugs need to be fixed in only one place when problems are discovered.

Another reason for using classes is to simplify the relationships of interrelated data. Rather than writing code to repeatedly call a graphical user interface (GUI) window drawing subroutine on the terminal screen (as would be typical for structured programming), it is more intuitive. With classes, GUI items that are similar to windows (such as dialog boxes) can simply inherit most of their functionality and data structures from the window class. The programmer then need only add code to the dialog class that is unique to its operation. Indeed, GUIs are a very common and useful application of classes, and GUI programming is generally much easier with a good class framework.

Read more about this topic:  Class (computer Programming)

Famous quotes containing the word benefits:

    While greedy good-doers, beneficent beasts of prey,
    Swarm over their lives enforcing benefits ...
    Robert Frost (1874–1963)

    In America the young are always ready to give to those who are older than themselves the full benefits of their inexperience.
    Oscar Wilde (1854–1900)

    When your parents are in political life, you aren’t normal. Everybody talks about the benefits, but I don’t know what the benefits are.... But I’d rather have that kind of mother than an overweight housewife.
    Katherine Berman Mariano (b. 1957)