paulwong

          #

          如何保證同事的代碼不會腐爛?一文帶你了解 Alibaba COLA 架構

          本文開始前,問大家一個問題,你覺得一份業務代碼,尤其是互聯網業務代碼,都有哪些特點?

          我能想到的有這幾點:

          • 互聯網業務迭代快,工期緊,導致代碼結構混亂,幾乎沒有代碼注釋和文檔
          • 互聯網人員變動頻繁,很容易接手別人的老項目,新人根本沒時間吃透代碼結構,緊迫的工期又只能讓屎山越堆越大。
          • 多人一起開發,每個人的編碼習慣不同,工具類代碼各用個的,業務命名也經常沖突,影響效率。
          • 大部分團隊幾乎沒有時間做代碼重構,任由代碼腐爛。

          每當我們新啟動一個代碼倉庫,都是信心滿滿,結構整潔。但是時間越往后,代碼就變得腐敗不堪,技術債務越來越龐大。

          這種情況有解決方案嗎?也是有的:

          1. 小組內定期做代碼重構,解決技術債務。
          2. 組內設計完善的應用架構,讓代碼的腐爛來得慢一些。(當然很難做到完全不腐爛)
          3. 設計盡量簡單,讓不同層級的開發都能快速看懂并上手開發,而不是在一堆復雜的沒人看懂的代碼上堆更多的屎山。

          而COLA,我們今天的主角,就是為了提供一個可落地的業務代碼結構規范,讓你的代碼腐爛的盡可能慢一些,讓團隊的開發效率盡可能快一些。

          https://github.com/alibaba/COLA

          https://blog.csdn.net/significantfrank/article/details/110934799





          posted @ 2023-12-05 10:31 paulwong 閱讀(121) | 評論 (0)編輯 收藏

          reinstall Mac OS

          使用「磁碟工具程式」清除配備 Apple 晶片的 Mac
          https://support.apple.com/zh-hk/HT212030

          在 Mac 清除所有內容和設定
          https://support.apple.com/zh-hk/HT212749

          為 macOS 製作開機安裝程式
          https://support.apple.com/zh-hk/HT201372

          如何重新安裝 macOS
          https://support.apple.com/zh-hk/HT204904

          posted @ 2022-11-11 22:44 paulwong 閱讀(170) | 評論 (0)編輯 收藏

          How to Downgrade macOS Ventura to Monterey, Big Sur, or Earlier

          https://www.drbuho.com/how-to/downgrade-macos


          posted @ 2022-11-11 11:27 paulwong 閱讀(145) | 評論 (0)編輯 收藏

          difference between homebrew and homebrew cask

          https://brew.sh/index_zh-tw

          difference between homebrew and homebrew cask
          https://www.zhihu.com/question/22624898

          install jdk11 on Mac:
          https://medium.com/@kirebyte/using-homebrew-to-install-java-jdk11-on-macos-2021-4a90aa276f1c



          posted @ 2022-11-11 11:21 paulwong 閱讀(158) | 評論 (0)編輯 收藏

          install docker on Mac


          https://yeasy.gitbook.io/docker_practice/install/mac

          posted @ 2022-11-11 11:07 paulwong 閱讀(150) | 評論 (0)編輯 收藏

          MONGODB SPRING DISTINCT

          SPRING 框架下 如果要做去重,在數據量大的時候會爆ERROR,可改用如下 寫法:

              private boolean needReorderCheck(String requestId) {
                  boolean result = false;
          //        try(MongoCursor<String> mongoCursor = 
          //                mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
          //                             .distinct(KEY, Filters.eq(REQUEST_ID, requestId), String.class)
          //                             .iterator()
          //                )
                  try(MongoCursor<Document> mongoCursor = 
                          mongoTemplate.getCollection(mongoTemplate.getCollectionName(AccountNumProductLineIndex.class))
                                       .aggregate(
                                           Arrays.asList(
                                              Aggregates.project(
                                                              Projections.fields(
                                                                              Projections.excludeId(),
                                                                             Projections.include(KEY),
                                                                             Projections.include(REQUEST_ID)
                                                                          )
                                                         ),
                                              Aggregates.match(Filters.eq(REQUEST_ID, requestId)),
                                              Aggregates.group("$" + KEY)
                                           )
                                        )
                                       .allowDiskUse(true)
                                       .iterator();
                  )
                  {
                      String key = null;
                      boolean breakMe = false;
                      LOGGER.info("needReorderCheck.key --> start");
                      while(mongoCursor.hasNext()) {
                          if(breakMe) {
                              mongoCursor.close();
                              break;
                          }
                          Document keyDocument = mongoCursor.next();
                          key = keyDocument.getString("_id");
          //                key = mongoCursor.next().getString(KEY);
          //                LOGGER.info("needReorderCheck.keyDocument --> {}, key --> {}", keyDocument, key);
                          try(MongoCursor<Document> indexMongoCursor = 
                                  mongoTemplate.getCollection(AccountNumProductLineIndex.COLLECTION_NAME)
                                                  .find(Filters.and(Filters.eq(REQUEST_ID, requestId), Filters.eq(KEY, key)))
                                                  .iterator()
                          )
                          {
                              int preIndex = -1, currentIndex = -1;
                              Document preIndexDocument = null, currentIndexDocument;
                              while(indexMongoCursor.hasNext()) {
                                  currentIndexDocument = indexMongoCursor.next();
          //                        System.out.println(currentIndexDocument.toJson());
                                  if(preIndexDocument != null) {
                                       currentIndex = currentIndexDocument.getInteger(INDEX);
                                       preIndex = preIndexDocument.getInteger(INDEX);
                                       if(currentIndex - preIndex > 1) {
                                          indexMongoCursor.close();
                                          breakMe = true;
                                          result = true;
                                          break;
                                      }
                                  }
                                  preIndexDocument = currentIndexDocument;
                              }
                          }
                      }
                  }
                  
                  return result;
              }

          posted @ 2022-10-18 10:22 paulwong 閱讀(206) | 評論 (0)編輯 收藏

          SPRING JSON TIMEZONE問題大匯總

          @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="America/Phoenix")
          private Date date;

          posted @ 2022-09-22 13:18 paulwong 閱讀(205) | 評論 (0)編輯 收藏

          Downloading Large Files using Spring WebClient

          https://www.amitph.com/spring-webclient-large-file-download/

          https://github.com/amitrp/spring-examples/blob/main/spring-webflux-webclient/src/main/java/com/amitph/spring/webclients/service/FileDownloaderWebClientService.java

          import lombok.RequiredArgsConstructor;
          import org.springframework.core.io.buffer.DataBuffer;
          import org.springframework.core.io.buffer.DataBufferUtils;
          import org.springframework.stereotype.Service;
          import org.springframework.web.reactive.function.client.WebClient;
          import reactor.core.publisher.Flux;
          import reactor.core.publisher.Mono;

          import java.io.IOException;
          import java.nio.file.Files;
          import java.nio.file.Path;
          import java.nio.file.StandardOpenOption;
          import java.util.Objects;

          @Service
          @RequiredArgsConstructor
          public class FileDownloaderWebClientService {
              private final WebClient webClient;

              /**
               * Reads the complete file in-memory. Thus, only useful for very large file
               
          */
              public void downloadUsingByteArray(Path destination) throws IOException {
                  Mono<byte[]> monoContents = webClient
                          .get()
                          .uri("/largefiles/1")
                          .retrieve()
                          .bodyToMono(byte[].class);

                  Files.write(destination, Objects.requireNonNull(monoContents.share().block()),
                          StandardOpenOption.CREATE);
              }

              /**
               * Reading file using Mono will try to fit the entire file into the DataBuffer.
               * Results in exception when the file is larger than the DataBuffer capacity.
               
          */
              public void downloadUsingMono(Path destination) {
                  Mono<DataBuffer> dataBuffer = webClient
                          .get()
                          .uri("/largefiles/1")
                          .retrieve()
                          .bodyToMono(DataBuffer.class);

                  DataBufferUtils.write(dataBuffer, destination,
                          StandardOpenOption.CREATE)
                          .share().block();
              }

              /**
               * Having using Flux we can download files of any size safely.
               * Optionally, we can configure DataBuffer capacity for better memory utilization.
               
          */
              public void downloadUsingFlux(Path destination) {
                  Flux<DataBuffer> dataBuffer = webClient
                          .get()
                          .uri("/largefiles/1")
                          .retrieve()
                          .bodyToFlux(DataBuffer.class);

                  DataBufferUtils.write(dataBuffer, destination,
                          StandardOpenOption.CREATE)
                          .share().block();
              }
          }

          posted @ 2022-09-22 13:14 paulwong 閱讀(267) | 評論 (0)編輯 收藏

          JAVA-SECURITY資源

          加密與安全
          https://www.liaoxuefeng.com/wiki/1252599548343744/1255943717668160

          JAVA KEYSTORE 存儲在MONGODB
          默認情況下,證書是放保存在文件,如果要改成MONGODB做為存儲界質,則要做以下改動:
          https://github.com/jmkgreen/keystore-mongo/tree/master/keystore-mongo/src/main/java/com/github/jmkgreen/keystore/mongo

          關于證書,這里有你想知道的一切
          http://ifeve.com/%e5%85%b3%e4%ba%8e%e8%af%81%e4%b9%a6%e8%bf%99%e9%87%8c%e6%9c%89%e4%bd%a0%e6%83%b3%e7%9f%a5%e9%81%93%e7%9a%84%e4%b8%80%e5%88%87-md/#more-59405

          posted @ 2022-07-18 11:09 paulwong 閱讀(204) | 評論 (0)編輯 收藏

          REDHEAD 8 LINUX 軟件集合

          https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/index


          posted @ 2022-06-23 17:27 paulwong 閱讀(133) | 評論 (0)編輯 收藏

          僅列出標題
          共115頁: First 上一頁 2 3 4 5 6 7 8 9 10 下一頁 Last 
          主站蜘蛛池模板: 高尔夫| 三台县| 白城市| 杭锦旗| 三门县| 怀柔区| 离岛区| 东阳市| 稻城县| 南昌县| 大悟县| 武夷山市| 苍山县| 波密县| 旅游| 当阳市| 定州市| 武山县| 广水市| 柳河县| 陈巴尔虎旗| 荣昌县| 日照市| 商都县| 玉树县| 阳西县| 启东市| 黄骅市| 旺苍县| 昆山市| 越西县| 霍林郭勒市| 中西区| 宜黄县| 泸西县| 治多县| 怀柔区| 阿克陶县| 阳西县| 田林县| 海晏县|