--2.C# series of object oriented understanding (Reference)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

What is the idea of object oriented “ ”? the essentials of course is “ all for object ” significance. The design and development of software, is centered around the development goal of. For example, the development of an e-commerce site, so related to electronic commerce are all we have to operate and caring, goods, orders, the user directory, shopping cart, and so on, are objects. If you want to develop a forum, the forum of essential elements, such as the forum theme, classification, posts, comments, the user, also is all objects. I said, we are asked to write an algorithm to calculate the factorial, then starting values, the results of operations, and the algorithms are object.

Then the object is what? generally speaking, an object has attributes and behaviors. In the real world as an example, “ ” as a special kind of animal, but also what we call the &ldquo object;”. This object has many attributes, such as name, height, weight, race, nationality, date of birth and so on. While the behavior, can walk, run, or even to eat, play games, play football. If from the semantic perspective, attribute more biased in favor of noun, verb and behavior is close to. However, object also has a special case, or only has the attribute, or only has the behavior. For example, the ID card, may only have the name, date of birth, nationality, identity card number and other attributes, but no action. For example, &rdquo “ fly; this itself is a kind of action, but also can be regarded as a kind of behavior.

In C#, objects with various types, in addition to the basic type itself provides, custom types also support, including class, struct, enum, interface, delegate, event. In the previous example, the object Person“ ”, can be defined as class type, nationality can be defined as a enum. No act of ID card, can also be defined as a struct. Action &ldquo ” fly; can be defined as a interface. As for delegate and event, is a special type of object, for example, we can define the forum management system, a series of events, such as BeforePost, AfterPost etc.

To master the object-oriented thought, it must have the ability to object recognition system. In the system we have developed, which should be defined as a separate object, and this object should have what attributes and behavior, is a headache problem for beginners. To correctly identify the object, we first need analysis should realize the function of the system. For example, we want to develop an e-commerce system, functional requirements are as follows:

1,Support the commodity inquiry function,

2,If users need to buy goods, need to be a registered user and login,

3,If the current inventory without the commodity, users can book,

4,The user can put the merchandise into the shopping car,

5,Before users to buy goods, need to submit orders,

6,Users submit orders, order information system should be send mail to users,

7,The user can add comments on the goods.

There is a simple method, can help us to identify the object, is to find out the key terms, the function description of the user, such as commercial, shopping cart, orders, review. These words are basically the main object can cover the electronic commerce system. As for the object's properties, can be studied on the object of the system and the information needed to. For example, commodity, must require the commodity name, price, related pictures, category, inventory etc. As for the behavior, we can also find these objects associated with the noun verb from the functional description. For example, the commodity inquiry, on behalf of products with Search behavior. User registration and login, on behalf of the user with these two kinds of behavior: Register, SignIn. Of course, the implicit behavior nature also includes SignOut.

The above is the removal of learning and save from the blog in the garden, I felt very vivid example, finishing first in well preserved, perhaps later forget can come back to have a look, can also learn together with beginners!!!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Corey at November 13, 2013 - 8:19 AM