外贸建站分享 · 5 7 月, 2020 0

Object-Oriented Programming Terms

Object-Oriented Programming Terms是转载自Deborah’s Blog,目的是为了理解编程的几个基本概念和理解html中术语意义,比如class, property, method, attribute, parameter等等,使用原文能更清晰的理解术语的意思。

Basic Object-Oriented Programming Terms

Object-Oriented Programming (OOP): An approach to designing and building applications that are flexible, natural, well-crafted, and testable by focusing on objects that interact cleanly with one another. Object-oriented Programming terms are very similar in different programming languages, but with different coding principles.

Class: The code describing a particular entity in the application, such as Customer, Order, or Address. The class contains the code defining the properties and methods (see below).
类:描述一种应用场景中一类特殊实体的代码,比如客户、订单或地址。类包含特征和方法代码。

Property: The code defining the data managed by the class, such as CustomerName, OrderNumber, or EmailAddress.
特征:由类管理的数据的代码,比如客户名称、订单号或邮件地址

Method: The code defining the actions or behaviors of the class, such as Validate or CalculateTotal. Methods are defined in the code with C# functions.
方法:定义类动作和行为的代码,比如验证或总计。方法在C# function函数代码中定义

Members: Refers to the properties and methods for a class.
成员:指一个类中的特征和方法

Object: An instance of a class that is created at runtime. In C#, an instance is created with the new keyword.
对象:某一类的一个实例。在C#中,创建一个实例用new关键字

Object Variable: The variable used when creating an object. For example, var myCustomer = new Customer(); In this example, myCustomer is the object variable. Use the object variable to set the properties and call the methods. The object variable retains the state of the object.
对象变量:变量在创建一个对象时会使用。对象变量可以获得对象本身的状态。

Method signature: The code defining the method function including the function name and the set of parameters. The signature does not include the return type. Every function signature within a class must be unique. The signature is used to “match up” calls to the function.

Overloading: Methods that have the same name but different parameters. Example: public bool Retrieve() and public bool Retrieve(int id). The Retrieve method in this example is said to have “two overloads”.

Contract: The set of public properties and methods in a class define the classes contract. The class makes a promise that it will provide the defined properties and methods to any other code that needs them. This is also known as the “class interface“.

Constructor: Code that is executed each time an instance of the class is created.

Default Constructor: A constructor with no parameters.

Overriding: When using inheritance (see below), a child class can override a member of the parent class to provide its own implementation.

Interface: An explicit interface is a separate type (INotifyPropertyChanged for example) that defines a set of properties and methods with no implementation. Any class can then implement an interface to use the set of properties and methods provided in the interface. Think of an interface as a role that an object can play. For example, an ILoggable interface defines a logging role. An IEmail interface defines an emailing role. An Order class may implement both the ILoggable and IEmail interface to take on both roles. There is no need to worry about website functionality on smaller devices, as the screen has been optimised to work at its best https://casillascontracting.us/trabajos-en-casinos-de-las-vegas-nv/ and the entire games library is on offer, as well as functions ranging from making a deposit to contacting customer support. An Address class may implement only the ILoggable interface.

Object-Oriented Programming Terms on Four Pillars

The pillars of OOP define the key characteristics of object-oriented programming and are:

Abstraction(抽象): The process of defining classes by simplifying reality, ignoring extraneous details, and focusing on what is important for a purpose. For example, a customer may have a name, title, address, marital status, pets, children, credit card information, vehicles, etc. The following are the top 5 online slots with their bonus rounds and https://parkirpintar.com/hard-rock-hotel-las-vegas-casino-chips/ other details. But if the purpose of the application is to process orders, the application may only care about the customer’s name, address, and credit card information.

Encapsulation(封装): A way to hide (or encapsulate) the data and implementation details within a class, thus hiding complexity. In C#, data elements are defined with private backing fields and exposed through property getters and setters. So the data is encapsulated.

object-oriented programming terms
this picture shows how Encapsulation works

Inheritance(继承): A relationship between classes whereby child (or derived) classes inherit all of the members of the parent (or base) class. For example, an application may define a “business object base” class that all business objects inherit from. The only difference between playing on a PC and on a https://www.siliconvalleycloudit.com/how-to-play-poker-in-spanish/ phone is the size of your screen. This base class can contain members common to all child classes, such as entity state information.

Inheritance
this picture shows Inheritance

Polymorphism(多态): Basically “many forms”. The concept that a single method can behave differently depending on the type of object that calls it. For example, the Validate method in Customer class performs differently from the Validate method in the Order class.

Inheritance-Based Polymorphism: Polymorphism in the case where the method is defined in a base class and behaves differently for each child class.

Interface-Based Polymorphism: Polymorphism in the case where the method is defined in an interface and behaves differently in each class that implements the interface.

Object-Oriented Programming Terms on Class Relationships

Collaboration: “Uses a” relationship. Objects can collaborate with other objects. For example, Customer Repository “uses a” Customer object to populate on a retrieve and serialize on a save. Start with the below-mentioned guides: — Top Online Casinos in India — How to select https://starlitenewsng.com/209-e-casino-rd-everett-wa-98208/ the best one for you?

Composition: “Has a” relationship. Objects can be composed of other objects. For example, Order “has a” Customer and Order “has a” shipping address.

Inheritance: “Is a” relationship. Objects can be subtyped. For example, a Business Type Customer “is a” Customer and a Residential Type Customer “is a” Customer.

C# Object-Orientation Programming Terms

Auto-implemented properties: Properties that create and manage the encapsulated backing field automatically.

Static method: Adding the static modifier on a member of the class (property or method) defines that the member belongs to the class itself, not an instance of the class.

Sealed class: Class that cannot be used as a base class for an inheritance relationship.

Abstract class: Class that cannot be instantiated, so no objects can be created from the class. Nor can it be accessed by its class name. The class can only be used as a base class for other classes.

Concrete class: Class that can be instantiated. Basically, the opposite of an abstract class. Hunt for Free https://www.fontdload.com/casinos-online-que-pagan-directamente-a-paypal/ Games with 40 Spins.

Static class: Class that cannot be instantiated, so no objects can be created from the class. The class members are instead accessed using the class name. A static class provides a shortcut to the members of the class when instancing is unwarranted. For example, the .NET Framework Console class is a static class. To call the WriteLine method you use Console.WriteLine. You don’t have to create a new instance of Console.

Abstract method: Method with no implementation (basically no code). The method must be overridden by a child class.

Virtual method: Method with an implementation that can be overridden by a child class.