主頁 > 軟體設計 > 初學者對C語言的愛恨情仇之神秘的字串

初學者對C語言的愛恨情仇之神秘的字串

2021-08-05 08:02:30 軟體設計

文章目錄

  • 前言
  • 字串是誰
  • 經常聽說字串字面量,究竟是什么鬼?
  • 字串字面量如何存盤的
  • C語言字符陣列與字符指標
  • C語言中的字串庫
    • 1、strlen函式
    • 2、strcat 和 strncat函式
    • 3、strcmp 和 strncmp函式
    • 4、strcpy 和 strncpy函式

前言

本文是針對對字串有疑惑的初學者,例如:對C語言中的字串并不了解,不太會使用,學過其他編程語言,現在轉入了C語言,但是在C語言中使用字串時不能像Java一樣如愿以償,自由自在的使用,那么就可以看本篇文章,本篇文章不會涉及太深的東西,太深的東西對于初學者會受不了的,

字串是誰

說到字串是誰,那么需要提一下字符是什么,沒有字符就沒有字串,

像我們學的“每一個”英文字符(a,b,c…)都是屬于字符,并且漢字、數字、標點符號都是屬于一個字符;

像“我是誰,我在哪”這7個字符合起來就是一個字串,那么串的話其實就是多個字符合在一起的結果,

經常聽說字串字面量,究竟是什么鬼?

經常聽別人說字串字面量,字面量的這是啥呢?

其實你一點也磨陌生,可能只是對這個名字陌生一些,你在學習Hello World的時候,其實就在用了,沒錯用雙引號包含的“Hello World”就是字串字面量,

printf("Hello World!");

執行結果:

Hello World!

我們想換行時,可以加個\n:

printf("Hello  \n   World!");

結果:

Hello  
   World!

字串字面量如何存盤的

例如字串:"Hello World!"

你看著是一個字串,實際上在存盤的時候,是像陣列一樣,一個字符一個字符分開存的,

[“H”,“e”,“l”,“l”,“o”," “,“W”,“o”,“r”,“l”,“d”,”!","\0"];

在存盤的時候,每個字串的結尾是包含"\0",所以一般我們如果不知道一個字串的長度如何遍歷每個字符呢?那就可以使用"\0"條件來判斷,

C語言字符陣列與字符指標

我們可以利用char型別的陣列,來定義和初始化字串,

char str[12] = "I Love You!";
char *pStr = "I Love You!";

我們在列印的時候,需要使用%s來格式化數值:

printf("str=%s\n",str);
printf("pStr=%s\n",pStr);

列印結果:

str=I Love You!
pStr=I Love You!

也支持多種單個訪問方式:

printf("*(str+2)=%c\n",*(str+2));
printf("*(pStr+2)=%c\n",*(pStr+2));

結果:

*(str+2)=L
*(pStr+2)=L

C語言中的字串庫

在Java中有String型別的jar包,在C語言中也有相應的字串庫,無論是Java中的jar包,還是C語言中的庫,其實都是一些封裝好的工具,以便給他人使用,

在實際開發中,我們掌握這些庫的基本用法是必須的,可以大大的提高我們的作業效率,

在Linux中我們可以使用man命令來查看幫助手冊,

例如:

man string

會出現下面這樣的結果:
在這里插入圖片描述

可以看到:
在這里插入圖片描述

這些都是我現在這個Ubuntu系統中的string庫中所提供的一些功能的函式,

在此我帶著熟悉幾個常用的函式,

我挑選了幾個常用的,其實也就四種:統計字串中的字符個數、字串拼接、字串比較、字串拷貝/賦值,

SYNOPSIS
       #include <string.h>

       size_t strlen(const char *s);
              Return the length of the string s.

       char *strcat(char *dest, const char *src);
              Append the string src to the string dest, returning a pointer dest.
              
       char *strncat(char *dest, const char *src, size_t n);
              Append at most n bytes from the string src to the string dest, returning a pointer to dest.

       int strcmp(const char *s1, const char *s2);
              Compare the strings s1 with s2.

       int strncmp(const char *s1, const char *s2, size_t n);
              Compare at most n bytes of the strings s1 and s2.

       char *strcpy(char *dest, const char *src);
              Copy the string src to dest, returning a pointer to the start of dest.

       char *strncpy(char *dest, const char *src, size_t n);
              Copy at most n bytes from string src to dest, returning a pointer to the start of dest.

我們如何想使用的話,需要先include一下頭檔案:

本次使用的代碼框架如下:

#include <stdio.h>
#include <string.h>

int main(void)
{
        return 0;
}

1、strlen函式

從函式的名字上也不難看出,這個是跟字串和長度有關系的函式,

如果第一次使用的話,可以使用:man strlen來查看這個函式的使用說明,

在這里插入圖片描述

解釋的非常詳細,

可以看到strlen()函式在計算傳入的字串s的時候是不計算結束符"\0"的,

回傳值是傳入字串s的位元組數/字符格式,

#include <stdio.h>
#include <string.h>

int main(void)
{
        char str[12] = "I Love You!";
        char *pStr = "I Love You!";


        printf("str=%s\n",str);
        printf("pStr=%s\n",pStr);

        int strLen = strlen(str);
        int pStrLen = strlen(pStr);

        printf("str len:%d \n",strLen);
        printf("pStr len:%d \n",pStrLen);

        return 0;
}

結果:

可以看到無論是字符陣列還是字符指標,都是可以統計出來有多少個字符的

zhenghui@zhlinux:~/桌面/code/string$ 
zhenghui@zhlinux:~/桌面/code/string$ make strtest && ./strtest 
cc     strtest.c   -o strtest
str=I Love You!
pStr=I Love You!
str len:11 
pStr len:11 
zhenghui@zhlinux:~/桌面/code/string$ 

計算時到底有沒有跟陣列的大小有關系?

	char str[12] = "I Love You!";
	char str2[100] = "I Love You!";
	char str3[100] = "I        Love      You!   ";
	
	int strLen = strlen(str);
	int strLen2 = strlen(str2);
	int strLen3 = strlen(str3);



	printf("str len:%d \n",strLen);
	printf("str2 len:%d \n",strLen2);
	printf("str3 len:%d \n",strLen3);

列印結果:

str len:11 
str2 len:11 
str3 len:26 

可以看到str2和str統計的數量是一樣的,

從上面結果來看,陣列的大小并不決定這個字串的長度,

strlen函式只統計“\0”結尾之前的字數,而且不算“\0”這個字符,

2、strcat 和 strncat函式

不了解strcat函式可以直接在linux的命令列中輸入:man strcat

就可以看到有兩個相關的函式:

SYNOPSIS
       #include <string.h>

       char *strcat(char *dest, const char *src);

       char *strncat(char *dest, const char *src, size_t n);

還有很詳細的說文,

The  strcat()  function  appends  the src string to the dest string, overwriting the terminating null byte
       ('\0') at the end of dest, and then adds a terminating null byte.  The strings may not  overlap,  and  the
       dest  string  must have enough space for the result.  If dest is not large enough, program behavior is un‐
       predictable; buffer overruns are a favorite avenue for attacking secure programs.

這個strcat函式是用來拼接字串的,分別傳入dest和src字串,最終把src拼接到dest中進行回傳,

實驗代碼:

zhenghui@zhlinux:~/桌面/code/string$ 
zhenghui@zhlinux:~/桌面/code/string$ cat strcatTest.c 
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str1[12] = " I ";
	char str2[100] = " Love ";
	char *pStr = " You!iiiiii ";


	int sl = strlen(str1);
	printf("str1 len :%d \n",sl);

	printf("str1=%s\n",str1);
	printf("str2=%s\n",str2);
	printf("pStr=%s\n",pStr);

	strcat(str1,str2);
	strcat(str1,pStr);

	printf("#####################\n");
	printf("str1 :%s \n",str1);
	sl = strlen(str1);
	printf("str1 len :%d \n",sl);

	return 0;
}
zhenghui@zhlinux:~/桌面/code/string$

執行結果:

用法很簡單,就是傳入兩個需要拼接的字串即可

zhenghui@zhlinux:~/桌面/code/string$ make strcatTest && ./strcatTest
cc     strcatTest.c   -o strcatTest
str1 len :3 
str1= I 
str2= Love 
pStr= You!iiiiii 
#####################
str1 : I  Love  You!iiiiii  
str1 len :21 
zhenghui@zhlinux:~/桌面/code/string$ 

相比較來說,strncat比strcat安全一些,

例如:

如果a的空間是有限的,b的長度又很大,那么就會超出了a的大小,
那么為了安全,就可以使用strncat來指定拼接的大小,

strcat(a,b);

為了安全,我們可以使用strncat:

zhenghui@zhlinux:~/桌面/code/string$ 
zhenghui@zhlinux:~/桌面/code/string$ 
zhenghui@zhlinux:~/桌面/code/string$ cat strcatTest.c 
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str1[12] = " I ";
	char str2[100] = " Love ";
	char *pStr = " You!iiiiii ";


	int sl = strlen(str1);
	printf("str1 len :%d \n",sl);

	printf("str1=%s\n",str1);
	printf("str2=%s\n",str2);
	printf("pStr=%s\n",pStr);

	//strcat(str1,str2);
	//strcat(str1,pStr);
	
	strncat(str1,str2,sizeof(str1) - strlen(str1) - 1);
	strncat(str1,pStr,sizeof(str1) - strlen(str1) - 1);

	printf("#####################\n");
	printf("str1 :%s \n",str1);
	sl = strlen(str1);
	printf("str1 len :%d \n",sl);

	return 0;
}
zhenghui@zhlinux:~/桌面/code/string$ 

可以看到結果也是正常的:

zhenghui@zhlinux:~/桌面/code/string$ make strcatTest && ./strcatTest
cc     strcatTest.c   -o strcatTest
str1 len :3 
str1= I 
str2= Love 
pStr= You!iiiiii 
#####################
str1 : I  Love  Y 
str1 len :11 
zhenghui@zhlinux:~/桌面/code/string$ 

我們使用sizeof(str1) - strlen(str1)就可以計算出str1所剩余的空間,-1是為了給“\0”留出空間,

strncat(str1,str2,sizeof(str1) - strlen(str1) - 1);

3、strcmp 和 strncmp函式

在C語言日常開發中,strcmp是非常常用的,我們做字串比較,兩個字串是否相等,我們直接呼叫這個函式就可以很好的解決這個難題,

我們仍然可以使用:man strcmp來查看幫助手冊:

SYNOPSIS
       #include <string.h>

       int strcmp(const char *s1, const char *s2);

       int strncmp(const char *s1, const char *s2, size_t n);

DESCRIPTION
       The strcmp() function compares the two strings s1 and s2.  The locale is not taken into account (for a lo‐
       cale-aware comparison, see strcoll(3)).  It returns an integer less than, equal to, or greater  than  zero
       if s1 is found, respectively, to be less than, to match, or be greater than s2.

       The strncmp() function is similar, except it compares only the first (at most) n bytes of s1 and s2.

RETURN VALUE
       The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or
       the first n bytes thereof) is found, respectively, to be less than, to match, or be greater than s2.

這是用來比較兩個字串的,

原型如下:

SYNOPSIS
       #include <string.h>

       int strcmp(const char *s1, const char *s2);

       int strncmp(const char *s1, const char *s2, size_t n);

我們需要傳遞兩個字串s1和s2;

回傳值是:

回傳值是一個大于、小于或等于0的值,
如果strcmp(s1,s2)==0:說明s1和s2相等;
如果strcmp(s1,s2) > 0:說明s1 > s2;
如果strcmp(s1,s2) < 0:說明s1 < s2;
當然了<=和>=運算子也是可以使用的,

RETURN VALUE
       The strcmp() and strncmp() functions return an integer less than, equal to, or greater than zero if s1 (or
       the first n bytes thereof) is found, respectively, to be less than, to match, or be greater than s2.

實驗代碼:

zhenghui@zhlinux:~/桌面/code/string$ cat strcmpTest.c 
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str1[12] = "abc";
	char *str2 = "ABC";

	printf("str1=%s\n",str1);
	printf("str2=%s\n",str2);

	printf("#####################\n");
	
	int res1 = strcmp(str1,str2);
	printf("strcmp(str1,str2) :%d \n",res1);

	int res2 = strcmp(str2,str1);
	printf("strcmp(str2,str1) :%d \n",res2);

	if(res1 > 0)
	{
		printf("res1:%s > %s \n",str1,str2);
	}

	if(res2 < 0)
	{
		printf("res2:%s < %s \n",str2,str1);
	}


	return 0;
}
zhenghui@zhlinux:~/桌面/code/string$ 

實驗結果:

zhenghui@zhlinux:~/桌面/code/string$ make strcmpTest && ./strcmpTest
make: “strcmpTest”已是最新,
str1=abc
str2=ABC
#####################
strcmp(str1,str2) :32 
strcmp(str2,str1) :-32 
res1:abc > ABC 
res2:ABC < abc 
zhenghui@zhlinux:~/桌面/code/string$ 

4、strcpy 和 strncpy函式

從字面上看,看著就很想copy拷貝,

沒錯,這個就是拷貝的功能,

同樣,我們使用:man strcpy來查看幫助手冊,

也有很詳細的說明:

SYNOPSIS
       #include <string.h>

       char *strcpy(char *dest, const char *src);

       char *strncpy(char *dest, const char *src, size_t n);

DESCRIPTION
       The  strcpy() function copies the string pointed to by src, including the terminating null byte ('\0'), to
       the buffer pointed to by dest.  The strings may not overlap, and the destination string dest must be large
       enough to receive the copy.  Beware of buffer overruns!  (See BUGS.)

       The strncpy() function is similar, except that at most n bytes of src are copied.  Warning: If there is no
       null byte among the first n bytes of src, the string placed in dest will not be null-terminated.

       If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total
       of n bytes are written.

廢話不多說,直接上代碼:

zhenghui@zhlinux:~/桌面/code/string$ 
zhenghui@zhlinux:~/桌面/code/string$ cat strcpyTest.c 
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str1[12] = " abc aowmdi9";
	char *str2 = " ABC 9999";

	printf("str1=%s\n",str1);
	printf("str2=%s\n",str2);

	printf("#####################\n");
	
	strcpy(str1,str2);


	printf("strcpy(str1,str2):%s \n",str1);


	return 0;
}
zhenghui@zhlinux:~/桌面/code/string$ 

實驗結果:

zhenghui@zhlinux:~/桌面/code/string$ make strcpyTest && ./strcpyTest
make: “strcpyTest”已是最新,
str1= abc aowmdi9
str2= ABC 9999
#####################
strcpy(str1,str2): ABC 9999 
zhenghui@zhlinux:~/桌面/code/string$ 

通過下面代碼可以看出,直接把str2的內容拷貝到了str1中,直接覆寫了,

strcpy(str1,str2);

重點:其實strcpy是用來解決我們不能用賦值運算子來賦值的操作的問題

那么什么時候,不能用“=”號來賦值呢?

例如:
我們定義一個陣列,一開始不賦值,然后等我們業務邏輯到達的時候,再賦值:

char str3[10];

假設到了該賦值的地方:

str3 = "zhenghui";

這個地方會執行錯誤的,

可以看下執行結果:

zhenghui@zhlinux:~/桌面/code/string$ make strcpyTest && ./strcpyTest
cc     strcpyTest.c   -o strcpyTest
strcpyTest.c: In function ‘main’:
strcpyTest.c:11:7: error: assignment to expression with array type
   11 |  str3 = "zhenghui";//錯誤
      |       ^
make: *** [<內置>:strcpyTest] 錯誤 1
zhenghui@zhlinux:~/桌面/code/string$ 

像這種特殊的賦值,我們可以利用strcpy來解決:

strcpy(str3,"zhenghui");

執行就沒問題了,

如果帶引數n的話,就是用來限制copy的資料值的多少,也是為了安全才有的,

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/291907.html

標籤:其他

上一篇:【C語言基礎學習筆記】+ 【C語言進階學習筆記】總結篇(堅持才有識訓!)

下一篇:歡迎光顧C語言的世界(C語言基礎知識)

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 面試突擊第一季,第二季,第三季

    第一季必考 https://www.bilibili.com/video/BV1FE411y79Y?from=search&seid=15921726601957489746 第二季分布式 https://www.bilibili.com/video/BV13f4y127ee/?spm_id_fro ......

    uj5u.com 2020-09-10 05:35:24 more
  • 第三單元作業總結

    1.前言 這應該是本學期最后一次寫作業總結了吧。總體來說,對作業的節奏也差不多掌握了,作業做起來的效率也更高了。雖然和之前的作業一樣,作業中都要用到新的知識,但是相比之前,更加懂得了如何利用工具以及資料。雖然之間卡過殼,但總體而言,這幾次作業還算完成的比較好。 2.作業程序總結 相比前兩個單元,此單 ......

    uj5u.com 2020-09-10 05:35:41 more
  • 北航OO(2020)第四單元博客作業暨課程總結博客

    北航OO(2020)第四單元博客作業暨課程總結博客 本單元作業的架構設計 在本單元中,由于UML圖具有比較清晰的樹形結構,因此我對其中需要進行查詢操作的元素進行了包裝,在樹的父節點中存盤所有孩子的參考。考慮到性能問題,我采用了快取機制,一次查詢后盡可能快取已經遍歷過的資訊,以減少遍歷次數。 本單元我 ......

    uj5u.com 2020-09-10 05:35:48 more
  • BUAA_OO_第四單元

    一、UML決議器設計 ? 先看下題目:第四單元實作一個基于JDK 8帶有效性檢查的UML(Unified Modeling Language)類圖,順序圖,狀態圖分析器 MyUmlInteraction,實際上我們要建立一個有向圖模型,UML中的物件(元素)可能與同級元素連接,也可與低級元素相連形成 ......

    uj5u.com 2020-09-10 05:35:54 more
  • 6.1邏輯運算子

    邏輯運算子 1. && 短路與 運算式1 && 運算式2 01.運算式1為true并且運算式2也為true 整體回傳為true 02.運算式1為false,將不會執行運算式2 整體回傳為false 03.只要有一個運算式為false 整體回傳為false 2. || 短路或 運算式1 || 運算式2 ......

    uj5u.com 2020-09-10 05:35:56 more
  • BUAAOO 第四單元 & 課程總結

    1. 第四單元:StarUml檔案決議 本單元采用了圖模型決議UML。 UML檔案可以抽象為圖、子圖、邊的邏輯結構。 在實作中,圖的節點包括類、介面、屬性,子圖包括狀態圖、順序圖等。 采用了三次遍歷UML元素的方法建圖,第一遍遍歷建點,第二、三次遍歷設定屬性、連邊,實作圖物件的初始化。這里借鑒了一些 ......

    uj5u.com 2020-09-10 05:36:06 more
  • 談談我對C# 多型的理解

    面向物件三要素:封裝、繼承、多型。 封裝和繼承,這兩個比較好理解,但要理解多型的話,可就稍微有點難度了。今天,我們就來講講多型的理解。 我們應該經常會看到面試題目:請談談對多型的理解。 其實呢,多型非常簡單,就一句話:呼叫同一種方法產生了不同的結果。 具體實作方式有三種。 一、多載 多載很簡單。 p ......

    uj5u.com 2020-09-10 05:36:09 more
  • Python 資料驅動工具:DDT

    背景 python 的unittest 沒有自帶資料驅動功能。 所以如果使用unittest,同時又想使用資料驅動,那么就可以使用DDT來完成。 DDT是 “Data-Driven Tests”的縮寫。 資料:http://ddt.readthedocs.io/en/latest/ 使用方法 dd. ......

    uj5u.com 2020-09-10 05:36:13 more
  • Python里面的xlrd模塊詳解

    那我就一下面積個問題對xlrd模塊進行學習一下: 1.什么是xlrd模塊? 2.為什么使用xlrd模塊? 3.怎樣使用xlrd模塊? 1.什么是xlrd模塊? ?python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫excel的庫。 今天就先來說一下xl ......

    uj5u.com 2020-09-10 05:36:28 more
  • 當我們創建HashMap時,底層到底做了什么?

    jdk1.7中的底層實作程序(底層基于陣列+鏈表) 在我們new HashMap()時,底層創建了默認長度為16的一維陣列Entry[ ] table。當我們呼叫map.put(key1,value1)方法向HashMap里添加資料的時候: 首先,呼叫key1所在類的hashCode()計算key1 ......

    uj5u.com 2020-09-10 05:36:38 more
最新发布
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:20:47 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:20:25 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:20:17 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:20:10 more
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:19:44 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:19:07 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:18:57 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:18:49 more
  • 05單件模式

    #經典的單件模式 public class Singleton { private static Singleton uniqueInstance; //一個靜態變數持有Singleton類的唯一實體。 // 其他有用的實體變數寫在這里 //構造器宣告為私有,只有Singleton可以實體化這個類! ......

    uj5u.com 2023-04-19 08:42:51 more
  • 【架構與設計】常見微服務分層架構的區別和落地實踐

    軟體工程的方方面面都遵循一個最基本的道理:沒有銀彈,架構分層模型更是如此,每一種都有各自優缺點,所以請根據不同的業務場景,并遵循簡單、可演進這兩個重要的架構原則選擇合適的架構分層模型即可。 ......

    uj5u.com 2023-04-19 08:42:41 more