Computer Science

Java Abstraction

Java Abstraction is a technique used to hide the implementation details of a program and only show the necessary information to the user. It allows developers to create complex systems by breaking them down into smaller, more manageable parts. Abstraction is achieved through the use of abstract classes and interfaces.

Written by Perlego with AI-assistance

3 Key excerpts on "Java Abstraction"

  • Putting Information First
    eBook - ePub

    Putting Information First

    Luciano Floridi and the Philosophy of Information

    • Patrick Allo, Patrick Allo(Authors)
    • 2011(Publication Date)
    • Wiley-Blackwell
      (Publisher)
    interaction patterns . Certainly, the objective of computer science is at times similar to that of mathematics—for example, when proving theorems about formal languages and the automata that process them. However, the central activity of computer science is the production of software, and this activity is primarily characterized not by the creation and exploitation of inference structures but by the modeling of interaction patterns. The kind of interaction involved depends upon the level of abstraction used to describe programs. At a basic level, software prescribes the interacting of a certain part of computer memory, namely, the program itself, and another part of memory, called the program data, through explicit instructions carried out by a processor. At a different level, software embodies algorithms that prescribe interactions among subroutines, which are cooperating pieces of programs. At a still different level, every software system is an interaction of computational processes. Today’s extremely complex software is possible only through abstraction levels that obscure machine-oriented concepts. Still, these levels are used to describe interaction patterns, whether they be between software objects or between a user and a system.
    What is a “level of abstraction” in computer science? The history of software development tells a story of an increasing distance between programmers and the machine-oriented entities that provide the foundation of their work, such as machine instructions, machine-oriented processes, and machine-oriented data types. Language abstraction accounts for this distance by allowing programmers to describe computational processes through linguistic constructs that hide details about the machine entities by allowing underlying software to handle those details. At the most basic physical level, a computer process is a series of changes in the state of a machine, where each state is described by the presence or absence of electrical charges in memory and processor elements. But programmers need not be directly concerned with machine states so described, because they can make use of languages that allow them to think in other terms. An assembly language programmer can ignore electrical charges and logic gates in favor of language involving registers, memory locations , and subroutines . A C language programmer can in turn ignore assembly language constructs in favor of language involving variables, pointers, arrays, structures , and functions . A Java language programmer can ignore some C language constructs by employing language involving objects and methods . The concepts introduced by each of these languages are not just old concepts with new names. They significantly enlarge the vocabulary of the programmer with new functionality while simultaneously freeing the programmer from having to attend to tedious details. For example, in the move from C to Java, programmers have new access to active
  • Refactoring for Software Design Smells
    eBook - ePub
    • Girish Suryanarayana, Ganesh Samarthyam, Tushar Sharma(Authors)
    • 2014(Publication Date)
    • Morgan Kaufmann
      (Publisher)
    Of course it is a human smiley face, but how do we decide on that answer? We arrive at it through abstraction! There are hundreds of millions of human faces and each and every face is unique (there are some exceptions). How are we able to cope with this complexity? We eliminated non-essential details such as hair styles and color. We also arrived at the answer by generalizing commonalities such as every face has two eyes and when we smile our lips curve upwards at the ends.
    Abstraction is a powerful principle that provides a means for effective yet simple communication and problem solving. Company logos and traffic signs are examples of abstractions for communication. Mathematical symbols and programming languages are examples of abstraction as a tool for problem solving.
    Modern software is so complex that it often spans millions of lines of code. To tame the complexity of such systems, we need to apply powerful principles such as abstraction in the most effective way possible. How do we apply the principle of abstraction in software design?
    We list below some key enabling techniques that we have gleaned from our experience that allow us to apply the principle of abstraction in software design (Figure 3.2 ):
    Provide a crisp conceptual boundary and an identity . Each abstraction should have a crisp and clear conceptual boundary and an identity. For instance, instead of “passing around” a group of data values representing a date, coordinates of a rectangle, or attributes of an image, they can be created as separate abstractions in the code.
    Map domain entities . There should be a mapping of vocabulary from the problem domain to the solution domain, i.e., objects recognized by the problem domain should be also represented in the solution domain. For instance, if there is a clip art that you can insert in a word processor application, it is easier to comprehend the design when it also has a corresponding abstraction named ClipArt.
    Ensure coherence and completeness
  • Learn Java 17 Programming
    Similar to static properties, static methods can be invoked without creating an instance of the class. Consider, for example, the following class: class SomeClass{     public static String someMethod() {         return "abc";     } } We can call the preceding method by using just a class name: System.out.println(SomeClass.someMethod()); //prints: abc

    Interface

    In the Abstraction/interface section, we talked about an interface in general terms. In this section, we are going to describe a Java language construct that expresses it.
    An interface presents what can be expected of an object. It hides the implementation and exposes only method signatures with return values. For example, here is an interface that declares two abstract methods:
    interface SomeInterface {     void method1();     String method2(int i); } Here is a class that implements it: class SomeClass implements SomeInterface{     public void method1(){         //method body     }     public String method2(int i) {         //method body         return "abc";     } }
    An interface cannot be instantiated. An object of an interface type can be created only by creating an object of a class that implements this interface:
    SomeInterface si = new SomeClass();
    If not all of the abstract methods of the interface have been implemented, the class must be declared abstract and cannot be instantiated. See the Interface versus abstract class section.
    An interface does not describe how the object of the class can be created. To discover that, you must look at the class and see what constructors it has. An interface also does not describe the static class methods. So, an interface is a public face of a class instance (object) only.
    With Java 8, an interface acquired the ability to have not just abstract methods (without a body) but really implemented ones. According to the Java Language Specification, “the body of an interface may declare members of the interface, that is, fields, methods, classes, and interfaces
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.