開發(fā)app項目對于各個模塊功能架構(gòu)的設(shè)計,深圳APP開發(fā)公司本欄目就以下幾種設(shè)計方式與代碼進行分享,希望能給您的項目規(guī)劃與設(shè)計工作有所幫助,業(yè)務(wù)邏輯層設(shè)計(Presenter)MVP架構(gòu)中的業(yè)務(wù)邏輯層可以分為兩大功能模塊:接口模塊和功能模塊。強化Presenter層的作用,將所有邏輯操作都放在Presenter層內(nèi)也容易造成Presenter層的代碼量比較大,在這層內(nèi)可按功能把代碼分成不同的功能塊,以方便管理。
APP開發(fā)關(guān)于數(shù)據(jù)訪問層模塊設(shè)計
(Model)Android應(yīng)用的數(shù)據(jù)訪問層包括SharedPreferences、File、DataBase和HTTP等與讀寫數(shù)據(jù)相關(guān)的類,分為三大功能模塊:接口模塊、功能模塊和實體類模塊。
APP開發(fā)關(guān)于功能模塊設(shè)計
實體類模塊實體類是現(xiàn)實實體在計算機中的表示。它貫穿于整個架構(gòu),負擔(dān)著在各層次及模塊間傳遞數(shù)據(jù)的職責(zé)。此模塊包括與各種數(shù)據(jù)相關(guān)的類,通常包含在Model層中。在處理類對象數(shù)據(jù)的時候,常需要把數(shù)據(jù)序列化,因此實體
實體類需要繼承Parcelable或Serializable這兩個接口類(建議優(yōu)先使用Parcelable)。Java語言在數(shù)據(jù)賦值/拷貝的時候,常是淺賦值/淺拷貝,因此實體類還需要繼承Cloneable這個接口類,利用clone方法實現(xiàn)數(shù)據(jù)的深賦值/深拷貝,示例代碼如下所示。
public class CommentDetail implements Parcelable, Cloneable { public String commentContent; public int commentId; public CommentDetail clone() { CommentDetail commentDetail = null; try { commentDetail = (CommentDetail) super. clone(); } catch (CloneNotSupportedException e) { e. printStackTrace(); } return commentDetail; } @ Override
public String toString() { return "CommentDetail{" + " commentContent = '" + commentContent + '\ ' ' + ", commentId = '" + commentId + '\ ' ' + '} '; } @ Override public int describeContents() { return 0; } @ Override public void writeToParcel( Parcel dest, int flags) { dest. writeString( this. commentContent); dest. writeInt( this. commentId); } public CommentDetail() {} protected CommentDetail( Parcel in) { this. commentContent = in. readString(); this. commentId= in. readInt(); } public static final Creator< CommentDetail> CREATOR = new Creator
Creator < CommentDetail>() { public CommentDetail createFromParcel( Parcel source) {return new CommentDetail (source);} public CommentDetail[] newArray( int size) {return new CommentDetail[ size];} }; private void setCommentContent( String strContent){ commentContent = strContent; } private String getCommentContent(){ return commentContent; } private void setCommentId( int intId){ commentId = intId; } private int getCommentId(){ return commentId; } }
APP開發(fā)公司關(guān)于輔助類模塊設(shè)計經(jīng)驗分享
此模塊包括各種全局輔助性功能的工具類,如對手機號碼的校驗、字符串的特殊處理、獲取設(shè)備的相關(guān)信息等功能都可放在這個模塊,日志功能通常也放在這個模塊。
APP開發(fā)公司關(guān)于第三方功能模塊設(shè)計方法解析
在APP中使用的三方功能模塊大體分為下面兩類。各類控件。具體功能。如掃碼、地圖、推送和統(tǒng)計等功能。此功能模塊可以按上述分類,再細分不同子模塊。對于各功能模塊,如地圖,可能用百度的,也可能用高德的,建議增加一個適配層,這樣切換不同的SDK時不需要修改調(diào)用此模塊的代碼。好了,APP開發(fā)公司本文關(guān)于“APP開發(fā)公司分享關(guān)于利用clone方法實現(xiàn)數(shù)據(jù)的深賦值的代碼”知識就分享到這里,謝謝關(guān)注,博納網(wǎng)絡(luò)編輯整理。