Blog Park Client (Universal App) Development essay-Project and directory organization in UAP

Source: Internet
Author: User

Objective

This essay is mainly about sharing the directory organization structure of a universal app, explaining what structure is suitable for a team development and minimizing the interaction between development members. These well-organized projects and catalogs can become a public protocol, and everyone can know where to put it or where it can be found. This is essential to avoid repeating code or to maximize code reuse.

This kind of engineering structure and directory Division although there is no theoretical basis, but it is through the experience of many of our projects, if it is a personal developer, also seriously recommend reference to this organizational structure, can help you clear your mind, good functional design and class design.

Project organization

Develop a universal app, if the previous article said, the basic framework in the VS (I'm sorry I installed an English version here), first select Universal apps, then select the blank App, and then change App1 to Cnblogs, you can punch OK.

It lacks the capital to help you build three projects:CNBlogs.Windows (Windows 8.1) and Cnblogs.windowsphone (Windows Phone 8.1). There is also a special cnblogs.shared, with the extension. Shproj, which is shared by the above two project.

If you make a simple UAP, these three project will suffice. But when it comes to larger projects that the team develops, there are some other supporting project and a series of folders to cope with. As shown in the following:

We have created the following auxiliary project:

1) Backgroundtask

2) Datahelper

3) Notificatoinsextensions

The description is as follows:

1) The main task of Backgroundtask is to update live tiles in the background. We will explain this later when we talk about Windows/phone's background tasks.

2) Datahelper, there are two folder, a Cloudapi, inside for each datasource (API interface) has a separate class to deal with, but also according to the similarity of each datasource, to abstract the lower class. The other is Datamodel, which is the data model class. This datahelper will be carefully said in our follow-up CLOUDAPI chapter.

3) Notificatoinsextensions This is actually not our own writing, is directly from the MSDN sample download (according to Microsoft's recommendations, but do not understand why not a library, but in the form of source code). This project mainly gives some help methods to simply update the tile, otherwise it is necessary to directly manipulate the XML data to update the tile, very error-prone, and not easy to understand. This is when you talk about live tiles.

Here's a question: Why is Datahelper project not in shared? The reason is very simple: because Backgroundtask also needs to access datahelper, if it is not accessible in shared, because GKFX only for Windows/windowsphone two project services. (If there is anything wrong with my understanding here, please correct the prawns)

Directory organization

Let's focus on Windows, WindowsPhone, shared three folders in project.

Cnblogs.windows (Windows 8.1)

1) Assets

It contains the image files, generally there are three categories: a) Tile class, only for the tile; B) The image class, only for background maps, decorations and the like; C) icon class, placed in the AppBar icons. If the project is large, the image file is more, you can create three subfolders under this folder, respectively, tile, image, Icon.

2) Common

This is the system comes with. If the system does not generate this folder, you can generate it by specifying basicpage when you add a new page. There are 4 files in this folder, including a lot of help functions that are used when dealing with navigation. Do not move it easily.

3) Controls

Here are your little babes, the template control, or the user control. If it is a template Control, it only puts a XXXControl.cs; If it's a user Control, put a xxxcontrol.xaml in it, and the XXXControl.xaml.cs is included below. Regarding the difference between these two control, we follow a special blog to explain.

5) Pages

This is where your big babes are, that's the page. Each page has a separate XAML and a. cs file that accompanies it to describe its style and behavior, as well as its interaction with other pages.

6) Settingflyouts

The Settings page in Windows is special, on the right, is a protocol, the mouse button or swipe the right border to pop up 5 system buttons, press the following "settings" to go to an app's own settings page. These settings pages are actually expressed in XAML.

7) Themes

Here is the template control style, there is only one generic.xml, which put all the custom template control style (User control is not here). No need to move it out and put it somewhere else, don't be a neat freak, who knows what's wrong with moving somewhere else.

folder on these, each has its own use, some systems built, some of your own built, the purpose is only one, so that you and others can quickly find things.

There is one place to pay attention to, is namespace. If you right-click on project to add a page, namespace is cnblogs; If you add it on Pages, namespace is cnblogs.pages. Yes, but be unified, or you'll have trouble.

Cnblogs.windowsphone (Windows Phone 8.1)

Windows Phone's folder and the basic Windows, just the bottom of the pages and views of the difference, this is just a matter of habit, you casually.

Cnblogs.shared

Shared project is a bit different, let's say it carefully.

1) Assets

If Windows/phone has the same image resource (look/color/size is the same), you can just put one copy here. But at present Windows/phone tile has the size difference, therefore the tile part must divide open. The background map and the like certainly are not the same, a big small. The icon section may be consistent because the Appbarbutton size is the same in AppBar under Windows and phone.

2) Controlhelper

This is generally placed in two types of CS files, one is Templateselector, the other is converter, is the data conversion class. This is what we're talking about in the back of the blog (remember to remind me that I've promised a lot of things). These two kinds of things are common for windows/phone.

3) Functionhelper

As the name implies, put your own generic helper function class.

4) HTML

Optional, look at the project. If the project is useful to WebView, you may need some initial HTML or CSS.

5) SampleData

For most applications, data support is required, either local data or remote data. When data is not in place (Cloudapi part is not finished), you can manually make some simulation data here, without affecting the development progress.

6) Strings

These are resources, divided by country/market. For example, we have only one ZH-CN subdirectory, and maybe a ja-jp subdirectory with RESOURCES.RESW in it. This way:

All the strings used in the interface are thrown inside, for example, there is a "title \ T Home" in ZH-CN, there must be a "title \ t Home" in en-us, in order to display different languages in different countries.

7) App.xaml and Styledictionary.xaml

Shared, it's okay to put it here. Especially Styledictionary.xaml, which contains all the colors, fonts, styles and other information, your application on Windows using blue-on-white, on the Windows Phone to unify the use of white on the blue, relying on the information in this file.

Summary

In this essay, we emphasize the importance of CLOUDAPI because we have summed up the importance of cloud data and service support from many successful apps. And it weakens the importance of MVVM because we realize in practice that model and view are indispensable, but viewmodel is not so important, code duplication, readability, and a lot of ways to replace it. As for what can be automated testing, not at all. Development and testing, to help save costs, improve work efficiency, enhance the responsibility of developers.

You can download the source code we share from here:

Https://code.msdn.microsoft.com/CNBlogs-Client-Universal-9c9692d1

Of course, you can directly download two apps to see the effect, but because the designer involved in the late, so the UI needs to be perfect, we will continue to update the app.

Windows Phone Store App Link:

http://www.windowsphone.com/zh-cn/store/app/Blog Park-UAP/500F08F0-5BE8-4723-AFF9-A397BEEE52FC

Windows Store App Link:

http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

Pure clean app, no ads inside, please feel free to use.

Share the code and change the world!

Blog Park Client (Universal App) Development essay-Project and directory organization in UAP

Related Article

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.