Comprehensive analysis of abstract classes and interfaces and complete case narration (II.)

Source: Internet
Author: User
Tags abstract

Through in-depth inheritance of abstract classes and interfaces comprehensive analysis and a complete case list (i), I think we have recognized the great power of knowledge sharing. What I see above the door is not one of us in a short period of time can be summed up, but we summed up, the result is so cool.

I hope that everyone can be generous, do not be so stingy, lest you know that knowledge is known by others. The job is robbed by others, in fact, in the process of sharing with people is not blindly in the pay, you will also have a harvest, whether it is to help others to answer questions or to communicate with others, as if I was writing (or saying I was in the copy of other people's experience), it seems that I was free for everyone to do, in fact, I have the same harvest, Because I wrote this article when I found a lot of I used to learn and use in one of the dead ends, but also found a lot of updates, better skills.

So I believe that as long as we are everyone as much as possible to share what you have learned, and ultimately bring the common progress of everyone. In the park I particularly like Lao Zhao (MSDN Web cast's asp.net ajax Simple series course), Dflying Chen (Ajax series), Zhang Yi teacher (software Design essentials and Mode, WCF), Li Huijun (new design mode) and other comrades, He door books and articles I believe that everyone will benefit from the light, they are in the park rankings and contributions are common to see.

Perhaps everybody discovered me to Zhang Yi to call the teacher, this is why? Listed above the cattle I know Zhang Yi, know my friends do not say that I and his surname only special introduction, in fact, it is not so. In the course of my study, Zhang Yi teacher helped me a lot, in the last year of my college graduation, I was in the company of Zhang Teacher internship (he was my door. NET development of a minister, Tube people can be strict, I quietly said, we have seen this sentence must be dizzy, hehe, he has given me a lot of courses and opened a lot of technical lectures, I think we all know, for a college students did not graduate, there is no certain project development experience in writing a paper when it is very laborious, In my exam system analyst during the paper to get his guidance let me pass the exam, where I borrow the garden position to Miss Zhang said thank you. In addition, his "Software Design essentials and Patterns" For my help is also very large, although this is not a book on the design pattern, his writing is mainly explained by the design mode, and finally to Ms Open source project PetShop 4.0 as a case study of the application of the model, personally feel that write very well, I have used many of the design ideas in my current project.

See here everyone is not think I this person is very wordy, write articles to introduce cattle and books to go, this is not for his door to advertise???

Well, the word is turning, I door or into the theme, the play can not sing half stop it, since the beginning then play in the poor also have to sing finished it. Take a look at the following example:

We are based on the case of a small bookstore, of course, the example can not accurately explain everything, just that through this class to make people more perceptual understanding of the use of abstract classes and interfaces.

First, analyze the business of the bookstore

1. Books are available for fathers and sales

2. The classification of the book is three aspects, so sales and the price of the ancestors are also divided into three grades

3. Customers are divided into members and ordinary customers

Through the above analysis, we can begin to conceive the realization of the program

1. Any book that buys that discount needs a cash purchase for the book.

2. No matter what kind of books you rent, you need to pay the corresponding rent

3. No matter which type of business needs to return the detailed information (should actually be written to the database)

4. No matter what his logic is, we do not need to know so much at the front desk, we want to use the information we now know straight

In exchange for the action to be done.

These two we use the interface to define the money returned.

Then define an interface method to handle our write database operations (here is the return details)

Next, make an enumeration of the type of customer, the type of transaction, the type of book and the type of loan (whether it's a rent or a book).

Let's take a look at a UML diagram and I believe it's easier to speak clearly than I do with my hand on the keyboard.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.