– Instance variables of the class are accessible only to members of the class this is
known as data hiding
– Predicate methods : methods to test the truth of conditions
– Data abstraction : The client cares about what functionality a class offers, but not about how that functionality is implemented
– The direct base class is the base class from which the derived class explicitly inherits. An indirect base class is any class above the direct base class in the class hierarchy, which defines the inheritance relationships among classes. The class hierarchy begins with class object (which is the C# alias for System.Object in the Framework Class Library), which every class directly or indirectly extends (or "inherits from").
– Notethat base classes tend to be "more general," and derived classes tend to be "more specific."
– Classes can be declared with only two access modifiers public and internal. If there is no access modifier in the class declaration, the class defaults to internal access. This allows the class to be used by all code in the same assembly as the class, but not by code in other assemblies. Within the same assembly as the class, this is equivalent to public access. However, if a class library is referenced from an application, the library’s internal classes will be inaccessible from the code of the application. Similarly, methods, instance variables and other members of a class declared internal are accessible to all code compiled in the same assembly, but not to code in other assemblies.
– Accessing types : private, protected, internal, public
– A base class’s protected internal members can be accessed by members of that base class, by members of its derived classes and by any class in the same assembly.)
– Base class methods must be explicitly declared virtual if they are to be overridden by methods in derived classes
– In fact, the first task of any derived class’s constructor is to call its direct base class’s constructor, either explicitly or implicitly (if no constructor call is specified), to ensure that the instance variables inherited from the base class are initialized properly.
– Class object is the only class that does not have a base class.
– "copy-and-paste" approach is often error prone and time consuming
– The virtual and abstract keywords indicate that a base class method can be overridden in derived classes
– The override modifier declares that a derived class method overrides a virtual or abstract base class method. This modifier also implicitly declares the derived class method virtual and allows it to be overridden in derived classes further down the inheritance hierarchy.
– Inheriting protected instance variables slightly increases performance, because we can directly access the variables in the derived class without incurring the overhead of invoking the set or get accesses of the corresponding property. In most cases, however, it is better to use private instance variables to encourage proper software engineering, and leave code optimization issues to the compiler. Your code will be easier to maintain, modify and debug.
– Using protected instance variables creates several potential problems. First, the derived class object can set an inherited variable’s value directly without using the property’s set accessor. Therefore, a derived class object can assign an invalid value to the variable, thus leaving the object in an inconsistent state
– Declaring base class instance variables private (as opposed to protected) enables
the base class implementation of these instance variables to change without
affecting derived class implementations.
– Localizing the effects of changes like this is a good software engineering practice.
– By using inheritance and by using properties that hide the data and ensure consistency, we have efficiently and effectively constructed a well-engineered class.
– Instantiating a derived class object begins a chain of constructor calls in which the derived class constructor, before performing its own tasks, invokes its direct base class’s constructor either explicitly (via a constructor initializer with the base reference) or implicitly (calling the base class’s default constructor or parameterless constructor). Similarly, if the base class is derived from another class (as every class except object is), the base class constructor invokes the constructor of the next class up in the hierarchy, and so on. The last constructor called in the chain is always the constructor for class object. The original derived class constructor’s body finishes executing last. Each base class’s constructor manipulates the base class instance variables that the derived class object inherits
– When an application creates a derived class object, the derived class constructor immediately calls the base class constructor (explicitly, via base, or implicitly). The base class constructor’s body executes to initialize the base class’s instance variables that are part of the derived class object, then the derived class constructor’s body executes to initialize the derived class-only instance variables. Even if a constructor does not assign a value to an instance variable, the variable is still initialized to its default value (i.e., 0 for simple numeric types, false for bools and null for references).
– People experienced with such projects say that effective software reuse improves the software development process. Object-oriented programming facilitates software reuse, potentially shortening development time. The availability of substantial and useful class libraries delivers the maximum benefits of software reuse through inheritance. The FCL class libraries that are used by C# tend to be rather general purpose. Many special-purpose class libraries exist and more are being created.
– At the design stage in an object-oriented system, the designer often finds that certain classes are closely related. The designer should "factor out" common members and place them in a base class. Then the designer should use inheritance to develop derived classes, specializing them with capabilities beyond those inherited from the base class.
– Just as designers of non-object-oriented systems should avoid method proliferation, designers of object-oriented systems should avoid class proliferation. Such proliferation creates management problems and can hinder software reusability, because in a huge class library it becomes difficult for a client to locate the most appropriate classes. The alternative is to create fewer classes that provide more substantial functionality, but such classes might prove cumbersome.
– Reading derived class declarations can be confusing, because inherited members are not declared explicitly in the derived classes, but are nevertheless present in them. A similar problem exists in documenting derived class members.
– A class that overrides the method Equals should also override the method GetHashCode to ensure that equal objects have identical hashcodes. The default Equals implementation determines only whether two references refer to the same object in memory
– Finalize : This method cannot be explicitly declared or called. When a class contains a destructor, the compiler implicitly renames it to override the protected method Finalize, which is called only by the garbage collector before it reclaims an object’s memory. The garbage collector is not guaranteed to reclaim an object, thus it is not guaranteed that an object’s Finalize method will execute. When a derived class’s Finalize method executes, it performs its task, then invokes the base class’s Finalize method. Finalize’s default implementation is a placeholder that simply invokes the base class’s Finalize method.
– GetType : Every object knows its own type at execution time. Method GetType returns an object of class Type (namespace System) that contains information about the object’s type, such as its class name (obtained from Type property FullName).
– MemberwiseClone : This protected method, which takes no arguments and returns an object reference, makes a copy of the object on which it is called. The implementation of this method performs a shallow copy instance variable values in one object are copied into another object of the same type. For reference types, only the references are copied.
– ReferenceEquals : This static method takes two object arguments and returns True if two objects are the same instance or if they are null references. Otherwise, it returns false.
– ToString : The default implementation of this method returns the namespace followed by a dot and the class name of the object’s class.
– To override a base class method, a derived class must declare a method with keyword override and with the same signature (method name, number of parameters and parameter types) and return type as the base class method
– Software is said to be fragile or brittle when a small change in the base class can "break" derived class implementation. You should be able to change the base class implementation while still providing the same services to the derived classes.
– Place the keyword base and the dot (.) operator before the base class method name to invoke an overridden base class method from a derived class.
– All classes in C# inherit directly or indirectly from the object class, so its seven methods are inherited by all other classes. These methods are Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ReferenceEquals and ToString
– All array types implicitly inherit from class Array in the System namespace, which in turn extends class object. As a result, like all other objects, an array inherits the members of class object
– We distinguish between the is-a relationship and the has-a relationship. Is-a represents inheritance. In an is-a relationship, an object of a derived class can also be treated as an object of its base class. For example, a car is a vehicle, and a truck is a vehicle. By contrast, has-a represents composition. In a has-a relationship, an object contains as members references to other objects. For example, a car has a steering wheel, and a car object has a reference to a steering wheel object
– Abstract Classes
– Concrete Classes
– Dynamic binding or late binding
The interface specifies what operations a radio must permit users to perform but does not specify how the operations are performed
An interface is typically used when disparate (i.e., unrelated) classes need to share common methods
- is an indication of a problem that occurs during a program’s execution
- Stack Trace
- Data maintained in files often is called persistent data
- Search engines are used to find Web sites. They usually catalog sites by following links from page to page (known as spidering or crawling) and saving identification and classification information for each page. One way that search engines catalog pages is by reading the content in each page’s meta elements, which specify information about a document
- http://www.deitel.com/books/downloads.html , The http:// indicates that the resource is to be obtained using the HTTP protocol. The middle portion, www.deitel.com, is the server’s fully qualified hostname the name of the computer on which the resource resides. This computer usually is referred to as the host, because it houses and maintains resources. The hostname www.deitel.com is translated into an IP address (126.96.36.199), which identifies the server in a manner similar to how a telephone number uniquely defines a particular phone line. The hostname is translated into an IP address by a domain name system (DNS) server a computer that maintains a database of hostnames and their corresponding IP addresses. This translation operation is called a DNS lookup
Client interacting with Web server:
The GET request is sent from the client to the Web Server
After it receives the request, the Web Server searches through its system for the resource.
- Error: HTTP/1.1 404 Not found
The server responds to the request with an appropriate message and the resource’s contents
MIME is an Internet standard:
that specifies data formats so that programs can interpret data correctly. For example, the MIME type text/plain indicates that the sent information is text that can be displayed directly, without any interpretation of the content as XHTML markup. Similarly, the MIME type image/jpeg indicates that the content is a JPEG image. When the browser receives this MIME type, it attempts to display the image
- The header or set of headers is followed by a blank line, which indicates to the client that the server is finished sending HTTP headers
- based applications are multitier applications (sometimes referred to as n-tier applications). Multitier applications divide functionality into separate tiers (i.e., logical groupings of functionality). Although tiers can be located on the same computer, the tiers of Web-based applications typically reside on separate computers
- relative positioning
- absolute positioning
- When the XHTML for our page is created, the validator is converted into ECMAScript that performs the validation. ECMAScript is a scripting language that enhances the functionality and appearance of Web pages. ECMAScript is typically executed on the client. Some clients do not support scripting or disable scripting. However, for security reasons, validation is always performed on the server whether or not the script executes on the client
Cookies provide Web developers with a tool for personalizing Web pages. A cookie is a piece of data stored in a small text file on the user’s computer. A cookie maintains information about the client during and between browser sessions. The first time a user visits the Web site, the user’s computer might receive a cookie; this cookie is then reactivated each time the user revisits that site. The collected information is intended to be an anonymous record containing data that is used to personalize the user’s future visits to the site