C # is purely object-oriented programming language, it really embodies the "everything is an object" spirit. In C #, even the most basic data types such as int, double, bool type, belonged to System.Object type. In addition, the use of C # programming, and separated from the object does not exist outside of what kind of process. Therefore, learning C #, it must have the object-oriented thinking, do not understand the so-called "object-oriented thinking", it is impossible to grasp the essence of C #, C # and for the understanding of language features can only be limited to the surface of the.
Many books explain object-oriented ideas and articles like the object-oriented and process-oriented comparison, but for beginners to learn programming is not necessary. A blank sheet of paper, in fact, the words written on paper than the more favorable future.
So what is "object oriented"? The essence of course, "everything is an object" significance. Software development and design centers around the development goals of the. Such as the development of a e-commerce site, then e-commerce-related operation and we are concerned, products, orders, users, directories, shopping cart, etc., are all objects. If you want to develop a forum, then the forum necessary elements, such as the forum categories, topics, posts, comments, users, all in the object. Small office, we asked to write an algorithm to calculate factorial, then the initial value, operation results and the algorithm is an object.
What if the object has the characteristics? Generally speaking, an object should have properties and behavior. To the real world, for example, "person" as a special animal, but also we call "object." This object has many properties, such as name, height, weight, ethnicity, nationality, date of birth and so on. The act does, it can be walking, eating, running, and even play games, play football. If you learn from the semantic point of view, the property is more biased in favor of the scope of the term, while the behavior is close to the verb. However, there are special circumstances an object, or just have the property, or only with behavior. Such as ID card, may only have a name, date of birth, place of origin, ID number and other properties, not behavior. Such as "fly", which itself is a movement, but can also be considered an act.
However, this division is not absolute, according to the actual situation, the same object with the properties and behavior may be different. For example, the same "people", if it is to develop a household registration system, we do not have to consider walking, eating, running etc., but if it is a football game, then the object "person", we need all kinds of soccer moves As the behavior of the object. Another example "ID" object, may also be to easy to use, it will add "IsValidate" such an act.
Also note that the fact itself is often an object attribute, such as name, can be string type, it is Sytem.Object object type, we can separate the name of a class object:
public class Name
(
public string FirstName;
public string MiddleName;
public string LastName;
)
In C #, there are a variety of object types, in addition to the basic type itself, but also support custom types, including class, struct, enum, interface, delegate, event. Using the previous example, many objects Person "who" can be defined as the class type, nationality can be defined as the enum type. ID cards do not act, can also be defined as a struct type. Action "fly" can be defined as interface type. As for the delegate and event, is a special object type, such as the Forum management system we can define a series of events, such as BeforePost, AfterPost so. On these elements, I will explain in detail the contents of the back.
To grasp the object-oriented thinking, we must have the capacity of the object recognition system. We want to develop the system, which need to define a separate object, and this object should have properties and behaviors which are more headaches for beginners. To correctly identify the object, you need to first analyze the system functionality to be achieved. For example, we sought to develop a e-commerce system, functional requirements are as follows:
1, support the product search function;
2, the user need to purchase goods, need to be a registered user and log;
3, if the current inventory without the goods, the user can book;
4, users can add to shopping cart of goods;
5, prior to the purchase of goods required to submit orders;
6, the user submits the order, the system should send a message to the user subscription information;
7, the user can add a comment on the product.
There is a simple way to help us identify the object, is to find these features describe the key terms, such as commodities, the user, shopping cart, order, comments. These words are basically to cover the main target of the e-commerce system. As for the object's properties, you can visit the system requirements on the object and the information they need. Such as commodity, necessarily require brand name, price, related images, their class, inventory and so on. As for the behavior, we can look for from the functional description in terms of these objects associated with the verb. For example, a query of goods, goods on behalf of a Search behavior. User registration and login, on behalf of the user behavior with these two: Register, SignIn. Of course, acts of nature also implies SignOut.
Recommended links:
Rising 2008, accused of dangerous: not Considered extreme?
Teaching And Training Tools Guide
EXPERT Games And Entertainment
B2C transactions in China this year is expected to reach 11.1 Billion U.S. dollars
CISCO "NOW Van" trip to China depart
.dvd file
Kingston New-miniSD impression
avi to mp4 converter Free
psp 6000
An amazing order THINKING
3gpp Converter
Update The Fastest Player - Music Video Box Fish
Three steps teach you to set up a SEPARATE page header and footer
No comments:
Post a Comment