需要设计一个android应用程序的架构设计
我需要为我的应用程序创建架构设计。
应用程序详细信息:在我的应用程序中,我显示了一些从服务器获取的数据。因此,基本上,当您启动应用程序时,您会获得一个类别列表,当您单击一个类别时,应用程序会使用 REST 调用 Web 服务并获得 JSON 响应。收到响应后,解析 JSON 数据以创建对象的 Arraylist,最后适配器在列表视图中显示此数据。
我想到的包结构:
com.app.activities:
包含应用程序中所需的所有活动。
com.app.customviews:
应用程序所需的自定义视图。
com.app.adapters:
不同的列表/网格适配器,用于创建不同类型的列表和网格视图。
com.app.parsers:
包含用于解析从服务器接收到的 JSON 响应的所有解析器类。这些类基本上将向活动返回一个数组列表,适配器类将进一步使用该数组列表来创建列表和网格视图。
com.app.utils:
包含在整个应用程序中使用的函数,例如从服务器获取请求响应、从输入流获取字符串、从某个 url 下载图像、记录日志的函数
com.app.model: 包含各种用户定义数据类型的所有模型类。
应用工作流程:当选择某个类别时,activity
会从 utils
获取响应,并将其发送到 parsers
以获取 的数组列表>模型
类型。现在这个数组列表被传递给适配器,适配器返回一个适配器对象,该对象最终用于在活动中显示列表/网格。
现在根据应用程序架构,您的代码应分为以下三层:
- 表示层
- 业务层
- 数据层
现在我需要知道,根据我的应用程序,哪一部分属于哪一层。
请帮忙,我对此完全一无所知。
谢谢!!
更新:在谷歌搜索时我偶然发现了这个链接:
http://apparchguide.codeplex.com/wikipage?title=Chapter%2019%20-%20Mobile%20Applications
它说,您的应用程序应该有一些工作流程、业务组件、实体等。
所以,我认为我当前的包结构不正确,因为我只在活动中做大部分事情。
所以现在,我的问题是:如果我遵循这种架构,包结构应该是什么或者如何设置我的代码库。
I need to create an architecture design for my application.
App Details: In my app, i show some data which is fetched from server. So basically when you start the app, you get a list of categories and when you click on a category, application calls a web service using REST and get a JSON response. After getting the response, JSON data is parsed to create an Arraylist of objects and finally an adapter shows this data in a list view.
Package structure which i have thought of:
com.app.activities:
contains all the activities required in the application.
com.app.customviews:
custom views required for the application.
com.app.adapters:
different list/grid adapters to create different types of list and grid views.
com.app.parsers:
contains all parser classes to parse the JSON response received from the server. These classes basically will return an arraylist to the activities which will be further used by adapter class for creating list and grid views.
com.app.utils:
contains functions which are used through out the application like function for getting the response from server for a request, getting a string from the inputstream, download an image from a certain url, logging etc.
com.app.model:
contains all the model classes for various user-defined data types.
App work flow: When a certain category is selected, activity
gets the response from utils
and send it to parsers
to get an arraylist of Model
type. Now this arraylist is passed to the adapters
which returns an adapter object which is finally used in showing the list/grid in the activity
.
Now as per the application architecture, your code should be divided into following three layers:
- Presentation Layer
- Business Layer
- Data Layer
Now i need to know, as per my application which part belong to which layer.
Please help, i am totally clueless about this.
thanks!!
Update: While googling i stumbled upon this link:
http://apparchguide.codeplex.com/wikipage?title=Chapter%2019%20-%20Mobile%20Applications
It says, your application should have some workflows, business components, entities etc.
So, i think my current package structure is incorrect as i am doing most of thing in Activities only.
So now, my question is: If i follow this architecture, what should be package structure or how do i setup my code base.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的应用程序仅用于演示吗?业务层是在服务器中实现的,因为您不更改数据,只显示它。
对我来说,模型位于数据层,其余的都是表示。
Is your app is only dedicated to presentation? The business layer is implemented in the server, since you do not change data, only show it.
For me model is in the data layer, all the rest is presentation.
你的应用程序的UI,你可以说它是表示层。在业务层中,您使用 REST 和 JSON Web 服务进行操作。数据层驻留在服务器上。所以基本上你通过使用一些服务(业务)从服务器(数据)获取结果(信息)来显示列表视图(演示文稿)。
your UI of application is, you can say it presentation layer. In business layer you do operations with REST and JSON web service. And the data layer resides on server. So basically you display the listview(Presentation) by using some services(Business) to get result(information) from server(Data).