Stockeye 持续集成之路 —— NotificationStockQuote 开发实录

关键字 :Jenkins、Gradle、Jacoco、Android Studio、JUnit 和 Robolectri(只适用Android API Level 16、 17、18)

预构

  • 故事点(Agile - Scrum):用户可拉下通知框以查看实时股票信息
  • 界面草图(见下图)
  • 软件设计模式 :观察者模式(Notification 为观察者,数据更新服务为目标,可能有多个不同类型观察者,考虑引进中介者模式以减轻服务管理依赖负担)
  • 类:NotificationStockQuote,接口 -> IObserverNotificationStockQuote,数据结构 -> 二维数组(界面布局采取Listview)

项目概览

项目 build.gradle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
classpath 'org.robolectric:robolectric-gradle-plugin:0.13.+'
}
}
allprojects {
repositories {
jcenter()
}
}

app. build.gradle

more >>

持续集成之路 —— Stockeye CalendarStock 库开发实录

关键字 :Jenkins、Gradle、JUnit、Jacoco、jar 包和库、TDD

库项目结构

1
2
3
4
5
6
| build.gradle
| src
| |- main
| |- java/com/msolo/stockeye/calendarstock/UtilCalTime.java
| |- test
| |- java/com/msolo/stockeye/calendarstock/UtilCalTimeTest.java

构建脚本(无 Jacoco)

1
2
3
4
5
6
7
8
9
10
11
apply plugin: 'java'
version = 0.1
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
}
task libJavadocs(type: Javadoc) {
source = sourceSets.main.allJava
}

Jenkins 项目配置(无 JaCoCo)

  • 项目名称:android_stockeye_cal_lib
  • 源码管理:https://github.com/mSoloMoon/android_stockeye_calendar_lib.git
  • 构建触发器:Poll SCM -> *
  • 构建步骤1:Invoke Gradle script -> Switch -> clean build javadoc
  • 构建后操作1:Publish JUnit test result report -> XML -> */build/test-results/.xml
  • 构建后操作2:Publish Javadoc -> build/docs/javadoc/

持续集成(无 JaCoCo)

项目首页
测试结果总结

more >>

Stockeye项目 - CalendarStock包(初步设计)

预构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// class UtilCalTime
public int getIntCal();
public String getStrCal();
public String getCalFormat();
public String getTimeHHMMSS();
public String getTimeFormat();
public String getLatestDayOfStock();
public String[] getWorkdayArrayUtilNow();
public int getIntWeekday();
public String getWeekday();
public int getCountByTenSecond();
public boolean checkIsWorkday();
public String convertIntToCalFormat();
public int convertStrCalToInt();
public int getQuarterByMonth();
public int getWeekIndexOfYear();
public int getDateIndexOfYear();

more >>

Stockeye 项目重新设计指引

将原先在软件中不可分割的包按功能、使用方式的思路重新设计,
可做成以第三方库为基准的组件有:股票的报价、股票的预警、股票的资产状况;股票的资讯;股票的图表库(基础K线图);股票的聊天库;
可高度组件化、不可分割的组件有:股票的数据库设计及实现;股票的定制查询库;

库的设计

1、关于股票报价、股票的预警、股票的资产状况

  • 核心对象举例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
StockPriceObjList stockPriceObjList = StockPriceObjList.getInstance();
stockPriceObjList.init();
stockPriceObjList.addStock();
stockPriceObjList.addStockArray();
StockPriceObj obj = stockPriceObjList.get(0);
class StockPriceObj {
String sName;
String sCode;
boolean hasSettedAlert
int alertPrice;
long alertVolume;
int curPrice;
long curVolume;
}

more >>